Skip to content

Commit 484153d

Browse files
committed
Fix lints
1 parent 5ffc900 commit 484153d

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

src/borsh.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
use crate::{Repr, SmolStr, INLINE_CAP};
22
use alloc::string::{String, ToString};
3-
use borsh::io::{Error, ErrorKind, Read, Write};
4-
use borsh::{BorshDeserialize, BorshSerialize};
5-
use core::intrinsics::transmute;
3+
use borsh::{
4+
io::{Error, ErrorKind, Read, Write},
5+
BorshDeserialize, BorshSerialize,
6+
};
7+
use core::mem::transmute;
68

79
impl BorshSerialize for SmolStr {
810
fn serialize<W: Write>(&self, writer: &mut W) -> borsh::io::Result<()> {
@@ -27,12 +29,8 @@ impl BorshDeserialize for SmolStr {
2729
}))
2830
} else {
2931
// u8::vec_from_reader always returns Some on success in current implementation
30-
let vec = u8::vec_from_reader(len, reader)?.ok_or_else(|| {
31-
Error::new(
32-
ErrorKind::Other,
33-
"u8::vec_from_reader unexpectedly returned None".to_string(),
34-
)
35-
})?;
32+
let vec = u8::vec_from_reader(len, reader)?
33+
.ok_or_else(|| Error::other("u8::vec_from_reader unexpectedly returned None"))?;
3634
Ok(SmolStr::from(String::from_utf8(vec).map_err(|err| {
3735
let msg = err.to_string();
3836
Error::new(ErrorKind::InvalidData, msg)

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'a> PartialEq<&'a str> for SmolStr {
161161
}
162162
}
163163

164-
impl<'a> PartialEq<SmolStr> for &'a str {
164+
impl PartialEq<SmolStr> for &str {
165165
#[inline(always)]
166166
fn eq(&self, other: &SmolStr) -> bool {
167167
*self == other
@@ -189,7 +189,7 @@ impl<'a> PartialEq<&'a String> for SmolStr {
189189
}
190190
}
191191

192-
impl<'a> PartialEq<SmolStr> for &'a String {
192+
impl PartialEq<SmolStr> for &String {
193193
#[inline(always)]
194194
fn eq(&self, other: &SmolStr) -> bool {
195195
*self == other
@@ -380,7 +380,7 @@ impl From<Box<str>> for SmolStr {
380380
impl From<Arc<str>> for SmolStr {
381381
#[inline]
382382
fn from(s: Arc<str>) -> SmolStr {
383-
let repr = Repr::new_on_stack(s.as_ref()).unwrap_or_else(|| Repr::Heap(s));
383+
let repr = Repr::new_on_stack(s.as_ref()).unwrap_or(Repr::Heap(s));
384384
Self(repr)
385385
}
386386
}

tests/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,8 @@ mod test_str_ext {
390390
assert!(!result.is_heap_allocated());
391391
}
392392
}
393-
#[cfg(feature = "borsh")]
394393

394+
#[cfg(feature = "borsh")]
395395
mod borsh_tests {
396396
use borsh::BorshDeserialize;
397397
use smol_str::{SmolStr, ToSmolStr};

0 commit comments

Comments
 (0)