Skip to content

Commit aaaa563

Browse files
committed
RFC: Remove cross borrowing entirely
1 parent 3c2aa77 commit aaaa563

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
- Start Date: 2014-06-25
2+
- RFC PR #: (leave this empty)
3+
- Rust Issue #: #10504
4+
5+
# Summary
6+
7+
Remove the coercion from `Box<T>` to `&T` from the language.
8+
9+
# Motivation
10+
11+
The coercion between `Box<T>` to `&T` is not replicable by user-defined smart pointers and has been found to be rarely used [1]. We already removed the coercion between `Box<T>` and `&mut T` in RFC 33.
12+
13+
# Detailed design
14+
15+
The coercion between `Box<T>` and `&T` should be removed.
16+
17+
Note that methods that take `&self` can still be called on values of type `Box<T>` without any special referencing or dereferencing. That is because the semantics of auto-deref and auto-ref conspire to make it work: the types unify after one autoderef followed by one autoref.
18+
19+
# Drawbacks
20+
21+
Borrowing from `Box<T>` to `&T` may be convenient.
22+
23+
# Alternatives
24+
25+
The impact of not doing this is that the coercion will remain.
26+
27+
# Unresolved questions
28+
29+
None.
30+
31+
[1]: https://github.com/rust-lang/rust/pull/15171

0 commit comments

Comments
 (0)