Struct OffsetArithmetic

pub struct OffsetArithmetic { /* private fields */ }

Options for Offset::checked_add and Offset::checked_sub.

This type provides a way to ergonomically add one of a few different duration types to a Offset.

The main way to construct values of this type is with its From trait implementations:

Example

use std::time::Duration;

use jiff::{tz::offset, SignedDuration, ToSpan};

let off = offset(-10);
assert_eq!(off.checked_add(11.hours())?, offset(1));
assert_eq!(off.checked_add(SignedDuration::from_hours(11))?, offset(1));
assert_eq!(off.checked_add(Duration::from_secs(11 * 60 * 60))?, offset(1));

# Ok::<(), Box<dyn std::error::Error>>(())

Trait Implementations

impl Clone for OffsetArithmetic

fn clone(&self) -> OffsetArithmetic

impl Copy for OffsetArithmetic

impl Debug for OffsetArithmetic

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

impl From<Duration> for OffsetArithmetic

fn from(udur: UnsignedDuration) -> OffsetArithmetic

impl From<SignedDuration> for OffsetArithmetic

fn from(sdur: SignedDuration) -> OffsetArithmetic

impl From<Span> for OffsetArithmetic

fn from(span: Span) -> OffsetArithmetic

impl<'a> From<&'a Duration> for OffsetArithmetic

fn from(udur: &'a UnsignedDuration) -> OffsetArithmetic

impl<'a> From<&'a SignedDuration> for OffsetArithmetic

fn from(sdur: &'a SignedDuration) -> OffsetArithmetic

impl<'a> From<&'a Span> for OffsetArithmetic

fn from(span: &'a Span) -> OffsetArithmetic

Auto Trait Implementations

impl Freeze for OffsetArithmetic

impl RefUnwindSafe for OffsetArithmetic

impl Send for OffsetArithmetic

impl Sync for OffsetArithmetic

impl Unpin for OffsetArithmetic

impl UnsafeUnpin for OffsetArithmetic

impl UnwindSafe for OffsetArithmetic

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for OffsetArithmetic where T: ?Sized,

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

impl<T> CloneToUninit for OffsetArithmetic where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for OffsetArithmetic

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for OffsetArithmetic where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for OffsetArithmetic where U: From<T>,

fn into(self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom<U> for OffsetArithmetic where U: Into<T>,

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

impl<T, U> TryInto<U> for OffsetArithmetic where U: TryFrom<T>,

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