提交 a09dcd94 编写于 作者: M Marijn Haverbeke

Fix some indentation and idioms in rope.rs

Sorry for the pedantry. I was handling a compilation bug related to this code,
and it just jumped out at me.
上级 9ff6f816
......@@ -1196,31 +1196,23 @@ fn loop_leaves(node: @node, it: block(leaf) -> bool) -> bool{
proportional to the height of the rope + the (bounded)
length of the largest leaf.
*/
fn char_at(node: @node, pos: uint) -> char {
let node = node;
let pos = pos;
while true {
alt(*node) {
leaf(x) {
ret str::char_at(*x.content, pos);
}
concat({left: left,
right: right,
char_len: _,
byte_len: _,
height: _}) {
let left_len = char_len(left);
if left_len > pos {
node = left;
} else {
node = right;
pos = pos - left_len;
}
}
}
};
fail;//unreachable
}
fn char_at(node: @node, pos: uint) -> char {
let node = node;
let pos = pos;
while true {
alt *node {
leaf(x) {
ret str::char_at(*x.content, pos);
}
concat({left, right, _}) {
let left_len = char_len(left);
node = if left_len > pos { left }
else { pos -= left_len; right };
}
}
}
fail;//unreachable
}
mod leaf_iterator {
type t = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册