Skip to content

Commit

Permalink
Improve macro-internal compile-time (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 committed May 14, 2022
1 parent 222f8ec commit 6ae70f9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/macro/internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ proc-macro = true

[dependencies]
data-encoding = { version = "2.3", path = "../..", default-features = false, features = ["alloc"] }
syn = "1"
syn = { version = "1", default-features = false, features = ["parsing", "proc-macro"] }
2 changes: 1 addition & 1 deletion lib/macro/internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn get_bool(map: &mut HashMap<String, TokenTree>, key: &str) -> Option<bool> {
};
match syn::parse::<syn::LitBool>(node.into()) {
Ok(result) => Some(result.value),
_ => panic!("expected bool for padding"),
_ => panic!("expected bool for {}", key),
}
}

Expand Down
8 changes: 8 additions & 0 deletions lib/macro/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,11 @@ fn base64_decode() {
const OUTPUT: &'static [u8] = &data_encoding_macro::base64!("deadbeef");
assert_eq!(OUTPUT, data_encoding::BASE64.decode(b"deadbeef").unwrap());
}

#[test]
fn escaped_symbols() {
const BASE: data_encoding::Encoding = data_encoding_macro::new_encoding! {
symbols: "\x00\n\"\\",
};
assert_eq!(BASE.encode(b"K"), "\n\x00\"\\");
}

0 comments on commit 6ae70f9

Please sign in to comment.