diff options
| author | Alexander Bulaev <aleks.bulaev@gmail.com> | 2015-11-04 15:03:33 +0300 |
|---|---|---|
| committer | Alexander Bulaev <aleks.bulaev@gmail.com> | 2015-11-04 15:03:33 +0300 |
| commit | fcc79f2d60d55114ae890e1112393ef0e2e8d93f (patch) | |
| tree | 06adda2f3d316e558bcbf5418711977445a9ba98 /src/liballoc_system | |
| parent | a216e847272ddbd3033037b606eaf2d801c250b9 (diff) | |
| download | rust-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/liballoc_system')
0 files changed, 0 insertions, 0 deletions
