diff --git a/rust/common/src/packed_func.rs b/rust/common/src/packed_func.rs index d9399492264b..8fa732e1a4ea 100644 --- a/rust/common/src/packed_func.rs +++ b/rust/common/src/packed_func.rs @@ -166,6 +166,10 @@ TVMPODValue! { /// # Example /// /// ``` + /// # use std::convert::TryFrom; + /// # use std::convert::TryInto; + /// # use self::tvm_common::TVMRetValue; + /// /// let a = 42u32; /// let b: i64 = TVMRetValue::from(a).try_into().unwrap(); /// @@ -335,6 +339,12 @@ impl From for TVMRetValue { } } +impl From<&str> for TVMRetValue { + fn from(s: &str) -> Self { + Self::from(s.to_string()) + } +} + impl From for TVMRetValue { fn from(arr: TVMByteArray) -> Self { Self::Bytes(arr) diff --git a/rust/common/src/value.rs b/rust/common/src/value.rs index 6d17db207865..4b991b6d9a98 100644 --- a/rust/common/src/value.rs +++ b/rust/common/src/value.rs @@ -162,6 +162,8 @@ impl_tvm_context!( /// ## Example /// /// ``` +/// # use self::tvm_common::TVMByteArray; +/// /// let v = b"hello"; /// let barr = TVMByteArray::from(&v); /// assert_eq!(barr.len(), v.len());