Add is_true

This commit is contained in:
Jonas Platte 2020-05-01 23:33:01 +02:00
parent 2fb17f30be
commit 25f302f491
No known key found for this signature in database
GPG Key ID: 7D261D771D915378
2 changed files with 8 additions and 1 deletions

View File

@ -8,7 +8,7 @@ authors = [
"Isaiah Inuwa <isaiah.inuwa@gmail.com>", "Isaiah Inuwa <isaiah.inuwa@gmail.com>",
"Anthony Ramine <n.oxyde@gmail.com>", "Anthony Ramine <n.oxyde@gmail.com>",
] ]
version = "0.1.2" version = "0.1.3"
repository = "https://github.com/ruma/ruma-serde" repository = "https://github.com/ruma/ruma-serde"
edition = "2018" edition = "2018"

View File

@ -23,6 +23,13 @@ pub fn default_true() -> bool {
true true
} }
/// Simplfy dereferences the given bool.
///
/// Useful for `#[serde(skip_serializing_if = ...)]`
pub fn is_true(b: &bool) -> bool {
*b
}
/// Serde deserialization decorator to map empty Strings to None, /// Serde deserialization decorator to map empty Strings to None,
/// and forward non-empty Strings to the Deserialize implementation for T. /// and forward non-empty Strings to the Deserialize implementation for T.
/// Useful for the typical /// Useful for the typical