Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -1,21 +1,18 @@ #![allow(incomplete_features, internal_features, mixed_script_confusables)] #![feature( - isqrt, + custom_inner_attributes, + proc_macro_hygiene, vec_into_raw_parts, - const_fn_floating_point_arithmetic, + type_alias_impl_trait, inline_const_pat, iter_chain, - const_option, adt_const_params, stmt_expr_attributes, iter_array_chunks, let_chains, - effects, - const_refs_to_cell, generic_const_exprs, core_intrinsics, iter_intersperse, - const_trait_impl, maybe_uninit_array_assume_init, array_windows, iter_map_windows @@ -25,13 +22,16 @@ pub struct pal<'palette, const N: usize> { inner: &'palette [[f32; N]], } -impl<'a, const N: usize> From<&'a [[f32; N]]> for pal<'a, N> { - fn from(value: &'a [[f32; N]]) -> Self { +impl<'a, const N: usize> pal<'a, N> { + /// Create a ne palette. The length can not be 0 and must be < u32::MAX. + pub fn new(value: &'a [[f32; N]]) -> Self { + let value = value.as_ref(); assert!(value.len() != 0); assert!(value.len() < u32::MAX as usize); pal { inner: value } } } + impl<'a, const N: usize> AsRef<[[f32; N]]> for pal<'a, N> { fn as_ref(&self) -> &[[f32; N]] { &*self @@ -57,7 +57,7 @@ use dumb::Closest; use fimg::{indexed::IndexedImage, Image}; fn dither<'a, const C: usize>( - image: Image<&[f32], C>, + image: Image<impl AsRef<[f32]>, C>, f: impl FnMut(((usize, usize), &[f32; C])) -> u32, pal: pal<'a, C>, ) -> out<'a, pal<'a, C>> { |