Soften text bend-in

Allow invalid UTF-8
This commit is contained in:
brevalferrari 2025-09-16 00:31:18 +02:00
parent 533cb094e0
commit 63a7cb5c20
Signed by: breval
GPG key ID: 913954DA013FAD4F
2 changed files with 4 additions and 4 deletions

View file

@ -193,7 +193,7 @@ pub mod dynamic {
bytes, bytes,
(), (),
Default::default(), Default::default(),
)?), ).unwrap()),
#[cfg(feature = "binary")] #[cfg(feature = "binary")]
_ => DynamicBendable::Binary(bytes), _ => DynamicBendable::Binary(bytes),
#[cfg(not(feature = "binary"))] #[cfg(not(feature = "binary"))]

View file

@ -1,18 +1,18 @@
use std::{borrow::Cow, string::FromUtf8Error}; use std::{borrow::Cow, convert::Infallible};
use crate::{Bendable, Bytes, IntoDataBytes, TryFromDataBytes}; use crate::{Bendable, Bytes, IntoDataBytes, TryFromDataBytes};
pub type Text<'a> = Cow<'a, str>; pub type Text<'a> = Cow<'a, str>;
impl TryFromDataBytes for Text<'_> { impl TryFromDataBytes for Text<'_> {
type Error = FromUtf8Error; type Error = Infallible;
type Format = (); type Format = ();
fn try_from_data_bytes( fn try_from_data_bytes(
bytes: Bytes, bytes: Bytes,
_format: Self::Format, _format: Self::Format,
_crop: crate::Crop, _crop: crate::Crop,
) -> Result<Self, Self::Error> { ) -> Result<Self, Self::Error> {
String::from_utf8(bytes).map(Into::into) Ok(String::from_utf8_lossy(&bytes).into_owned().into())
} }
} }