pub struct TimeSpan { /* private fields */ }
Expand description
An interval of times.
Implementations§
Source§impl TimeSpan
impl TimeSpan
Sourcepub fn new(start: Time, end: Time) -> TimeSpan
pub fn new(start: Time, end: Time) -> TimeSpan
Creates a new TimeSpan
representing the closed interval [start, end]
.
§Panics
Panics if start > end
.
Sourcepub fn interpolate_to(&self, time: Time, other: TimeSpan) -> Time
pub fn interpolate_to(&self, time: Time, other: TimeSpan) -> Time
Interpolates from a time in this timespan to a time in other
.
§Panics
Panics if time
doesn’t belong to this TimeSpan
.
§Example
use scribl_curves::{Time, TimeSpan};
let me = TimeSpan::new(Time::from_micros(0), Time::from_micros(100));
let other = TimeSpan::new(Time::from_micros(0), Time::from_micros(10));
assert_eq!(me.interpolate_to(Time::from_micros(50), other), Time::from_micros(5));
assert_eq!(me.interpolate_to(Time::from_micros(59), other), Time::from_micros(5));
assert_eq!(me.interpolate_to(Time::from_micros(78), other), Time::from_micros(7));
Trait Implementations§
Source§impl<'de> Deserialize<'de> for TimeSpan
impl<'de> Deserialize<'de> for TimeSpan
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 Ord for TimeSpan
impl Ord for TimeSpan
Source§impl PartialOrd for TimeSpan
impl PartialOrd for TimeSpan
impl Copy for TimeSpan
impl Eq for TimeSpan
impl StructuralPartialEq for TimeSpan
Auto Trait Implementations§
impl Freeze for TimeSpan
impl RefUnwindSafe for TimeSpan
impl Send for TimeSpan
impl Sync for TimeSpan
impl Unpin for TimeSpan
impl UnwindSafe for TimeSpan
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