Trait OverflowingSquare

Source
pub trait OverflowingSquare {
    type Output;

    // Required method
    fn overflowing_square(self) -> (Self::Output, bool);
}
Expand description

Squares a number.

Returns a tuple of the sum along with a boolean indicating whether an arithmetic overflow occurred. If an overflow occurred, then the wrapped number is returned.

Required Associated Types§

Required Methods§

Source

fn overflowing_square(self) -> (Self::Output, bool)

Implementations on Foreign Types§

Source§

impl OverflowingSquare for i8

Source§

fn overflowing_square(self) -> (i8, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i8

Source§

impl OverflowingSquare for i16

Source§

fn overflowing_square(self) -> (i16, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i16

Source§

impl OverflowingSquare for i32

Source§

fn overflowing_square(self) -> (i32, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i32

Source§

impl OverflowingSquare for i64

Source§

fn overflowing_square(self) -> (i64, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i64

Source§

impl OverflowingSquare for i128

Source§

fn overflowing_square(self) -> (i128, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = i128

Source§

impl OverflowingSquare for isize

Source§

fn overflowing_square(self) -> (isize, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = isize

Source§

impl OverflowingSquare for u8

Source§

fn overflowing_square(self) -> (u8, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u8

Source§

impl OverflowingSquare for u16

Source§

fn overflowing_square(self) -> (u16, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u16

Source§

impl OverflowingSquare for u32

Source§

fn overflowing_square(self) -> (u32, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u32

Source§

impl OverflowingSquare for u64

Source§

fn overflowing_square(self) -> (u64, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u64

Source§

impl OverflowingSquare for u128

Source§

fn overflowing_square(self) -> (u128, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = u128

Source§

impl OverflowingSquare for usize

Source§

fn overflowing_square(self) -> (usize, bool)

Squares a number.

Returns a tuple containing the result and a boolean indicating whether an arithmetic occurred. If an overflow occurred, then the wrapped value is returned.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

type Output = usize

Implementors§