-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates IonData to work with Deref impls and improves docs
- Loading branch information
Showing
9 changed files
with
240 additions
and
73 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
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
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
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,45 @@ | ||
use crate::ion_data::{IonEq, IonOrd}; | ||
use std::cmp::Ordering; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
/// Represents an Ion `bool` value, for the purpose of implementing some Ion-related traits. | ||
/// | ||
/// Most of the time, you can use [bool] instead of this type. | ||
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq)] | ||
pub struct Bool(bool); | ||
|
||
impl Display for Bool { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
<bool as Display>::fmt(&self.0, f) | ||
} | ||
} | ||
|
||
impl From<bool> for Bool { | ||
fn from(value: bool) -> Self { | ||
Bool(value) | ||
} | ||
} | ||
|
||
impl From<Bool> for bool { | ||
fn from(value: Bool) -> Self { | ||
value.0 | ||
} | ||
} | ||
|
||
impl PartialEq<bool> for Bool { | ||
fn eq(&self, other: &bool) -> bool { | ||
self.0 == *other | ||
} | ||
} | ||
|
||
impl IonEq for Bool { | ||
fn ion_eq(&self, other: &Self) -> bool { | ||
self.0 == other.0 | ||
} | ||
} | ||
|
||
impl IonOrd for Bool { | ||
fn ion_cmp(&self, other: &Self) -> Ordering { | ||
self.0.cmp(&other.0) | ||
} | ||
} |
Oops, something went wrong.