diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-10-22 11:09:42 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2019-11-02 09:00:28 +1100 |
| commit | e6d541a60abd7941fb19996c0327a1229d4bcbbe (patch) | |
| tree | 4d6ef830e3da50de9b0740ca0946b865ba653bbf | |
| parent | 2f7d7c2ca44a1487157394e1562e793dbb3db81f (diff) | |
| download | rust-e6d541a60abd7941fb19996c0327a1229d4bcbbe.tar.gz rust-e6d541a60abd7941fb19996c0327a1229d4bcbbe.zip | |
Add some explanatory comments.
| -rw-r--r-- | src/libsyntax_pos/symbol.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 0d11a4c426a..4ff558a22e1 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -1109,6 +1109,8 @@ where } } +// This impl allows a `SymbolStr` to be directly equated with a `String` or +// `&str`. impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr { fn eq(&self, other: &T) -> bool { self.string == other.deref() @@ -1118,6 +1120,11 @@ impl<T: std::ops::Deref<Target = str>> std::cmp::PartialEq<T> for SymbolStr { impl !Send for SymbolStr {} impl !Sync for SymbolStr {} +/// This impl means that if `ss` is a `SymbolStr`: +/// - `*ss` is a `str`; +/// - `&*ss` is a `&str`; +/// - `&ss as &str` is a `&str`, which means that `&ss` can be passed to a +/// function expecting a `&str`. impl std::ops::Deref for SymbolStr { type Target = str; #[inline] |
