mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-09 14:47:56 -05:00
refactor!: Use NonZero<T> in DataKind
Change the type used to store a block count in DataKind to NonZero. This makes it impossible to store 'empty' kinds such as DataKind::Unsigned(0), DataKind::Signed(0). Also, when deserializing, if the count is zero and error will be returned, adding an additional layer of sanitization.
This commit is contained in:
@@ -18,7 +18,7 @@ use std::convert::Infallible;
|
||||
use std::error::Error;
|
||||
use std::fmt::Display;
|
||||
use std::marker::PhantomData;
|
||||
use std::num::Wrapping;
|
||||
use std::num::{NonZero, Wrapping};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub use derived_traits::{Version, VersionsDispatch};
|
||||
@@ -268,6 +268,9 @@ impl_scalar_versionize!(f64);
|
||||
|
||||
impl_scalar_versionize!(char);
|
||||
|
||||
impl_scalar_versionize!(NonZero<u32>);
|
||||
impl_scalar_versionize!(NonZero<usize>);
|
||||
|
||||
impl<T: Versionize> Versionize for Wrapping<T> {
|
||||
type Versioned<'vers>
|
||||
= Wrapping<T::Versioned<'vers>>
|
||||
|
||||
Reference in New Issue
Block a user