@@ -140,12 +140,6 @@ unsafe fn unsafe_slice<'a>(buf: &'a [u8], start: usize, new_len: usize) -> &'a [
140140 slice:: from_raw_parts ( buf. as_ptr ( ) . offset ( start as isize ) , new_len)
141141}
142142
143- macro_rules! otry {
144- ( $x: expr) => {
145- unwrap_or_return!( $x, None )
146- } ;
147- }
148-
149143/// Describes the UTF-8 codepoint containing the byte at index `idx` within
150144/// `buf`.
151145///
@@ -159,7 +153,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option<Codepoint<'a>> {
159153
160154 unsafe {
161155 let x = * buf. get_unchecked ( idx) ;
162- match otry ! ( Byte :: classify( x) ) {
156+ match Byte :: classify ( x) ? {
163157 Byte :: Ascii => Some ( Codepoint {
164158 bytes : unsafe_slice ( buf, idx, 1 ) ,
165159 rewind : 0 ,
@@ -172,7 +166,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option<Codepoint<'a>> {
172166 if !all_cont ( unsafe_slice ( bytes, 1 , n - 1 ) ) {
173167 return None ;
174168 }
175- let meaning = otry ! ( decode( bytes) ) ;
169+ let meaning = decode ( bytes) ? ;
176170 Some ( Codepoint {
177171 bytes : bytes,
178172 rewind : 0 ,
@@ -201,7 +195,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option<Codepoint<'a>> {
201195
202196 start -= 1 ;
203197 checked += 1 ;
204- match otry ! ( Byte :: classify( * buf. get_unchecked( start) ) ) {
198+ match Byte :: classify ( * buf. get_unchecked ( start) ) ? {
205199 Byte :: Cont => ( ) ,
206200 Byte :: Start ( n) => {
207201 let avail = buf. len ( ) - start;
@@ -212,7 +206,7 @@ pub fn classify<'a>(buf: &'a [u8], idx: usize) -> Option<Codepoint<'a>> {
212206 return None ;
213207 }
214208 }
215- let meaning = otry ! ( decode( bytes) ) ;
209+ let meaning = decode ( bytes) ? ;
216210 return Some ( Codepoint {
217211 bytes : bytes,
218212 rewind : idx - start,
0 commit comments