Skip to main content

WithOffset

Trait WithOffset 

Source
pub trait WithOffset<O> {
    type Output;

    // Required method
    fn with_offset(&self, offset: O) -> Self::Output;
}
Expand description

Functionality to add an offset to a value and convert it.

§Examples

use offset_views::with_offset::WithOffset;
assert_eq!(3.with_offset(5), 8);
assert_eq!((3..8).with_offset(-3), 0..5);

Required Associated Types§

Required Methods§

Source

fn with_offset(&self, offset: O) -> Self::Output

Adds an offset to a value and tries to convert the result to a suitable output type.

This method may panic if it is not possible to represent the result in the output type.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl WithOffset<isize> for isize

Source§

type Output = usize

Source§

fn with_offset(&self, offset: isize) -> usize

Source§

impl WithOffset<isize> for RangeFull

Source§

impl<I> WithOffset<isize> for Range<I>
where I: WithOffset<isize, Output = usize>,

Source§

impl<I> WithOffset<isize> for RangeFrom<I>
where I: WithOffset<isize, Output = usize>,

Source§

impl<I> WithOffset<isize> for RangeInclusive<I>
where I: WithOffset<isize, Output = usize>,

Source§

impl<I> WithOffset<isize> for RangeTo<I>
where I: WithOffset<isize, Output = usize>,

Source§

impl<I> WithOffset<isize> for RangeToInclusive<I>
where I: WithOffset<isize, Output = usize>,

Implementors§