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.

§

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.

§

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.

§

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.

§

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.

§

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.

§

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.

§

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.

§

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.

§

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.

§

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.

§

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.

§

type Output = usize

Implementors§