Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Add some null and boolean representations
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Sep 14, 2022
1 parent a7b9862 commit 35037c5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions src/de.rs
Expand Up @@ -923,20 +923,17 @@ fn parse_borrowed_str<'de>(
}

fn parse_null(scalar: &[u8]) -> Option<()> {
if scalar == b"~" || scalar == b"null" {
Some(())
} else {
None
match scalar {
b"null" | b"Null" | b"NULL" | b"~" => Some(()),
_ => None,
}
}

fn parse_bool(scalar: &str) -> Option<bool> {
if scalar == "true" {
Some(true)
} else if scalar == "false" {
Some(false)
} else {
None
match scalar {
"true" | "True" | "TRUE" => Some(true),
"false" | "False" | "FALSE" => Some(false),
_ => None,
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_value.rs
Expand Up @@ -97,7 +97,7 @@ fn test_merge() {
#[test]
fn test_debug() {
let yaml = indoc! {"
Null: ~
'Null': ~
Bool: true
Number: 1
String: ...
Expand Down

0 comments on commit 35037c5

Please sign in to comment.