Remove ByteStr

Users can now build a `Literal::byte_string(bytes)` and interpolate that.
This commit is contained in:
David Tolnay 2018-01-06 09:48:24 -08:00
parent 9ae2877249
commit 4189356a5d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
3 changed files with 1 additions and 28 deletions

View File

@ -80,7 +80,7 @@ mod tokens;
pub use tokens::Tokens;
mod to_tokens;
pub use to_tokens::{ByteStr, ToTokens};
pub use to_tokens::ToTokens;
// Not public API.
#[doc(hidden)]

View File

@ -149,14 +149,3 @@ impl ToTokens for bool {
tokens.append(tt(TokenNode::Term(Term::intern(word))));
}
}
/// Wrap a `&str` so it interpolates as a byte-string: `b"abc"`.
#[derive(Debug)]
pub struct ByteStr<'a>(pub &'a str);
impl<'a> ToTokens for ByteStr<'a> {
fn to_tokens(&self, tokens: &mut Tokens) {
let lit = Literal::byte_string(self.0.as_bytes());
tokens.append(tt(TokenNode::Literal(lit)));
}
}

View File

@ -183,22 +183,6 @@ fn test_string() {
assert_eq!(expected, tokens.to_string());
}
#[test]
fn test_byte_str() {
let s = quote::ByteStr("\0 a 'b \" c");
let tokens = quote!(#s);
let expected = "b\"\\0 a \'b \\\" c\"";
assert_eq!(expected, tokens.to_string());
}
#[test]
fn test_byte_str_escape() {
let s = quote::ByteStr("\u{3c3} \\ \" \n");
let tokens = quote!(#s);
let expected = "b\"\\xCF\\x83 \\\\ \\\" \\n\"";
assert_eq!(expected, tokens.to_string());
}
#[test]
fn test_ident() {
let foo = Term::intern("Foo");