1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
use core::convert::Infallible; use alloc::str::FromStr; use alloc::string::String; #[cfg(feature = "std")] use std::{ ffi::{OsStr, OsString}, path::{Path, PathBuf}, }; use crate::Cow; impl<'a> FromStr for Cow<'a, str> { type Err = Infallible; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self::owned(String::from(s))) } } #[cfg(feature = "std")] impl<'a> FromStr for Cow<'a, OsStr> { type Err = Infallible; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self::owned(OsString::from(s))) } } #[cfg(feature = "std")] impl<'a> FromStr for Cow<'a, Path> { type Err = Infallible; fn from_str(s: &str) -> Result<Self, Self::Err> { Ok(Self::owned(PathBuf::from(s))) } }