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: The lb property represents the lower bound of the interval. It is of type T, which is a generic type that must implement the PartialOrd trait. This means that the type T must be able to be compared for ordering.
  • ub: The ub property represents the upper bound of the interval. It is of type T, which is a generic type that must implement the PartialOrd trait. The PartialOrd trait allows for comparison between values of type T.
  • _marker: The _marker field is a marker field that is used to indicate that the generic type T is 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>

source

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: The lb parameter represents the lower bound value. It is of type T, which means it can be any type that implements the necessary traits for the struct.
  • ub: The ub parameter represents the upper bound value. It is of type T, 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: Debug + PartialOrd> Debug for Interval<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: PartialOrd> PartialEq<Interval<T>> for Interval<T>

source§

fn eq(&self, other: &Self) -> bool

The function checks if two objects have equal values for their “lb” and “ub” fields.

Arguments:

  • other: The other parameter is a reference to another object of the same type as Self. In this case, Self refers to the type of the object implementing the eq method.

Returns:

A boolean value is being returned.

Examples
use physdes::interval_ai::Interval;
assert_eq!(Interval::new(1, 2), Interval::new(1, 2));
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T: PartialOrd> PartialOrd<Interval<T>> for Interval<T>

source§

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: The other parameter is a reference to another object of the same type as self.

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 lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto 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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.