pub struct Period { /* private fields */ }Expand description
A time span expressed as an integer length of a given TimeUnit.
The length may be negative to express a span into the past. Equality and
ordering are semantic (12 Months == 1 Year), not structural; see the
module docs for the partial-order behaviour.
Implementations§
Source§impl Period
impl Period
Sourcepub fn normalize(&mut self)
pub fn normalize(&mut self)
Rewrites the period into a canonical unit where possible: a zero length
becomes Days, a whole number of months collapses to years, and a whole
number of days collapses to weeks. Weeks and years are already canonical.
§Panics
Panics if the period uses a sub-day unit, which has no place in the
calendar algebra (matching QuantLib’s QL_FAIL).
Sourcepub fn normalized(&self) -> Period
pub fn normalized(&self) -> Period
Returns a normalized copy, leaving self untouched.
Sourcepub fn frequency(&self) -> Frequency
pub fn frequency(&self) -> Frequency
The Frequency this period corresponds to, or
OtherFrequency when it maps to none of the
named ones (e.g. 5 Years). A zero length is Once
for years and NoFrequency otherwise.
§Panics
Panics if the period uses a sub-day unit (matching QuantLib’s QL_FAIL).
Trait Implementations§
Source§impl AddAssign for Period
impl AddAssign for Period
Source§fn add_assign(&mut self, p: Period)
fn add_assign(&mut self, p: Period)
Adds p in place, converting units where the algebra allows.
§Panics
Panics on an impossible addition, e.g. a non-zero Days period added to
a Years one (matching QuantLib’s QL_REQUIRE).
impl Copy for Period
Source§impl DivAssign<i32> for Period
impl DivAssign<i32> for Period
Source§fn div_assign(&mut self, n: Integer)
fn div_assign(&mut self, n: Integer)
Divides in place, keeping the original unit when it divides evenly and otherwise falling back to the finer unit (years -> months, weeks -> days).
§Panics
Panics if n is zero, or if the period is not divisible by n even
after refining the unit (matching QuantLib’s QL_REQUIRE).
Source§impl MulAssign<i32> for Period
impl MulAssign<i32> for Period
Source§fn mul_assign(&mut self, n: Integer)
fn mul_assign(&mut self, n: Integer)
*= operation. Read moreSource§impl PartialOrd for Period
impl PartialOrd for Period
Source§fn partial_cmp(&self, other: &Period) -> Option<Ordering>
fn partial_cmp(&self, other: &Period) -> Option<Ordering>
Returns None when the comparison is undecidable (see module docs).
Source§impl SubAssign for Period
impl SubAssign for Period
Source§fn sub_assign(&mut self, p: Period)
fn sub_assign(&mut self, p: Period)
-= operation. Read more