Skip to content

Commit 5164b0e

Browse files
committed
hidpp: use str::from_utf8 instead of core::str::from_utf8 (rust-lang/rust#137277)
1 parent 4bb2415 commit 5164b0e

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

hidpp/src/feature/device_friendly_name/v0.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ impl DeviceFriendlyNameFeatureV0 {
102102
let mut len = 0;
103103
while len < count as usize {
104104
let part = self.get_friendly_name(len as u8).await?;
105-
string.push_str(
106-
core::str::from_utf8(&part).map_err(|_| Hidpp20Error::UnsupportedResponse)?,
107-
);
105+
string.push_str(str::from_utf8(&part).map_err(|_| Hidpp20Error::UnsupportedResponse)?);
108106
len = string.len();
109107
}
110108

@@ -148,9 +146,7 @@ impl DeviceFriendlyNameFeatureV0 {
148146
let mut len = 0;
149147
while len < count as usize {
150148
let part = self.get_default_friendly_name(len as u8).await?;
151-
string.push_str(
152-
core::str::from_utf8(&part).map_err(|_| Hidpp20Error::UnsupportedResponse)?,
153-
);
149+
string.push_str(str::from_utf8(&part).map_err(|_| Hidpp20Error::UnsupportedResponse)?);
154150
len = string.len();
155151
}
156152

hidpp/src/feature/device_type_and_name/v0.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ impl DeviceTypeAndNameFeatureV0 {
101101
let mut len = 0;
102102
while len < count as usize {
103103
let part = self.get_device_name(len as u8).await?;
104-
string.push_str(
105-
core::str::from_utf8(&part).map_err(|_| Hidpp20Error::UnsupportedResponse)?,
106-
);
104+
string.push_str(str::from_utf8(&part).map_err(|_| Hidpp20Error::UnsupportedResponse)?);
107105
len = string.len();
108106
}
109107

hidpp/src/receiver/bolt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl BoltReceiver {
184184

185185
// I have no clue how to retrieve the serial number of the receiver.
186186

187-
Ok(core::str::from_utf8(&response)
187+
Ok(str::from_utf8(&response)
188188
.map_err(|_| Hidpp10Error::UnsupportedResponse)?
189189
.to_string())
190190
}
@@ -229,7 +229,7 @@ impl BoltReceiver {
229229
.await?;
230230

231231
let end_idx = response[2] as usize;
232-
Ok(core::str::from_utf8(&response[3..end_idx])
232+
Ok(str::from_utf8(&response[3..end_idx])
233233
.map_err(|_| Hidpp10Error::UnsupportedResponse)?
234234
.to_string())
235235
}

0 commit comments

Comments
 (0)