2 #![allow(unused_braces)]
4 // pretty-expanded FIXME #23616
8 // Examples from the "deref coercions" RFC, at rust-lang/rfcs#241.
10 fn use_ref<T>(_: &T) {}
11 fn use_mut<T>(_: &mut T) {}
13 fn use_rc<T>(t: Rc<T>) {
14 use_ref(&*t); // what you have to write today
15 use_ref(&t); // what you'd be able to write
21 fn use_mut_box<T>(mut t: &mut Box<T>) {
22 use_mut(&mut *t); // what you have to write today
23 use_mut(t); // what you'd be able to write
24 use_mut(&mut &mut &mut t);
26 use_ref(&*t); // what you have to write today
27 use_ref(t); // what you'd be able to write
33 fn use_nested<T>(t: &Box<T>) {
34 use_ref(&**t); // what you have to write today
35 use_ref(t); // what you'd be able to write (note: recursive deref)
41 fn use_slice(_: &[u8]) {}
42 fn use_slice_mut(_: &mut [u8]) {}
44 fn use_vec(mut v: Vec<u8>) {
45 use_slice_mut(&mut v[..]); // what you have to write today
46 use_slice_mut(&mut v); // what you'd be able to write
47 use_slice_mut(&mut &mut &mut v);
49 use_slice(&v[..]); // what you have to write today
50 use_slice(&v); // what you'd be able to write
52 use_slice(&mut &&&&&v);
53 use_slice(&&&mut &&&v);
56 fn use_vec_ref(v: &Vec<u8>) {
57 use_slice(&v[..]); // what you have to write today
58 use_slice(v); // what you'd be able to write
60 use_slice(&mut &&&&&v);
61 use_slice(&&&mut &&&v);
64 fn use_op_rhs(s: &mut String) {
65 *s += {&String::from(" ")};