Struct opendp::domains::AtomDomain
source · pub struct AtomDomain<T: CheckAtom> {
bounds: Option<Bounds<T>>,
nullable: bool,
}
Expand description
Proof Definition
AtomDomain(T)
is the domain of all values of an atomic type T
.
If bounds are set, then the domain is restricted to the bounds.
If nullable is set, then null value(s) are included in the domain.
Notes
If nullable is set, a domain may have multiple possible null values,
like in the case of floating-point numbers, which have ~2^MANTISSA_BITS
null values.
Because domains are defined in terms of a union, null values need a conceptual definition of equality to uniquely identify them in a set. In order to construct a well-defined set of members in the domain, we consider null values to have the same identity if their bit representation is equal.
Example
// Create a domain that includes all values `{0, 1, ..., 2^32 - 1}`.
use opendp::domains::AtomDomain;
let i32_domain = AtomDomain::<i32>::default();
// 1 is a member of the i32_domain
use opendp::core::Domain;
assert!(i32_domain.member(&1)?);
// Create a domain that includes all non-null 32-bit floats.
let f32_domain = AtomDomain::<f32>::default();
// 1. is a member of the f32_domain
assert!(f32_domain.member(&1.)?);
// NAN is not a member of the f32_domain
assert!(!f32_domain.member(&f32::NAN)?);
Null Example
use opendp::domains::{Null, AtomDomain};
let all_domain = AtomDomain::default();
let null_domain = AtomDomain::new_nullable();
use opendp::core::Domain;
// f64 NAN is not a member of all_domain, but is a member of null_domain
assert!(!all_domain.member(&f64::NAN)?);
assert!(null_domain.member(&f64::NAN)?);
Fields§
§bounds: Option<Bounds<T>>
§nullable: bool
Implementations§
source§impl<T: CheckAtom> AtomDomain<T>
impl<T: CheckAtom> AtomDomain<T>
source§impl<T: CheckAtom + InherentNull> AtomDomain<T>
impl<T: CheckAtom + InherentNull> AtomDomain<T>
pub fn new_nullable() -> Self
source§impl<T: CheckAtom + TotalOrd> AtomDomain<T>
impl<T: CheckAtom + TotalOrd> AtomDomain<T>
pub fn new_closed(bounds: (T, T)) -> Fallible<Self>
Trait Implementations§
source§impl<T: Clone + CheckAtom> Clone for AtomDomain<T>
impl<T: Clone + CheckAtom> Clone for AtomDomain<T>
source§fn clone(&self) -> AtomDomain<T>
fn clone(&self) -> AtomDomain<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: CheckAtom> Debug for AtomDomain<T>
impl<T: CheckAtom> Debug for AtomDomain<T>
source§impl<T: CheckAtom> Default for AtomDomain<T>
impl<T: CheckAtom> Default for AtomDomain<T>
source§impl<T: CheckAtom> Domain for AtomDomain<T>
impl<T: CheckAtom> Domain for AtomDomain<T>
source§impl<T: CheckAtom + InherentNull + Clone> DropNullDomain for AtomDomain<T>
impl<T: CheckAtom + InherentNull + Clone> DropNullDomain for AtomDomain<T>
how to standardize into an option, when null represented as T with internal nullity
source§impl<T: CheckAtom + InherentNull> ImputeConstantDomain for AtomDomain<T>
impl<T: CheckAtom + InherentNull> ImputeConstantDomain for AtomDomain<T>
source§impl<T> LipschitzMulFloatDomain for AtomDomain<T>where
T: 'static + Float,
impl<T> LipschitzMulFloatDomain for AtomDomain<T>where T: 'static + Float,
source§impl<T: PartialEq + CheckAtom> PartialEq<AtomDomain<T>> for AtomDomain<T>
impl<T: PartialEq + CheckAtom> PartialEq<AtomDomain<T>> for AtomDomain<T>
source§fn eq(&self, other: &AtomDomain<T>) -> bool
fn eq(&self, other: &AtomDomain<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<T: CheckAtom> StructuralPartialEq for AtomDomain<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for AtomDomain<T>where T: RefUnwindSafe,
impl<T> Send for AtomDomain<T>where T: Send,
impl<T> Sync for AtomDomain<T>where T: Sync,
impl<T> Unpin for AtomDomain<T>where T: Unpin,
impl<T> UnwindSafe for AtomDomain<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.