pub fn to_string_lossy(self) -> Cow<'a, str> {
        match self {
            PyStringData::Utf8(data) => String::from_utf8_lossy(data),
            PyStringData::Latin1(data) => {
                if data.iter().all(|&b| b.is_ascii()) {
                    Cow::Borrowed(unsafe { str::from_utf8_unchecked(data) })
                } else {
                    Cow::Owned(data.iter().map(|&b| b as char).collect())
                }
            },
            PyStringData::Utf16(data) => {
                Cow::Owned(String::from_utf16_lossy(data))
            },
            PyStringData::Utf32(data) => {
                Cow::Owned(data.iter()
                           .map(|&u| char::from_u32(u).unwrap_or('\u{FFFD}'))
                           .collect())
            }
        }
    }
/// Convert the Python string data to a Rust string.
///
/// Returns a borrow into the original string data if possible.
///
/// Data that isn't valid in its encoding will be replaced
/// with U+FFFD REPLACEMENT CHARACTER.
Convert the Python string data to a Rust string.
Returns a borrow into the original string data if possible.

Data that isn't valid in its encoding will be replaced
with U+FFFD REPLACEMENT CHARACTER.
Convert the Python string data to a Rust string . Returns a borrow into the original string data if possible . Data that isn ' t valid in its encoding will be replaced with U + FFFD REPLACEMENT CHARACTER .
pub fn to_string_lossy(self) -> Cow<'a, str> {
        match self {
            PyStringData::Utf8(data) => String::from_utf8_lossy(data),
            PyStringData::Latin1(data) => {
                if data.iter().all(|&b| b.is_ascii()) {
                    Cow::Borrowed(unsafe { str::from_utf8_unchecked(data) })
                } else {
                    Cow::Owned(data.iter().map(|&b| b as char).collect())
                }
            },
            PyStringData::Utf16(data) => {
                Cow::Owned(String::from_utf16_lossy(data))
            },
            PyStringData::Utf32(data) => {
                Cow::Owned(data.iter()
                           .map(|&u| char::from_u32(u).unwrap_or('\u{FFFD}'))
                           .collect())
            }
        }
    }
pub fn to_string_lossy ( self ) -> Cow < ' a , str > { match self { PyStringData :: Utf8 ( data ) => String :: from_utf8_lossy ( data ) , PyStringData :: Latin1 ( data ) => { if data . iter ( ) . all ( | & b | b . is_ascii ( ) ) { Cow :: Borrowed ( unsafe { str :: from_utf8_unchecked ( data ) } ) } else { Cow :: Owned ( data . iter ( ) . map ( | & b | b as char ) . collect ( ) ) } } , PyStringData :: Utf16 ( data ) => { Cow :: Owned ( String :: from_utf16_lossy ( data ) ) } , PyStringData :: Utf32 ( data ) => { Cow :: Owned ( data . iter ( ) . map ( | & u | char :: from_u32 ( u ) . unwrap_or ( '\u{FFFD}' ) ) . collect ( ) ) } } }
Convert the Python string data to a Rust string.
Convert the Python string data to a Rust string .
self
self