Struct physdes::interval_ai::Interval
source · pub struct Interval<T: PartialOrd> {
pub lb: T,
pub ub: T,
pub _marker: PhantomData<T>,
}Expand description
The Interval struct represents a range of values with a lower bound (lb) and an upper bound
(ub).
Properties:
lb: Thelbproperty represents the lower bound of the interval. It is of typeT, which is a generic type that must implement thePartialOrdtrait. This means that the typeTmust be able to be compared for ordering.ub: Theubproperty represents the upper bound of the interval. It is of typeT, which is a generic type that must implement thePartialOrdtrait. ThePartialOrdtrait allows for comparison between values of typeT._marker: The_markerfield is a marker field that is used to indicate that the generic typeTis used in the struct. It is typically used when you want to associate a type parameter with a struct, but you don’t actually need to store any values of that type in the struct.
Fields§
§lb: T§ub: T§_marker: PhantomData<T>Implementations§
source§impl<T: PartialOrd> Interval<T>
impl<T: PartialOrd> Interval<T>
sourcepub fn new(lb: T, ub: T) -> Self
pub fn new(lb: T, ub: T) -> Self
The function new creates a new instance of a struct with given lower and upper bounds.
Arguments:
lb: Thelbparameter represents the lower bound value. It is of typeT, which means it can be any type that implements the necessary traits for the struct.ub: Theubparameter represents the upper bound value. It is of typeT, which means it can be any type that implements the necessary traits for the struct.
Returns:
The new function is returning an instance of the struct Self.
Examples
use physdes::interval_ai::Interval;
use std::marker::PhantomData;
assert_eq!(Interval::new(1, 2), Interval { lb: 1, ub: 2, _marker: PhantomData });
assert_eq!(Interval::new(2, 1), Interval { lb: 2, ub: 1, _marker: PhantomData });Trait Implementations§
source§impl<T: PartialOrd> PartialEq<Interval<T>> for Interval<T>
impl<T: PartialOrd> PartialEq<Interval<T>> for Interval<T>
source§fn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
The function checks if two objects have equal values for their “lb” and “ub” fields.
Arguments:
other: Theotherparameter is a reference to another object of the same type asSelf. In this case,Selfrefers to the type of the object implementing theeqmethod.
Returns:
A boolean value is being returned.
Examples
use physdes::interval_ai::Interval;
assert_eq!(Interval::new(1, 2), Interval::new(1, 2));source§impl<T: PartialOrd> PartialOrd<Interval<T>> for Interval<T>
impl<T: PartialOrd> PartialOrd<Interval<T>> for Interval<T>
source§fn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
The function partial_cmp compares the lower bound of self with the upper bound of other
and returns the result as an Option of Ordering.
Arguments:
other: Theotherparameter is a reference to another object of the same type asself.
Returns:
an Option containing a std::cmp::Ordering value.
Examples
use physdes::interval_ai::Interval;
use std::marker::PhantomData;
assert_eq!(Interval::new(1, 2).partial_cmp(&Interval::new(2, 3)), Some(std::cmp::Ordering::Less));1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moreAuto Trait Implementations§
impl<T> RefUnwindSafe for Interval<T>where T: RefUnwindSafe,
impl<T> Send for Interval<T>where T: Send,
impl<T> Sync for Interval<T>where T: Sync,
impl<T> Unpin for Interval<T>where T: Unpin,
impl<T> UnwindSafe for Interval<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