use std::io;
use std::str;
use std::string::String;
-use std::uint;
+use std::usize;
#[derive(Clone, Copy, PartialEq)]
pub enum CommentStyle {
pub fn strip_doc_comment_decoration(comment: &str) -> String {
/// remove whitespace-only lines from the start/end of lines
fn vertical_trim(lines: Vec<String> ) -> Vec<String> {
- let mut i = 0u;
+ let mut i = 0us;
let mut j = lines.len();
// first line of all-stars should be omitted
if lines.len() > 0 &&
/// remove a "[ \t]*\*" block from each line, if possible
fn horizontal_trim(lines: Vec<String> ) -> Vec<String> {
- let mut i = uint::MAX;
+ let mut i = usize::MAX;
let mut can_trim = true;
let mut first = true;
for line in lines.iter() {
if can_trim {
lines.iter().map(|line| {
- line[i + 1..line.len()].to_string()
+ (&line[i + 1..line.len()]).to_string()
}).collect()
} else {
lines
static ONLINERS: &'static [&'static str] = &["///!", "///", "//!", "//"];
for prefix in ONLINERS.iter() {
if comment.starts_with(*prefix) {
- return comment[prefix.len()..].to_string();
+ return (&comment[prefix.len()..]).to_string();
}
}
if comment.starts_with("/*") {
- let lines = comment[3u..comment.len() - 2u]
+ let lines = comment[3..comment.len() - 2]
.lines_any()
.map(|s| s.to_string())
.collect::<Vec<String> >();
fn consume_whitespace_counting_blank_lines(rdr: &mut StringReader,
comments: &mut Vec<Comment>) {
while is_whitespace(rdr.curr) && !rdr.is_eof() {
- if rdr.col == CharPos(0u) && rdr.curr_is('\n') {
+ if rdr.col == CharPos(0us) && rdr.curr_is('\n') {
push_blank_line_comment(rdr, &mut *comments);
}
rdr.bump();
let line = rdr.read_one_line_comment();
debug!("{}", line);
// Doc comments are not put in comments.
- if is_doc_comment(line[]) {
+ if is_doc_comment(&line[]) {
break;
}
lines.push(line);
/// Returns None if the first col chars of s contain a non-whitespace char.
/// Otherwise returns Some(k) where k is first char offset after that leading
/// whitespace. Note k may be outside bounds of s.
-fn all_whitespace(s: &str, col: CharPos) -> Option<uint> {
+fn all_whitespace(s: &str, col: CharPos) -> Option<usize> {
let len = s.len();
- let mut col = col.to_uint();
- let mut cursor: uint = 0;
+ let mut col = col.to_usize();
+ let mut cursor: usize = 0;
while col > 0 && cursor < len {
let r: str::CharRange = s.char_range_at(cursor);
if !r.ch.is_whitespace() {
fn trim_whitespace_prefix_and_push_line(lines: &mut Vec<String> ,
s: String, col: CharPos) {
let len = s.len();
- let s1 = match all_whitespace(s[], col) {
+ let s1 = match all_whitespace(&s[], col) {
Some(col) => {
if col < len {
- s[col..len].to_string()
+ (&s[col..len]).to_string()
} else {
"".to_string()
}
rdr.bump();
rdr.bump();
}
- if is_block_doc_comment(curr_line[]) {
+ if is_block_doc_comment(&curr_line[]) {
return
}
assert!(!curr_line.contains_char('\n'));
lines.push(curr_line);
} else {
- let mut level: int = 1;
+ let mut level: isize = 1;
while level > 0 {
debug!("=== block comment level {}", level);
if rdr.is_eof() {
let mut style = if code_to_the_left { Trailing } else { Isolated };
rdr.consume_non_eol_whitespace();
- if !rdr.is_eof() && !rdr.curr_is('\n') && lines.len() == 1u {
+ if !rdr.is_eof() && !rdr.curr_is('\n') && lines.len() == 1us {
style = Mixed;
}
debug!("<<< block comment");
}
#[test] fn test_block_doc_comment_3() {
- let comment = "/**\n let a: *int;\n *a = 5;\n*/";
+ let comment = "/**\n let a: *i32;\n *a = 5;\n*/";
let stripped = strip_doc_comment_decoration(comment);
- assert_eq!(stripped, " let a: *int;\n *a = 5;");
+ assert_eq!(stripped, " let a: *i32;\n *a = 5;");
}
#[test] fn test_block_doc_comment_4() {