@@ -36,8 +36,8 @@ language, coercions included things like auto-borrowing (taking `T` to `&T`),
36
36
auto-slicing (taking ` Vec<T> ` to ` &[T] ` ) and "cross-borrowing" (taking ` Box<T> `
37
37
to ` &T ` ). As built-in types migrated to the library, these coercions have
38
38
disappeared: none of them apply today. That means that you have to write code
39
- like ` &**v ` to convert ` Rc<Box <T>> ` to ` &T ` and ` v.as_slice() ` to convert
40
- ` Vec<T> ` to ` &T ` .
39
+ like ` &**v ` to convert ` &Box<T> ` or ` Rc<RefCell <T>> ` to ` &T ` and ` v.as_slice() `
40
+ to convert ` Vec<T> ` to ` &T ` .
41
41
42
42
The ergonomic regression was coupled with a promise that we'd improve things in
43
43
a more general way later on.
@@ -176,15 +176,24 @@ Under this coercion design, we'd see the following ergonomic improvements for
176
176
177
177
``` rust
178
178
fn use_ref (t : & T ) { ... }
179
+ fn use_mut (t : & mut T ) { ... }
179
180
180
181
fn use_rc (t : Rc <T >) {
181
182
use_ref (& * t ); // what you have to write today
182
183
use_ref (& t ); // what you'd be able to write
183
184
}
184
185
185
- fn use_nested (t : Rc <Box <T >>) {
186
+ fn use_mut (t : & mut Box <T >) {
187
+ use_mut (& mut * t ); // what you have to write today
188
+ use_mut (t ); // what you'd be able to write
189
+
190
+ use_ref (* t ); // what you have to write today
191
+ use_ref (t ); // what you'd be able to write
192
+ }
193
+
194
+ fn use_nested (t : & Box <T >) {
186
195
use_ref (& * * t ); // what you have to write today
187
- use_ref (& t ); // what you'd be able to write (note: recursive deref)
196
+ use_ref (t ); // what you'd be able to write (note: recursive deref)
188
197
}
189
198
```
190
199
0 commit comments