Log10

Trait Log10 

Source
pub trait Log10: Sized {
    type Error: Error;

    // Required methods
    fn try_log10(self) -> Result<Self, Self::Error>;
    fn log10(self) -> Self;
}
Expand description

Trait for computing the base-10 logarithm 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 the try_log10 method. This type must implement the std::error::Error trait.

§Required Methods

  • try_log10: Computes the base-10 logarithm 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.
  • log10: Computes the base-10 logarithm of self and directly returns the computed value. This method may panic (in Debug mode) if the computation fails.

Required Associated Types§

Source

type Error: Error

The error type that is returned by the try_log10 method.

Required Methods§

Source

fn try_log10(self) -> Result<Self, Self::Error>

Computes the base-10 logarithm 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 Log10::Error type.

Source

fn log10(self) -> Self

Computes the base-10 logarithm of self and directly returns the computed value.

This method may panic (in Debug mode) if the computation fails.

§Panics

This method may panic (in Debug mode) if the computation fails. It is recommended to use the try_log10 method for safe computations.

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 Log10 for f64

Source§

impl Log10 for Complex<f64>

Implementors§