mirror of
https://github.com/zama-ai/tfhe-rs.git
synced 2026-01-09 14:47:56 -05:00
feat(core): add missing APIs
This commit is contained in:
committed by
Nicolas Sarlin
parent
fff86fb3b4
commit
802945fa52
@@ -1,5 +1,7 @@
|
||||
//! Module with traits pertaining to container manipulation.
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// A trait to manipulate various immutable container types transparently.
|
||||
pub trait Container: AsRef<[Self::Element]> {
|
||||
type Element;
|
||||
@@ -16,6 +18,10 @@ impl<T> Container for [T] {
|
||||
type Element = T;
|
||||
}
|
||||
|
||||
impl<T: Clone> Container for Cow<'_, [T]> {
|
||||
type Element = T;
|
||||
}
|
||||
|
||||
impl<T> ContainerMut for [T] {}
|
||||
|
||||
impl<T> Container for Vec<T> {
|
||||
|
||||
@@ -81,6 +81,14 @@ where
|
||||
SwitchedScalar: UnsignedInteger,
|
||||
C: Container<Element = Scalar>,
|
||||
{
|
||||
pub fn into_raw_parts(self) -> (LweCiphertext<C>, Scalar, CiphertextModulusLog) {
|
||||
(
|
||||
self.lwe_in,
|
||||
self.body_correction_to_add_before_switching,
|
||||
self.log_modulus,
|
||||
)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn from_raw_parts(
|
||||
lwe_in: LweCiphertext<C>,
|
||||
|
||||
Reference in New Issue
Block a user