File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323 integration.
2424
2525### Changed
26+ - ` Token::from_encoded ` now accepts owned or borrowed strings (any type that
27+ implements ` Into<Cow<'_, str>> ` ).
2628- Sealed the ` Diagnose ` trait.
2729- Implementation of the ` Default ` trait for ` Pointer ` now doesn't constrain the lifetime.
2830
Original file line number Diff line number Diff line change @@ -74,9 +74,10 @@ impl<'a> Token<'a> {
7474 /// ## Errors
7575 /// Returns `InvalidEncodingError` if the input string is not a valid RFC
7676 /// 6901 (`~` must be followed by `0` or `1`)
77- pub fn from_encoded ( s : & ' a str ) -> Result < Self , EncodingError > {
77+ pub fn from_encoded ( s : impl Into < Cow < ' a , str > > ) -> Result < Self , EncodingError > {
78+ let inner = s. into ( ) ;
7879 let mut escaped = false ;
79- for ( offset, b) in s . bytes ( ) . enumerate ( ) {
80+ for ( offset, b) in inner . bytes ( ) . enumerate ( ) {
8081 match b {
8182 b'/' => {
8283 return Err ( EncodingError {
@@ -102,11 +103,11 @@ impl<'a> Token<'a> {
102103 }
103104 if escaped {
104105 return Err ( EncodingError {
105- offset : s . len ( ) ,
106+ offset : inner . len ( ) ,
106107 source : InvalidEncoding :: Tilde ,
107108 } ) ;
108109 }
109- Ok ( Self { inner : s . into ( ) } )
110+ Ok ( Self { inner } )
110111 }
111112
112113 /// Constructs a `Token` from an arbitrary string.
You can’t perform that action at this time.
0 commit comments