Trait TryOp

Source
pub trait TryOp: Sized {
    // Required methods
    fn try_op<F: FnOnce(f32, f32) -> f32>(
        &self,
        rhs: &Self,
        op: F,
    ) -> Option<Self>;
    fn try_op_to<T, F: FnOnce(f32, f32) -> T>(
        &self,
        rhs: &Self,
        op: F,
    ) -> Option<T>;
}
Expand description

A trait for values that potentially support a binary operation (e.g. if they have the same unit).

Required Methods§

Source

fn try_op<F: FnOnce(f32, f32) -> f32>(&self, rhs: &Self, op: F) -> Option<Self>

Returns the result of the operation in the same type, if possible.

Source

fn try_op_to<T, F: FnOnce(f32, f32) -> T>(&self, rhs: &Self, op: F) -> Option<T>

Returns the result of the operation in a different type, if possible.

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.

Implementors§