Change functions from taking ~str to taking &str

This commit is contained in:
Erick Tryzelaar 2013-02-11 08:28:41 -08:00
parent 9da641bd8c
commit e6d84268fa
2 changed files with 9 additions and 9 deletions

View File

@ -487,12 +487,12 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
fn crate_meta_extras_hash(symbol_hasher: &hash::State,
-cmh_items: ~[@ast::meta_item],
dep_hashes: ~[~str]) -> @str {
fn len_and_str(s: ~str) -> ~str {
return fmt!("%u_%s", str::len(s), s);
fn len_and_str(s: &str) -> ~str {
fmt!("%u_%s", s.len(), s)
}
fn len_and_str_lit(l: ast::lit) -> ~str {
return len_and_str(pprust::lit_to_str(@l));
len_and_str(pprust::lit_to_str(@l))
}
let cmh_items = attr::sort_meta_items(cmh_items);
@ -615,7 +615,7 @@ pub fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {
// Name sanitation. LLVM will happily accept identifiers with weird names, but
// gas doesn't!
pub fn sanitize(s: ~str) -> ~str {
pub fn sanitize(s: &str) -> ~str {
let mut result = ~"";
for str::chars_each(s) |c| {
match c {
@ -629,10 +629,10 @@ pub fn sanitize(s: ~str) -> ~str {
'a' .. 'z'
| 'A' .. 'Z'
| '0' .. '9'
| '_' => str::push_char(&mut result, c),
| '_' => result.push_char(c),
_ => {
if c > 'z' && char::is_XID_continue(c) {
str::push_char(&mut result, c);
result.push_char(c);
}
}
}

View File

@ -46,14 +46,14 @@ impl cmp::Eq for cmnt_style {
pub type cmnt = {style: cmnt_style, lines: ~[~str], pos: BytePos};
pub fn is_doc_comment(s: ~str) -> bool {
pub fn is_doc_comment(s: &str) -> bool {
(s.starts_with(~"///") && !is_line_non_doc_comment(s)) ||
s.starts_with(~"//!") ||
(s.starts_with(~"/**") && !is_block_non_doc_comment(s)) ||
s.starts_with(~"/*!")
}
pub fn doc_comment_style(comment: ~str) -> ast::attr_style {
pub fn doc_comment_style(comment: &str) -> ast::attr_style {
assert is_doc_comment(comment);
if comment.starts_with(~"//!") || comment.starts_with(~"/*!") {
ast::attr_inner
@ -62,7 +62,7 @@ pub fn doc_comment_style(comment: ~str) -> ast::attr_style {
}
}
pub fn strip_doc_comment_decoration(comment: ~str) -> ~str {
pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
/// remove whitespace-only lines from the start/end of lines
fn vertical_trim(lines: ~[~str]) -> ~[~str] {