Skip to content

Commit ec284ba

Browse files
committed
Remove unnecessary transmute and expand some unsafe blocks
1 parent 048b3ec commit ec284ba

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/ascii.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,9 @@ impl Ascii {
189189
/// ```
190190
#[inline]
191191
pub fn from(ch: char) -> Result<Ascii, ()> {
192-
if ch as u32 <= 0x7F {
193-
return Ok(unsafe{ ch.to_ascii_nocheck() });
194-
}
192+
unsafe{if ch as u32 <= 0x7F {
193+
return Ok(ch.to_ascii_nocheck());
194+
}}
195195
Err(())
196196
}
197197

@@ -210,16 +210,16 @@ impl Ascii {
210210
/// ```
211211
#[inline]
212212
pub fn from_byte(ch: u8) -> Result<Ascii, ()> {
213-
if ch <= 0x7F {
214-
return Ok(unsafe{ ch.to_ascii_nocheck() });
215-
}
213+
unsafe{if ch <= 0x7F {
214+
return Ok(ch.to_ascii_nocheck());
215+
}}
216216
Err(())
217217
}
218218

219219
/// Converts an ascii character into a `u8`.
220220
#[inline]
221221
pub fn as_byte(&self) -> u8 {
222-
unsafe{ transmute(*self) }
222+
*self as u8
223223
}
224224

225225
/// Converts an ascii character into a `char`.

0 commit comments

Comments
 (0)