about summary refs log tree commit diff
path: root/src/libstd/thread
diff options
context:
space:
mode:
authorAlexander Bulaev <aleks.bulaev@gmail.com>2015-11-04 15:03:33 +0300
committerAlexander Bulaev <aleks.bulaev@gmail.com>2015-11-04 15:03:33 +0300
commitfcc79f2d60d55114ae890e1112393ef0e2e8d93f (patch)
tree06adda2f3d316e558bcbf5418711977445a9ba98 /src/libstd/thread
parenta216e847272ddbd3033037b606eaf2d801c250b9 (diff)
downloadrust-fcc79f2d60d55114ae890e1112393ef0e2e8d93f.tar.gz
rust-fcc79f2d60d55114ae890e1112393ef0e2e8d93f.zip
liballoc: implement From for Box, Rc, Arc
Sometimes when writing generic code you want to abstract over
owning/pointer type so that calling code isn't restricted by one
concrete owning/pointer type. This commit makes possible such code:
```
fn i_will_work_with_arc<T: Into<Arc<MyTy>>>(t: T) {
    let the_arc = t.into();
    // Do something
}

i_will_work_with_arc(MyTy::new());

i_will_work_with_arc(Box::new(MyTy::new()));

let arc_that_i_already_have = Arc::new(MyTy::new());
i_will_work_with_arc(arc_that_i_already_have);
```

Please note that this patch doesn't work with DSTs.
Diffstat (limited to 'src/libstd/thread')
0 files changed, 0 insertions, 0 deletions