libsyntax: De-@str
get_single_str_from_tts
This commit is contained in:
parent
f9af11d6cc
commit
cbf9f5f5df
1 changed files with 4 additions and 2 deletions
|
@ -439,13 +439,15 @@ pub fn get_single_str_from_tts(cx: &ExtCtxt,
|
||||||
sp: Span,
|
sp: Span,
|
||||||
tts: &[ast::TokenTree],
|
tts: &[ast::TokenTree],
|
||||||
name: &str)
|
name: &str)
|
||||||
-> Option<@str> {
|
-> Option<~str> {
|
||||||
if tts.len() != 1 {
|
if tts.len() != 1 {
|
||||||
cx.span_err(sp, format!("{} takes 1 argument.", name));
|
cx.span_err(sp, format!("{} takes 1 argument.", name));
|
||||||
} else {
|
} else {
|
||||||
match tts[0] {
|
match tts[0] {
|
||||||
ast::TTTok(_, token::LIT_STR(ident))
|
ast::TTTok(_, token::LIT_STR(ident))
|
||||||
| ast::TTTok(_, token::LIT_STR_RAW(ident, _)) => return Some(cx.str_of(ident)),
|
| ast::TTTok(_, token::LIT_STR_RAW(ident, _)) => {
|
||||||
|
return Some(cx.str_of(ident).to_str())
|
||||||
|
}
|
||||||
_ => cx.span_err(sp, format!("{} requires a string.", name)),
|
_ => cx.span_err(sp, format!("{} requires a string.", name)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue