Skip to content

Commit e6d541a

Browse files
committed
Add some explanatory comments.
1 parent 2f7d7c2 commit e6d541a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/libsyntax_pos/symbol.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,8 @@ where
11091109
}
11101110
}
11111111

1112+
// This impl allows a `SymbolStr` to be directly equated with a `String` or
1113+
// `&str`.
11121114
impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr {
11131115
fn eq(&self, other: &T) -> bool {
11141116
self.string == other.deref()
@@ -1118,6 +1120,11 @@ impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr {
11181120
impl !Send for SymbolStr {}
11191121
impl !Sync for SymbolStr {}
11201122

1123+
/// This impl means that if `ss` is a `SymbolStr`:
1124+
/// - `*ss` is a `str`;
1125+
/// - `&*ss` is a `&str`;
1126+
/// - `&ss as &str` is a `&str`, which means that `&ss` can be passed to a
1127+
/// function expecting a `&str`.
11211128
impl std::ops::Deref for SymbolStr {
11221129
type Target = str;
11231130
#[inline]

0 commit comments

Comments
 (0)