pub enum VariationValue {
Float(OrderedFloat<f64>),
Int(i64),
}Expand description
The value for a single parameter variation.
Floating-point values use ordered_float::OrderedFloat to support hashing
and equality, which are required for deduplication via std::collections::HashSet.
§Examples
use zeph_experiments::VariationValue;
let f = VariationValue::from(0.7_f64);
let i = VariationValue::from(40_i64);
assert!((f.as_f64() - 0.7).abs() < f64::EPSILON);
assert_eq!(i.as_f64(), 40.0);
assert_eq!(i.to_string(), "40");Variants§
Float(OrderedFloat<f64>)
A floating-point parameter value.
Int(i64)
An integer parameter value (used for TopK, RetrievalTopK).
Implementations§
Source§impl VariationValue
impl VariationValue
Sourcepub fn as_f64(&self) -> f64
pub fn as_f64(&self) -> f64
Return the value as f64.
Int variants are cast to f64 via as f64 (possible precision loss for
very large integers, but parameter values are always small).
§Examples
use zeph_experiments::VariationValue;
assert!((VariationValue::from(0.5_f64).as_f64() - 0.5).abs() < f64::EPSILON);
assert_eq!(VariationValue::from(10_i64).as_f64(), 10.0);Trait Implementations§
Source§impl Clone for VariationValue
impl Clone for VariationValue
Source§fn clone(&self) -> VariationValue
fn clone(&self) -> VariationValue
Returns a duplicate 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 Debug for VariationValue
impl Debug for VariationValue
Source§impl<'de> Deserialize<'de> for VariationValue
impl<'de> Deserialize<'de> for VariationValue
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for VariationValue
impl Display for VariationValue
Source§impl From<f64> for VariationValue
impl From<f64> for VariationValue
Source§impl From<i64> for VariationValue
impl From<i64> for VariationValue
Source§impl Hash for VariationValue
impl Hash for VariationValue
Source§impl PartialEq for VariationValue
impl PartialEq for VariationValue
Source§impl Serialize for VariationValue
impl Serialize for VariationValue
impl Eq for VariationValue
impl StructuralPartialEq for VariationValue
Auto Trait Implementations§
impl Freeze for VariationValue
impl RefUnwindSafe for VariationValue
impl Send for VariationValue
impl Sync for VariationValue
impl Unpin for VariationValue
impl UnsafeUnpin for VariationValue
impl UnwindSafe for VariationValue
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.