Skip to main content

Half

Trait Half 

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

Returns half of a value, for centering and midpoints.

Geometry code uses this trait to find midpoints and centers for each unit. For integers, the result truncates toward zero, so half of 7 is 3.

§Examples

use gpui::{Half, px};

assert_eq!(7_i32.half(), 3);
assert_eq!(px(7.).half(), px(3.5));

Required Methods§

Source

fn half(&self) -> Self

Returns half of this value.

Dyn Compatibility§

This trait is not dyn compatible.

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

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§