File tree Expand file tree Collapse file tree 2 files changed +5
-13
lines changed
Expand file tree Collapse file tree 2 files changed +5
-13
lines changed Original file line number Diff line number Diff line change @@ -7,13 +7,13 @@ pub(super) struct Buf<'a> {
77}
88
99impl < ' a > Buf < ' a > {
10- pub ( super ) fn new ( bytes : & ' a mut [ u8 ] ) -> Self {
10+ pub fn new ( bytes : & ' a mut [ u8 ] ) -> Self {
1111 Buf { bytes, offset : 0 }
1212 }
1313
14- pub ( super ) unsafe fn as_str ( & self ) -> & str {
14+ pub fn as_str ( & self ) -> & str {
1515 let slice = & self . bytes [ ..self . offset ] ;
16- str:: from_utf8_unchecked ( slice)
16+ unsafe { str:: from_utf8_unchecked ( slice) }
1717 }
1818}
1919
Original file line number Diff line number Diff line change @@ -1376,11 +1376,7 @@ pub trait Visitor<'de>: Sized {
13761376 let mut buf = [ 0u8 ; 58 ] ;
13771377 let mut writer = format:: Buf :: new( & mut buf) ;
13781378 fmt:: Write :: write_fmt( & mut writer, format_args!( "integer `{}` as i128" , v) ) . unwrap( ) ;
1379-
1380- // Safety: This is safe because we only wrote UTF-8 into the buffer.
1381- let s = unsafe { writer. as_str( ) } ;
1382-
1383- Err ( Error :: invalid_type( Unexpected :: Other ( s) , & self ) )
1379+ Err ( Error :: invalid_type( Unexpected :: Other ( writer. as_str( ) ) , & self ) )
13841380 }
13851381 }
13861382
@@ -1442,11 +1438,7 @@ pub trait Visitor<'de>: Sized {
14421438 let mut buf = [ 0u8 ; 57 ] ;
14431439 let mut writer = format:: Buf :: new( & mut buf) ;
14441440 fmt:: Write :: write_fmt( & mut writer, format_args!( "integer `{}` as u128" , v) ) . unwrap( ) ;
1445-
1446- // Safety: This is safe because we only wrote UTF-8 into the buffer.
1447- let s = unsafe { writer. as_str( ) } ;
1448-
1449- Err ( Error :: invalid_type( Unexpected :: Other ( s) , & self ) )
1441+ Err ( Error :: invalid_type( Unexpected :: Other ( writer. as_str( ) ) , & self ) )
14501442 }
14511443 }
14521444
You can’t perform that action at this time.
0 commit comments