File tree Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Expand file tree Collapse file tree 2 files changed +4
-2
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( round_char_boundary) ]
2
+
1
3
pub mod prelude;
2
4
3
5
pub mod id;
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ impl Username {
127
127
pub fn new_coerce ( s : & str ) -> Self {
128
128
let mut s = s. to_string ( ) ;
129
129
s. retain ( |c| c != '[' ) ;
130
- s. truncate ( 10 ) ;
130
+ s. truncate ( s . floor_char_boundary ( 10 ) ) ;
131
131
// expect() is safe here; we've already truncated to the max length
132
132
Self ( ArrayString :: try_from ( s. as_str ( ) ) . expect ( "Failed to convert string" ) )
133
133
}
@@ -138,7 +138,7 @@ impl ChannelKey {
138
138
let mut s = s. to_string ( ) ;
139
139
s. retain ( |c| c > ' ' && c <= '~' && c != ':' && c != ',' ) ;
140
140
let mut val = <Self as Validated >:: Underlying :: new ( ) ;
141
- s. truncate ( val. capacity ( ) ) ;
141
+ s. truncate ( s . floor_char_boundary ( val. capacity ( ) ) ) ;
142
142
val. push_str ( & s) ;
143
143
Self :: validate ( & val) . map ( |( ) | Self ( val) )
144
144
}
You can’t perform that action at this time.
0 commit comments