-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
2,126 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use core::str::FromStr; | ||
|
||
use super::{AdjustedBit, Bit, Unit, UnitType}; | ||
use crate::ParseError; | ||
|
||
impl From<Bit> for AdjustedBit { | ||
/// `multiple_option` is set to `UnitType::Both`. See [`Bit::get_appropriate_unit`](./struct.Bit.html#method.get_appropriate_unit). | ||
#[inline] | ||
fn from(value: Bit) -> Self { | ||
value.get_appropriate_unit(UnitType::Both) | ||
} | ||
} | ||
|
||
impl From<AdjustedBit> for f64 { | ||
#[inline] | ||
fn from(value: AdjustedBit) -> Self { | ||
value.get_value() | ||
} | ||
} | ||
|
||
impl From<AdjustedBit> for Unit { | ||
#[inline] | ||
fn from(value: AdjustedBit) -> Self { | ||
value.get_unit() | ||
} | ||
} | ||
|
||
impl From<AdjustedBit> for Bit { | ||
#[inline] | ||
fn from(value: AdjustedBit) -> Self { | ||
value.get_bit() | ||
} | ||
} | ||
|
||
impl FromStr for AdjustedBit { | ||
type Err = ParseError; | ||
|
||
/// * `multiple_option` is set to `UnitType::Both`. See [`Bit::get_appropriate_unit`](./struct.Bit.html#method.get_appropriate_unit). | ||
#[inline] | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
Ok(Bit::parse_str(s)?.get_appropriate_unit(UnitType::Both)) | ||
} | ||
} |
Oops, something went wrong.