From 63a7cb5c2071d3be5935e13a65f9d86458c77422 Mon Sep 17 00:00:00 2001 From: brevalferrari Date: Tue, 16 Sep 2025 00:31:18 +0200 Subject: [PATCH] Soften text bend-in Allow invalid UTF-8 --- bingus/src/lib.rs | 2 +- bingus/src/txt/bare.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bingus/src/lib.rs b/bingus/src/lib.rs index e8d1cd6..30c7bfc 100644 --- a/bingus/src/lib.rs +++ b/bingus/src/lib.rs @@ -193,7 +193,7 @@ pub mod dynamic { bytes, (), Default::default(), - )?), + ).unwrap()), #[cfg(feature = "binary")] _ => DynamicBendable::Binary(bytes), #[cfg(not(feature = "binary"))] diff --git a/bingus/src/txt/bare.rs b/bingus/src/txt/bare.rs index b58741e..b52d6a3 100644 --- a/bingus/src/txt/bare.rs +++ b/bingus/src/txt/bare.rs @@ -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 { - String::from_utf8(bytes).map(Into::into) + Ok(String::from_utf8_lossy(&bytes).into_owned().into()) } }