Soften text bend-in
Allow invalid UTF-8
This commit is contained in:
parent
533cb094e0
commit
63a7cb5c20
2 changed files with 4 additions and 4 deletions
|
@ -193,7 +193,7 @@ pub mod dynamic {
|
|||
bytes,
|
||||
(),
|
||||
Default::default(),
|
||||
)?),
|
||||
).unwrap()),
|
||||
#[cfg(feature = "binary")]
|
||||
_ => DynamicBendable::Binary(bytes),
|
||||
#[cfg(not(feature = "binary"))]
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
use std::{borrow::Cow, string::FromUtf8Error};
|
||||
use std::{borrow::Cow, convert::Infallible};
|
||||
|
||||
use crate::{Bendable, Bytes, IntoDataBytes, TryFromDataBytes};
|
||||
|
||||
pub type Text<'a> = Cow<'a, str>;
|
||||
|
||||
impl TryFromDataBytes for Text<'_> {
|
||||
type Error = FromUtf8Error;
|
||||
type Error = Infallible;
|
||||
type Format = ();
|
||||
fn try_from_data_bytes(
|
||||
bytes: Bytes,
|
||||
_format: Self::Format,
|
||||
_crop: crate::Crop,
|
||||
) -> Result<Self, Self::Error> {
|
||||
String::from_utf8(bytes).map(Into::into)
|
||||
Ok(String::from_utf8_lossy(&bytes).into_owned().into())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue