Skip to content

Commit 8251fa9

Browse files
committed
Mark U16UtfExt trait as unsafe.
1 parent b764bc1 commit 8251fa9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/traits.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ impl U8UtfExt for u8 {
119119

120120

121121
/// Methods for working with `u16`s as UTF-16 units.
122-
pub trait U16UtfExt {
122+
///
123+
/// This trait is marked unsafe as avoiding undefined behaviour necessarily
124+
/// depends on the implementation of `utf16_needs_extra_unit` being correct.
125+
pub unsafe trait U16UtfExt {
123126
/// Will you need an extra unit to complete this codepoint?
124127
///
125128
/// Returns `Err` for trailing surrogates, `Ok(true)` for leading surrogates,
@@ -132,7 +135,7 @@ pub trait U16UtfExt {
132135
/// Is basically an unchecked variant of `utf16_needs_extra_unit()`.
133136
fn is_utf16_leading_surrogate(self) -> bool;
134137
}
135-
impl U16UtfExt for u16 {
138+
unsafe impl U16UtfExt for u16 {
136139
#[inline]
137140
fn utf16_needs_extra_unit(self) -> Result<bool,Utf16FirstUnitError> {
138141
match self {

0 commit comments

Comments
 (0)