Half

Trait Half 

Source
pub trait Half {
    // Required method
    fn half(&self) -> Self;
}
Expand description

Provides a trait for types that can calculate half of their value.

The Half trait is used for types that can be evenly divided, returning a new instance of the same type representing half of the original value. This is commonly used for types that represent measurements or sizes, such as lengths or pixels, where halving is a frequent operation during layout calculations or animations.

Required Methods§

Source

fn half(&self) -> Self

Returns half of the current value.

§Returns

A new instance of the implementing type, representing half of the original value.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Half for f32

Source§

fn half(&self) -> Self

Source§

impl Half for i32

Source§

fn half(&self) -> Self

Implementors§