pub trait TanH: Sized {
type Error: Error;
// Required methods
fn try_tanh(self) -> Result<Self, <Self as TanH>::Error>;
fn tanh(self) -> Self;
}
Expand description
Trait for computing the hyperbolic tangent of a number.
This trait defines methods for computing the hyperbolic tangent of a number. It includes both a safe method that returns a Result
and an unsafe method that directly returns the computed value.
§Associated Types
Error
: The error type that is returned by thetry_tanh
method. This type must implement thestd::error::Error
trait.
§Required Methods
-
try_tanh
: Computes the hyperbolic tangent ofself
and returns aResult
. If the computation is successful, it returnsOk
with the computed value. If an error occurs, it returnsErr
with the associated error. -
tanh
: Computes the hyperbolic tangent of the number and directly returns the computed value. In Debug mode this method may panic if the computation fails.
Required Associated Types§
Required Methods§
Sourcefn try_tanh(self) -> Result<Self, <Self as TanH>::Error>
fn try_tanh(self) -> Result<Self, <Self as TanH>::Error>
Computes the hyperbolic tangent of self
and returns a Result
.
If the computation is successful, it returns Ok
with the computed value. If an error occurs, it returns Err
with the associated error.
§Errors
This method returns an error if the computation fails. The error type is defined by the associated Error
type.
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.