Domain

Struct Domain 

Source
pub struct Domain(pub Range<f64>);
Expand description

Domain or codomain of a graph.

Domain is needed for implementing DrawView for a new type of plot.

Tuple Fields§

§0: Range<f64>

Implementations§

Source§

impl Domain

Source

pub fn min(&self) -> f64

The smallest value of the domain.

§Examples
use termplot::Domain;

let domain = Domain(-10.0..10.0);
assert_eq!(domain.min(), -10.0);
Source

pub fn max(&self) -> f64

The largest value of the domain.

§Examples
use termplot::Domain;

let domain = Domain(-10.0..10.0);
assert_eq!(domain.max(), 10.0);
Source

pub fn range(&self) -> f64

The range of the domain as an absolute value.

§Examples
use termplot::Domain;

let domain = Domain(-10.0..10.0);
assert_eq!(domain.range(), 20.0);

let domain = Domain(8.0..-8.0);
assert_eq!(domain.range(), 16.0);
Source

pub fn iter(&self, steps: usize) -> DomainIterator

An iterator over the range where a number of steps.

For example, use this if it’s needed to compute the value of each pixel for a plot.

§Examples
use termplot::{Domain};

let domain = Domain(-10.0..10.0);
let view_width = 100;

domain
    .iter(view_width)
    .for_each(|x| {
        // draw into the canvas
    });

See how plot::Graph is implemented for an in depth example.

Trait Implementations§

Source§

impl Default for Domain

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Domain

§

impl RefUnwindSafe for Domain

§

impl Send for Domain

§

impl Sync for Domain

§

impl Unpin for Domain

§

impl UnwindSafe for Domain

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.