Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #21648 from alexanderkjall/borsh-error-compilation-failure
fix smol_str compilation error
Chayim Refael Friedman 2 months ago
parent 4d29f32 · parent f9ca8b2 · commit 00a9173
-rw-r--r--lib/smol_str/src/borsh.rs5
-rw-r--r--lib/smol_str/tests/test.rs2
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/smol_str/src/borsh.rs b/lib/smol_str/src/borsh.rs
index 527ce85a17..b684a4910c 100644
--- a/lib/smol_str/src/borsh.rs
+++ b/lib/smol_str/src/borsh.rs
@@ -29,8 +29,9 @@ impl BorshDeserialize for SmolStr {
}))
} else {
// u8::vec_from_reader always returns Some on success in current implementation
- let vec = u8::vec_from_reader(len, reader)?
- .ok_or_else(|| Error::other("u8::vec_from_reader unexpectedly returned None"))?;
+ let vec = u8::vec_from_reader(len, reader)?.ok_or_else(|| {
+ Error::new(ErrorKind::Other, "u8::vec_from_reader unexpectedly returned None")
+ })?;
Ok(SmolStr::from(String::from_utf8(vec).map_err(|err| {
let msg = err.to_string();
Error::new(ErrorKind::InvalidData, msg)
diff --git a/lib/smol_str/tests/test.rs b/lib/smol_str/tests/test.rs
index 640e7df681..00fab2ee1c 100644
--- a/lib/smol_str/tests/test.rs
+++ b/lib/smol_str/tests/test.rs
@@ -393,7 +393,7 @@ mod test_str_ext {
}
}
-#[cfg(feature = "borsh")]
+#[cfg(all(feature = "borsh", feature = "std"))]
mod borsh_tests {
use borsh::BorshDeserialize;
use smol_str::{SmolStr, ToSmolStr};