small_fixed_array/
truncating_into.rs1use alloc::{string::String, vec::Vec};
2
3use crate::{FixedArray, FixedString, ValidLength};
4
5mod sealed {
6 use alloc::{string::String, vec::Vec};
7
8 #[allow(unnameable_types)]
9 pub trait Sealed {}
10
11 impl Sealed for String {}
12 impl<T> Sealed for Vec<T> {}
13}
14
15pub trait TruncatingInto<T>: sealed::Sealed {
20 fn trunc_into(self) -> T;
21}
22
23impl<LenT: ValidLength> TruncatingInto<FixedString<LenT>> for String {
24 fn trunc_into(self) -> FixedString<LenT> {
25 FixedString::from_string_trunc(self)
26 }
27}
28
29impl<T, LenT: ValidLength> TruncatingInto<FixedArray<T, LenT>> for Vec<T> {
30 fn trunc_into(self) -> FixedArray<T, LenT> {
31 FixedArray::from_vec_trunc(self)
32 }
33}