diff --git a/rust/src/ident.rs b/rust/src/ident.rs index c392699..e919695 100644 --- a/rust/src/ident.rs +++ b/rust/src/ident.rs @@ -19,7 +19,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::fmt::{self, Debug, Formatter}; use std::str::FromStr; use amplify::Wrapper; @@ -46,14 +45,18 @@ macro_rules! impl_ident_type { fn try_from(s: String) -> Result { Self::from_str(&s) } } - impl Debug for $ty { - fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { + impl ::core::fmt::Debug for $ty { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { f.debug_tuple(&$crate::type_name::()) .field(&self.as_str()) .finish() } } + impl ::core::borrow::Borrow for $ty { + fn borrow(&self) -> &str { self.as_str() } + } + impl $ty { /// Returns string reference. pub fn as_str(&self) -> &str { self.0.as_str() } diff --git a/rust/src/stl.rs b/rust/src/stl.rs index ff4df41..5603858 100644 --- a/rust/src/stl.rs +++ b/rust/src/stl.rs @@ -21,6 +21,7 @@ #![allow(non_camel_case_types, unused_imports)] +use std::borrow::Borrow; use std::fmt::{Debug, Display, Formatter}; use std::marker::PhantomData; use std::ops::Deref; @@ -102,6 +103,12 @@ impl &str { self.s.as_str() } } +impl Borrow + for RString +{ + fn borrow(&self) -> &str { self.s.as_str() } +} + impl FromStr for RString {