diff --git a/src/lib.rs b/src/lib.rs index f37106e..03d298b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -223,7 +223,11 @@ where // however the user // can be as bright as Proxima Centauri // or as dark as Sagittarius A - let str_arg = match str::from_utf8(arg) { + // + // `inherent_str_constructors` is not stabilised yet + // https://github.com/rust-lang/rust/issues/131114 + // use `str::from_utf8(arg)` if you don't care about stable rust + let str_arg = match core::str::from_utf8(arg) { Err(_e) => { let err = ParsingError::InvalidString; return Err(err); @@ -257,7 +261,12 @@ where // might not be needed, // however i am not sure of the user's // eternal glory and shine - let str_arg = match str::from_utf8(arg.as_encoded_bytes()) { + // + // `inherent_str_constructors` is not stabilised yet + // https://github.com/rust-lang/rust/issues/131114 + // use `str::from_utf8(arg.as_encoded_bytes())` + // if you don't care about stable rust + let str_arg = match core::str::from_utf8(arg.as_encoded_bytes()) { Err(_e) => { let err = ParsingError::InvalidString; return Err(err); @@ -353,14 +362,20 @@ impl Display for ParsingError { Self::InvalidOption { reason, offender } => { let reserve = write!(f, "reason: {reason}"); if let Some(sentence) = offender { - return write!(f, " at: {}", sentence.display()); + // `os_str_display` is stabilised in 1.87.0 + // https://github.com/rust-lang/rust/issues/120048 + // use `sentence.display()` if you don't care about rust <1.87.0 + return write!(f, " at: {}", String::from_utf8_lossy(sentence.as_bytes())); } reserve } Self::UnconsumedValue { value } => { - write!(f, "leftover value: {}", value.display()) + // `os_str_display` is stabilised in 1.87.0 + // https://github.com/rust-lang/rust/issues/120048 + // use `value.display()` if you don't care about rust <1.87.0 + write!(f, "leftover value: {}", String::from_utf8_lossy(value.as_bytes())) } Self::UnexpectedArg {