Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
aa760a84
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
aa760a84
编写于
7月 15, 2014
作者:
N
Nick Cameron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
deprecate Vec::get
上级
b35d1a83
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
91 addition
and
88 deletion
+91
-88
src/compiletest/compiletest.rs
src/compiletest/compiletest.rs
+3
-3
src/compiletest/runtest.rs
src/compiletest/runtest.rs
+12
-12
src/doc/intro.md
src/doc/intro.md
+7
-7
src/doc/tutorial.md
src/doc/tutorial.md
+1
-1
src/libcollections/vec.rs
src/libcollections/vec.rs
+4
-1
src/libdebug/repr.rs
src/libdebug/repr.rs
+2
-2
src/libgetopts/lib.rs
src/libgetopts/lib.rs
+17
-17
src/libglob/lib.rs
src/libglob/lib.rs
+6
-6
src/libgraphviz/lib.rs
src/libgraphviz/lib.rs
+4
-4
src/libregex/parse.rs
src/libregex/parse.rs
+5
-5
src/libregex/re.rs
src/libregex/re.rs
+6
-6
src/libregex/vm.rs
src/libregex/vm.rs
+6
-6
src/librustdoc/clean/mod.rs
src/librustdoc/clean/mod.rs
+1
-1
src/librustdoc/html/format.rs
src/librustdoc/html/format.rs
+1
-1
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+1
-1
src/librustdoc/lib.rs
src/librustdoc/lib.rs
+1
-1
src/librustdoc/markdown.rs
src/librustdoc/markdown.rs
+1
-1
src/librustdoc/passes.rs
src/librustdoc/passes.rs
+1
-1
src/libserialize/json.rs
src/libserialize/json.rs
+1
-1
src/libsync/mpmc_bounded_queue.rs
src/libsync/mpmc_bounded_queue.rs
+2
-2
src/libsync/raw.rs
src/libsync/raw.rs
+2
-2
src/libterm/terminfo/parm.rs
src/libterm/terminfo/parm.rs
+3
-3
src/libtest/lib.rs
src/libtest/lib.rs
+1
-1
src/libtest/stats.rs
src/libtest/stats.rs
+1
-1
src/libuuid/lib.rs
src/libuuid/lib.rs
+2
-2
未找到文件。
src/compiletest/compiletest.rs
浏览文件 @
aa760a84
...
...
@@ -89,9 +89,9 @@ pub fn parse_config(args: Vec<String> ) -> Config {
optflag
(
"h"
,
"help"
,
"show this message"
));
assert
!
(
!
args
.is_empty
());
let
argv0
=
(
*
args
.get
(
0
))
.clone
();
let
argv0
=
args
[
0
]
.clone
();
let
args_
=
args
.tail
();
if
args
.get
(
1
)
.as_slice
()
==
"-h"
||
args
.get
(
1
)
.as_slice
()
==
"--help"
{
if
args
[
1
]
.as_slice
()
==
"-h"
||
args
[
1
]
.as_slice
()
==
"--help"
{
let
message
=
format!
(
"Usage: {} [OPTIONS] [TESTNAME...]"
,
argv0
);
println!
(
"{}"
,
getopts
::
usage
(
message
.as_slice
(),
groups
.as_slice
()));
println!
(
""
);
...
...
@@ -116,7 +116,7 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
}
let
filter
=
if
!
matches
.free
.is_empty
()
{
let
s
=
matches
.free
.get
(
0
)
.as_slice
();
let
s
=
matches
.free
[
0
]
.as_slice
();
match
regex
::
Regex
::
new
(
s
)
{
Ok
(
re
)
=>
Some
(
re
),
Err
(
e
)
=>
{
...
...
src/compiletest/runtest.rs
浏览文件 @
aa760a84
...
...
@@ -167,7 +167,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
let
proc_res
=
print_source
(
config
,
props
,
testfile
,
(
*
srcs
.get
(
round
))
.to_string
(),
srcs
[
round
]
.to_string
(),
"normal"
);
if
!
proc_res
.status
.success
()
{
...
...
@@ -187,9 +187,9 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
let
s
=
File
::
open
(
&
filepath
)
.read_to_end
()
.unwrap
();
String
::
from_utf8
(
s
)
.unwrap
()
}
None
=>
{
(
*
srcs
.get
(
srcs
.len
()
-
2u
))
.clone
()
}
None
=>
{
srcs
[
srcs
.len
()
-
2u
]
.clone
()
}
};
let
mut
actual
=
(
*
srcs
.get
(
srcs
.len
()
-
1u
))
.clone
();
let
mut
actual
=
srcs
[
srcs
.len
()
-
1u
]
.clone
();
if
props
.pp_exact
.is_some
()
{
// Now we have to care about line endings
...
...
@@ -209,7 +209,7 @@ fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
if
props
.no_pretty_expanded
{
return
}
// additionally, run `--pretty expanded` and try to build it.
let
proc_res
=
print_source
(
config
,
props
,
testfile
,
(
*
srcs
.get
(
round
))
.clone
(),
"expanded"
);
let
proc_res
=
print_source
(
config
,
props
,
testfile
,
srcs
[
round
]
.clone
(),
"expanded"
);
if
!
proc_res
.status
.success
()
{
fatal_proc_rec
(
"pretty-printing (expanded) failed"
,
&
proc_res
);
}
...
...
@@ -702,7 +702,7 @@ fn check_debugger_output(debugger_run_result: &ProcRes, check_lines: &[String])
let
mut
rest
=
line
.trim
();
let
mut
first
=
true
;
let
mut
failed
=
false
;
for
frag
in
check_fragments
.get
(
i
)
.iter
()
{
for
frag
in
check_fragments
[
i
]
.iter
()
{
let
found
=
if
first
{
if
rest
.starts_with
(
frag
.as_slice
())
{
Some
(
0
)
...
...
@@ -752,7 +752,7 @@ fn check_error_patterns(props: &TestProps,
}
let
mut
next_err_idx
=
0u
;
let
mut
next_err_pat
=
props
.error_patterns
.get
(
next_err_idx
)
;
let
mut
next_err_pat
=
&
props
.error_patterns
[
next_err_idx
]
;
let
mut
done
=
false
;
let
output_to_check
=
if
props
.check_stdout
{
format!
(
"{}{}"
,
proc_res
.stdout
,
proc_res
.stderr
)
...
...
@@ -761,14 +761,14 @@ fn check_error_patterns(props: &TestProps,
};
for
line
in
output_to_check
.as_slice
()
.lines
()
{
if
line
.contains
(
next_err_pat
.as_slice
())
{
debug!
(
"found error pattern {}"
,
*
next_err_pat
);
debug!
(
"found error pattern {}"
,
next_err_pat
);
next_err_idx
+=
1u
;
if
next_err_idx
==
props
.error_patterns
.len
()
{
debug!
(
"found all error patterns"
);
done
=
true
;
break
;
}
next_err_pat
=
props
.error_patterns
.get
(
next_err_idx
)
;
next_err_pat
=
&
props
.error_patterns
[
next_err_idx
]
;
}
}
if
done
{
return
;
}
...
...
@@ -847,13 +847,13 @@ fn prefix_matches( line : &str, prefix : &str ) -> bool {
for
line
in
proc_res
.stderr
.as_slice
()
.lines
()
{
let
mut
was_expected
=
false
;
for
(
i
,
ee
)
in
expected_errors
.iter
()
.enumerate
()
{
if
!
*
found_flags
.get
(
i
)
{
if
!
found_flags
[
i
]
{
debug!
(
"prefix={} ee.kind={} ee.msg={} line={}"
,
prefixes
.get
(
i
)
.as_slice
(),
prefixes
[
i
]
.as_slice
(),
ee
.kind
,
ee
.msg
,
line
);
if
prefix_matches
(
line
,
prefixes
.get
(
i
)
.as_slice
())
&&
if
prefix_matches
(
line
,
prefixes
[
i
]
.as_slice
())
&&
line
.contains
(
ee
.kind
.as_slice
())
&&
line
.contains
(
ee
.msg
.as_slice
())
{
*
found_flags
.get_mut
(
i
)
=
true
;
...
...
@@ -877,7 +877,7 @@ fn prefix_matches( line : &str, prefix : &str ) -> bool {
for
(
i
,
&
flag
)
in
found_flags
.iter
()
.enumerate
()
{
if
!
flag
{
let
ee
=
expected_errors
.get
(
i
)
;
let
ee
=
&
expected_errors
[
i
]
;
fatal_proc_rec
(
format!
(
"expected {} on line {} not found: {}"
,
ee
.kind
,
ee
.line
,
ee
.msg
)
.as_slice
(),
proc_res
);
...
...
src/doc/intro.md
浏览文件 @
aa760a84
...
...
@@ -205,7 +205,7 @@ fn main() {
spawn(proc() {
let numbers = rx.recv();
println!("{}",
*numbers.get(0)
);
println!("{}",
numbers[0]
);
})
}
```
...
...
@@ -244,11 +244,11 @@ fn main() {
spawn(proc() {
let numbers = rx.recv();
println!("{}", numbers
.get(0)
);
println!("{}", numbers
[0]
);
});
// Try to print a number from the original task
println!("{}",
*numbers.get(0)
);
println!("{}",
numbers[0]
);
}
```
...
...
@@ -256,7 +256,7 @@ The compiler will produce an error indicating that the value is no longer in sco
```
text
concurrency.rs:12:20: 12:27 error: use of moved value: 'numbers'
concurrency.rs:12 println!("{}", numbers
.get(0)
);
concurrency.rs:12 println!("{}", numbers
[0]
);
^~~~~~~
```
...
...
@@ -276,7 +276,7 @@ fn main() {
spawn(proc() {
let numbers = rx.recv();
println!("{:d}",
*numbers.get(num as uint)
);
println!("{:d}",
numbers[num as uint]
);
})
}
}
...
...
@@ -309,7 +309,7 @@ fn main() {
spawn(proc() {
let numbers = rx.recv();
println!("{:d}",
*numbers.get(num as uint)
);
println!("{:d}",
(*numbers)[num as uint]
);
})
}
}
...
...
@@ -364,7 +364,7 @@ fn main() {
// See: https://github.com/rust-lang/rust/issues/6515
*numbers.get_mut(num as uint) = *numbers.get_mut(num as uint) + 1;
println!("{}",
*numbers.get(num as uint)
);
println!("{}",
(*numbers)[num as uint]
);
// When `numbers` goes out of scope the lock is dropped
})
...
...
src/doc/tutorial.md
浏览文件 @
aa760a84
...
...
@@ -2427,7 +2427,7 @@ as in this version of `print_all` that copies elements.
fn print_all<T: Printable + Clone>(printable_things: Vec<T>) {
let mut i = 0;
while i < printable_things.len() {
let copy_of_thing = printable_things
.get(i)
.clone();
let copy_of_thing = printable_things
[i]
.clone();
copy_of_thing.print();
i += 1;
}
...
...
src/libcollections/vec.rs
浏览文件 @
aa760a84
...
...
@@ -42,7 +42,7 @@
/// vec.push(2i);
///
/// assert_eq!(vec.len(), 2);
/// assert_eq!(vec
.get(0), &
1);
/// assert_eq!(vec
[0],
1);
///
/// assert_eq!(vec.pop(), Some(2));
/// assert_eq!(vec.len(), 1);
...
...
@@ -746,9 +746,12 @@ pub unsafe fn set_len(&mut self, len: uint) {
/// # Example
///
/// ```rust
/// #![allow(deprecated)]
///
/// let vec = vec!(1i, 2, 3);
/// assert!(vec.get(1) == &2);
/// ```
#[deprecated=
"prefer using indexing, e.g., vec[0]"
]
#[inline]
pub
fn
get
<
'a
>
(
&
'a
self
,
index
:
uint
)
->
&
'a
T
{
&
self
.as_slice
()[
index
]
...
...
src/libdebug/repr.rs
浏览文件 @
aa760a84
...
...
@@ -466,7 +466,7 @@ fn visit_enum_variant_field(&mut self,
_
offset
:
uint
,
inner
:
*
const
TyDesc
)
->
bool
{
match
*
self
.var_stk
.get
(
self
.var_stk
.len
()
-
1
)
{
match
self
.var_stk
[
self
.var_stk
.len
()
-
1
]
{
Matched
=>
{
if
i
!=
0
{
try!
(
self
,
self
.writer
.write
(
", "
.as_bytes
()));
...
...
@@ -484,7 +484,7 @@ fn visit_leave_enum_variant(&mut self, _variant: uint,
_
disr_val
:
Disr
,
n_fields
:
uint
,
_
name
:
&
str
)
->
bool
{
match
*
self
.var_stk
.get
(
self
.var_stk
.len
()
-
1
)
{
match
self
.var_stk
[
self
.var_stk
.len
()
-
1
]
{
Matched
=>
{
if
n_fields
>
0
{
try!
(
self
,
self
.writer
.write
([
')'
as
u8
]));
...
...
src/libgetopts/lib.rs
浏览文件 @
aa760a84
...
...
@@ -51,7 +51,7 @@
//! fn main() {
//! let args: Vec<String> = os::args();
//!
//! let program = args
.get(0)
.clone();
//! let program = args
[0]
.clone();
//!
//! let opts = [
//! optopt("o", "", "set output file name", "NAME"),
...
...
@@ -67,7 +67,7 @@
//! }
//! let output = matches.opt_str("o");
//! let input = if !matches.free.is_empty() {
//!
(*matches.free.get(0))
.clone()
//!
matches.free[0]
.clone()
//! } else {
//! print_usage(program.as_slice(), opts);
//! return;
...
...
@@ -275,7 +275,7 @@ pub fn long_to_short(&self) -> Opt {
impl
Matches
{
fn
opt_vals
(
&
self
,
nm
:
&
str
)
->
Vec
<
Optval
>
{
match
find_opt
(
self
.opts
.as_slice
(),
Name
::
from_str
(
nm
))
{
Some
(
id
)
=>
(
*
self
.vals
.get
(
id
))
.clone
(),
Some
(
id
)
=>
self
.vals
[
id
]
.clone
(),
None
=>
fail
!
(
"No option '{}' defined"
,
nm
)
}
}
...
...
@@ -285,7 +285,7 @@ fn opt_val(&self, nm: &str) -> Option<Optval> {
if
vals
.is_empty
()
{
None
}
else
{
Some
(
(
*
vals
.get
(
0
))
.clone
())
Some
(
vals
[
0
]
.clone
())
}
}
...
...
@@ -304,7 +304,7 @@ pub fn opts_present(&self, names: &[String]) -> bool {
for
nm
in
names
.iter
()
{
match
find_opt
(
self
.opts
.as_slice
(),
Name
::
from_str
(
nm
.as_slice
()))
{
Some
(
id
)
if
!
self
.vals
.get
(
id
)
.is_empty
()
=>
return
true
,
Some
(
id
)
if
!
self
.vals
[
id
]
.is_empty
()
=>
return
true
,
_
=>
(),
};
}
...
...
@@ -344,8 +344,8 @@ pub fn opt_str(&self, nm: &str) -> Option<String> {
if
vals
.is_empty
()
{
return
None
::
<
String
>
;
}
match
vals
.get
(
0
)
{
&
Val
(
ref
s
)
=>
Some
((
*
s
)
.clone
()),
match
vals
[
0
]
{
Val
(
ref
s
)
=>
Some
((
*
s
)
.clone
()),
_
=>
None
}
}
...
...
@@ -361,8 +361,8 @@ pub fn opt_default(&self, nm: &str, def: &str) -> Option<String> {
if
vals
.is_empty
()
{
return
None
;
}
match
vals
.get
(
0
)
{
&
Val
(
ref
s
)
=>
Some
((
*
s
)
.clone
()),
match
vals
[
0
]
{
Val
(
ref
s
)
=>
Some
((
*
s
)
.clone
()),
_
=>
Some
(
def
.to_string
())
}
}
...
...
@@ -560,8 +560,8 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
names
=
vec!
(
Long
(
tail
.to_string
()));
}
else
{
names
=
vec!
(
Long
(
(
*
tail_eq
.get
(
0
))
.to_string
()));
i_arg
=
Some
(
(
*
tail_eq
.get
(
1
))
.to_string
());
vec!
(
Long
(
tail_eq
[
0
]
.to_string
()));
i_arg
=
Some
(
tail_eq
[
1
]
.to_string
());
}
}
else
{
let
mut
j
=
1
;
...
...
@@ -583,7 +583,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
None
=>
{
let
arg_follows
=
last_valid_opt_id
.is_some
()
&&
match
opts
.get
(
last_valid_opt_id
.unwrap
())
match
opts
[
last_valid_opt_id
.unwrap
()]
.hasarg
{
Yes
|
Maybe
=>
true
,
...
...
@@ -609,7 +609,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
Some
(
id
)
=>
id
,
None
=>
return
Err
(
UnrecognizedOption
(
nm
.to_string
()))
};
match
opts
.get
(
optid
)
.hasarg
{
match
opts
[
optid
]
.hasarg
{
No
=>
{
if
!
i_arg
.is_none
()
{
return
Err
(
UnexpectedArgument
(
nm
.to_string
()));
...
...
@@ -646,16 +646,16 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
}
i
=
0u
;
while
i
<
n_opts
{
let
n
=
vals
.get
(
i
)
.len
();
let
occ
=
opts
.get
(
i
)
.occur
;
let
n
=
vals
[
i
]
.len
();
let
occ
=
opts
[
i
]
.occur
;
if
occ
==
Req
{
if
n
==
0
{
return
Err
(
OptionMissing
(
opts
.get
(
i
)
.name
.to_string
()));
return
Err
(
OptionMissing
(
opts
[
i
]
.name
.to_string
()));
}
}
if
occ
!=
Multi
{
if
n
>
1
{
return
Err
(
OptionDuplicated
(
opts
.get
(
i
)
.name
.to_string
()));
return
Err
(
OptionDuplicated
(
opts
[
i
]
.name
.to_string
()));
}
}
i
+=
1
;
...
...
src/libglob/lib.rs
浏览文件 @
aa760a84
...
...
@@ -154,7 +154,7 @@ fn next(&mut self) -> Option<Path> {
if
self
.require_dir
&&
!
path
.is_dir
()
{
continue
;
}
return
Some
(
path
);
}
let
ref
pattern
=
*
self
.dir_patterns
.get
(
idx
)
;
let
ref
pattern
=
self
.dir_patterns
[
idx
]
;
if
pattern
.matches_with
(
match
path
.filename_str
()
{
// this ugly match needs to go here to avoid a borrowck error
...
...
@@ -250,21 +250,21 @@ pub fn new(pattern: &str) -> Pattern {
let
mut
i
=
0
;
while
i
<
chars
.len
()
{
match
*
chars
.get
(
i
)
{
match
chars
[
i
]
{
'?'
=>
{
tokens
.push
(
AnyChar
);
i
+=
1
;
}
'*'
=>
{
// *, **, ***, ****, ... are all equivalent
while
i
<
chars
.len
()
&&
*
chars
.get
(
i
)
==
'*'
{
while
i
<
chars
.len
()
&&
chars
[
i
]
==
'*'
{
i
+=
1
;
}
tokens
.push
(
AnySequence
);
}
'['
=>
{
if
i
<=
chars
.len
()
-
4
&&
*
chars
.get
(
i
+
1
)
==
'!'
{
if
i
<=
chars
.len
()
-
4
&&
chars
[
i
+
1
]
==
'!'
{
match
chars
.slice_from
(
i
+
3
)
.position_elem
(
&
']'
)
{
None
=>
(),
Some
(
j
)
=>
{
...
...
@@ -276,7 +276,7 @@ pub fn new(pattern: &str) -> Pattern {
}
}
}
else
if
i
<=
chars
.len
()
-
3
&&
*
chars
.get
(
i
+
1
)
!=
'!'
{
else
if
i
<=
chars
.len
()
-
3
&&
chars
[
i
+
1
]
!=
'!'
{
match
chars
.slice_from
(
i
+
2
)
.position_elem
(
&
']'
)
{
None
=>
(),
Some
(
j
)
=>
{
...
...
@@ -507,7 +507,7 @@ fn pattern_as_str(pattern: &Pattern) -> Option<String> {
// the current and parent directory respectively requires that
// the pattern has a leading dot, even if the `MatchOptions` field
// `require_literal_leading_dot` is not set.
if
pattern
.tokens
.len
()
>
0
&&
pattern
.tokens
.get
(
0
)
==
&
Char
(
'.'
)
{
if
pattern
.tokens
.len
()
>
0
&&
pattern
.tokens
[
0
]
==
Char
(
'.'
)
{
for
&
special
in
[
"."
,
".."
]
.iter
()
{
if
pattern
.matches_with
(
special
,
options
)
{
add
(
todo
,
path
.join
(
special
));
...
...
src/libgraphviz/lib.rs
浏览文件 @
aa760a84
...
...
@@ -168,7 +168,7 @@ fn node_id(&'a self, n: &Nd) -> dot::Id<'a> {
dot::Id::new(format!("N{}", n))
}
fn node_label<'a>(&'a self, n: &Nd) -> dot::LabelText<'a> {
dot::LabelStr(str::Slice(self.nodes
.get(*n)
.as_slice()))
dot::LabelStr(str::Slice(self.nodes
[*n]
.as_slice()))
}
fn edge_label<'a>(&'a self, _: &Ed) -> dot::LabelText<'a> {
dot::LabelStr(str::Slice("⊆"))
...
...
@@ -225,7 +225,7 @@ fn node_id(&'a self, n: &Nd<'a>) -> dot::Id<'a> {
}
fn node_label<'a>(&'a self, n: &Nd<'a>) -> dot::LabelText<'a> {
let &(i, _) = n;
dot::LabelStr(str::Slice(self.nodes
.get(i)
.as_slice()))
dot::LabelStr(str::Slice(self.nodes
[i]
.as_slice()))
}
fn edge_label<'a>(&'a self, _: &Ed<'a>) -> dot::LabelText<'a> {
dot::LabelStr(str::Slice("⊆"))
...
...
@@ -238,8 +238,8 @@ fn nodes(&'a self) -> dot::Nodes<'a,Nd<'a>> {
}
fn edges(&'a self) -> dot::Edges<'a,Ed<'a>> {
self.edges.iter()
.map(|&(i,j)|((i, self.nodes
.get(i)
.as_slice()),
(j, self.nodes
.get(j)
.as_slice())))
.map(|&(i,j)|((i, self.nodes
[i]
.as_slice()),
(j, self.nodes
[j]
.as_slice())))
.collect()
}
fn source(&self, e: &Ed<'a>) -> Nd<'a> { let &(s,_) = e; s }
...
...
src/libregex/parse.rs
浏览文件 @
aa760a84
...
...
@@ -235,7 +235,7 @@ fn parse(&mut self) -> Result<Ast, Error> {
// left paren, let's grab the old flags and see if we
// need a capture.
let
(
cap
,
cap_name
,
oldflags
)
=
{
let
paren
=
self
.stack
.get
(
altfrom
-
1
)
;
let
paren
=
&
self
.stack
[
altfrom
-
1
]
;
(
paren
.capture
(),
paren
.capture_name
(),
paren
.flags
())
};
try!
(
self
.alternate
(
altfrom
));
...
...
@@ -464,7 +464,7 @@ fn try_parse_ascii(&mut self) -> Option<Ast> {
Some
(
i
)
=>
i
,
None
=>
return
None
,
};
if
*
self
.chars
.get
(
closer
-
1
)
!=
':'
{
if
self
.chars
[
closer
-
1
]
!=
':'
{
return
None
}
if
closer
-
self
.chari
<=
3
{
...
...
@@ -519,7 +519,7 @@ fn parse_counted(&mut self) -> Result<(), Error> {
max
=
Some
(
min
);
}
else
{
let
pieces
:
Vec
<&
str
>
=
inner
.as_slice
()
.splitn
(
','
,
1
)
.collect
();
let
(
smin
,
smax
)
=
(
*
pieces
.get
(
0
),
*
pieces
.get
(
1
)
);
let
(
smin
,
smax
)
=
(
pieces
[
0
],
pieces
[
1
]
);
if
smin
.len
()
==
0
{
return
self
.err
(
"Max repetitions cannot be specified
\
without min repetitions."
)
...
...
@@ -931,7 +931,7 @@ fn peek(&self, offset: uint) -> Option<char> {
if
self
.chari
+
offset
>=
self
.chars
.len
()
{
return
None
}
Some
(
*
self
.chars
.get
(
self
.chari
+
offset
)
)
Some
(
self
.chars
[
self
.chari
+
offset
]
)
}
fn
peek_is
(
&
self
,
offset
:
uint
,
is
:
char
)
->
bool
{
...
...
@@ -939,7 +939,7 @@ fn peek_is(&self, offset: uint, is: char) -> bool {
}
fn
cur
(
&
self
)
->
char
{
*
self
.chars
.get
(
self
.chari
)
self
.chars
[
self
.chari
]
}
fn
slice
(
&
self
,
start
:
uint
,
end
:
uint
)
->
String
{
...
...
src/libregex/re.rs
浏览文件 @
aa760a84
...
...
@@ -207,7 +207,7 @@ pub fn is_match(&self, text: &str) -> bool {
pub
fn
find
(
&
self
,
text
:
&
str
)
->
Option
<
(
uint
,
uint
)
>
{
let
caps
=
exec
(
self
,
Location
,
text
);
if
has_match
(
&
caps
)
{
Some
((
caps
.get
(
0
)
.unwrap
(),
caps
.get
(
1
)
.unwrap
()))
Some
((
caps
[
0
]
.unwrap
(),
caps
[
1
]
.unwrap
()))
}
else
{
None
}
...
...
@@ -699,11 +699,11 @@ fn new(re: &Regex, search: &'t str, locs: CaptureLocs)
/// original string matched.
pub
fn
pos
(
&
self
,
i
:
uint
)
->
Option
<
(
uint
,
uint
)
>
{
let
(
s
,
e
)
=
(
i
*
2
,
i
*
2
+
1
);
if
e
>=
self
.locs
.len
()
||
self
.locs
.get
(
s
)
.is_none
()
{
if
e
>=
self
.locs
.len
()
||
self
.locs
[
s
]
.is_none
()
{
// VM guarantees that each pair of locations are both Some or None.
return
None
}
Some
((
self
.locs
.get
(
s
)
.unwrap
(),
self
.locs
.get
(
e
)
.unwrap
()))
Some
((
self
.locs
[
s
]
.unwrap
(),
self
.locs
[
e
]
.unwrap
()))
}
/// Returns the matched string for the capture group `i`.
...
...
@@ -851,7 +851,7 @@ fn next(&mut self) -> Option<Captures<'t>> {
if
!
has_match
(
&
caps
)
{
return
None
}
else
{
(
caps
.get
(
0
)
.unwrap
(),
caps
.get
(
1
)
.unwrap
())
(
caps
[
0
]
.unwrap
(),
caps
[
1
]
.unwrap
())
};
// Don't accept empty matches immediately following a match.
...
...
@@ -893,7 +893,7 @@ fn next(&mut self) -> Option<(uint, uint)> {
if
!
has_match
(
&
caps
)
{
return
None
}
else
{
(
caps
.get
(
0
)
.unwrap
(),
caps
.get
(
1
)
.unwrap
())
(
caps
[
0
]
.unwrap
(),
caps
[
1
]
.unwrap
())
};
// Don't accept empty matches immediately following a match.
...
...
@@ -922,5 +922,5 @@ fn exec_slice(re: &Regex, which: MatchKind,
#[inline]
fn
has_match
(
caps
:
&
CaptureLocs
)
->
bool
{
caps
.len
()
>=
2
&&
caps
.get
(
0
)
.is_some
()
&&
caps
.get
(
1
)
.is_some
()
caps
.len
()
>=
2
&&
caps
[
0
]
.is_some
()
&&
caps
[
1
]
.is_some
()
}
src/libregex/vm.rs
浏览文件 @
aa760a84
...
...
@@ -123,7 +123,7 @@ fn run(&mut self) -> CaptureLocs {
// Make sure multi-line mode isn't enabled for it, otherwise we can't
// drop the initial .*?
let
prefix_anchor
=
match
*
self
.prog.insts
.get
(
1
)
{
match
self
.prog.insts
[
1
]
{
EmptyBegin
(
flags
)
if
flags
&
FLAG_MULTI
==
0
=>
true
,
_
=>
false
,
};
...
...
@@ -192,7 +192,7 @@ fn run(&mut self) -> CaptureLocs {
fn
step
(
&
self
,
groups
:
&
mut
[
Option
<
uint
>
],
nlist
:
&
mut
Threads
,
caps
:
&
mut
[
Option
<
uint
>
],
pc
:
uint
)
->
StepState
{
match
*
self
.prog.insts
.get
(
pc
)
{
match
self
.prog.insts
[
pc
]
{
Match
=>
{
match
self
.which
{
Exists
=>
{
...
...
@@ -259,7 +259,7 @@ fn add(&self, nlist: &mut Threads, pc: uint, groups: &mut [Option<uint>]) {
//
// We make a minor optimization by indicating that the state is "empty"
// so that its capture groups are not filled in.
match
*
self
.prog.insts
.get
(
pc
)
{
match
self
.prog.insts
[
pc
]
{
EmptyBegin
(
flags
)
=>
{
let
multi
=
flags
&
FLAG_MULTI
>
0
;
nlist
.add
(
pc
,
groups
,
true
);
...
...
@@ -481,8 +481,8 @@ fn add(&mut self, pc: uint, groups: &[Option<uint>], empty: bool) {
#[inline]
fn
contains
(
&
self
,
pc
:
uint
)
->
bool
{
let
s
=
*
self
.sparse
.get
(
pc
)
;
s
<
self
.size
&&
self
.queue
.get
(
s
)
.pc
==
pc
let
s
=
self
.sparse
[
pc
]
;
s
<
self
.size
&&
self
.queue
[
s
]
.pc
==
pc
}
#[inline]
...
...
@@ -492,7 +492,7 @@ fn empty(&mut self) {
#[inline]
fn
pc
(
&
self
,
i
:
uint
)
->
uint
{
self
.queue
.get
(
i
)
.pc
self
.queue
[
i
]
.pc
}
#[inline]
...
...
src/librustdoc/clean/mod.rs
浏览文件 @
aa760a84
...
...
@@ -999,7 +999,7 @@ fn clean(&self) -> Item {
};
let
s
=
match
s
{
ast
::
SelfRegion
(
..
)
=>
{
match
ty
::
get
(
*
self
.fty.sig.inputs
.get
(
0
)
)
.sty
{
match
ty
::
get
(
self
.fty.sig.inputs
[
0
]
)
.sty
{
ty
::
ty_rptr
(
r
,
mt
)
=>
{
SelfBorrowed
(
r
.clean
(),
mt
.mutbl
.clean
())
}
...
...
src/librustdoc/html/format.rs
浏览文件 @
aa760a84
...
...
@@ -210,7 +210,7 @@ fn path(w: &mut fmt::Formatter, path: &clean::Path, print_all: bool,
let
loc
=
current_location_key
.get
()
.unwrap
();
let
cache
=
cache_key
.get
()
.unwrap
();
let
abs_root
=
root
(
&**
cache
,
loc
.as_slice
());
let
rel_root
=
match
path
.segments
.get
(
0
)
.name
.as_slice
()
{
let
rel_root
=
match
path
.segments
[
0
]
.name
.as_slice
()
{
"self"
=>
Some
(
"./"
.to_string
()),
_
=>
None
,
};
...
...
src/librustdoc/html/render.rs
浏览文件 @
aa760a84
...
...
@@ -551,7 +551,7 @@ fn collect(path: &Path, krate: &str,
}
mydst
.push
(
format!
(
"{}.{}.js"
,
remote_item_type
.to_static_str
(),
*
remote_path
.get
(
remote_path
.len
()
-
1
)
));
remote_path
[
remote_path
.len
()
-
1
]
));
let
all_implementors
=
try!
(
collect
(
&
mydst
,
krate
.name
.as_slice
(),
"implementors"
));
...
...
src/librustdoc/lib.rs
浏览文件 @
aa760a84
...
...
@@ -167,7 +167,7 @@ pub fn main_args(args: &[String]) -> int {
println!
(
"only one input file may be specified"
);
return
1
;
}
let
input
=
matches
.free
.get
(
0
)
.as_slice
();
let
input
=
matches
.free
[
0
]
.as_slice
();
let
libs
=
matches
.opt_strs
(
"L"
)
.iter
()
.map
(|
s
|
Path
::
new
(
s
.as_slice
()))
.collect
();
...
...
src/librustdoc/markdown.rs
浏览文件 @
aa760a84
...
...
@@ -75,7 +75,7 @@ pub fn render(input: &str, mut output: Path, matches: &getopts::Matches,
"invalid markdown file: expecting initial line with `% ...TITLE...`"
);
return
5
;
}
let
title
=
metadata
.get
(
0
)
.as_slice
();
let
title
=
metadata
[
0
]
.as_slice
();
reset_headers
();
...
...
src/librustdoc/passes.rs
浏览文件 @
aa760a84
...
...
@@ -339,7 +339,7 @@ pub fn unindent(s: &str) -> String {
});
if
lines
.len
()
>=
1
{
let
mut
unindented
=
vec!
[
lines
.get
(
0
)
.trim
()
.to_string
()
];
let
mut
unindented
=
vec!
[
lines
[
0
]
.trim
()
.to_string
()
];
unindented
.push_all
(
lines
.tail
()
.iter
()
.map
(|
&
line
|
{
if
line
.is_whitespace
()
{
line
.to_string
()
...
...
src/libserialize/json.rs
浏览文件 @
aa760a84
...
...
@@ -1015,7 +1015,7 @@ pub fn is_empty(&self) -> bool { self.stack.is_empty() }
/// lower indices are at the bottom of the stack while higher indices are
/// at the top.
pub
fn
get
<
'l
>
(
&
'l
self
,
idx
:
uint
)
->
StackElement
<
'l
>
{
match
*
self
.stack
.get
(
idx
)
{
match
self
.stack
[
idx
]
{
InternalIndex
(
i
)
=>
{
Index
(
i
)
}
InternalKey
(
start
,
size
)
=>
{
Key
(
str
::
from_utf8
(
...
...
src/libsync/mpmc_bounded_queue.rs
浏览文件 @
aa760a84
...
...
@@ -90,7 +90,7 @@ fn push(&self, value: T) -> bool {
let
mask
=
self
.mask
;
let
mut
pos
=
self
.enqueue_pos
.load
(
Relaxed
);
loop
{
let
node
=
self
.buffer
.get
(
pos
&
mask
)
;
let
node
=
&
self
.buffer
[
pos
&
mask
]
;
let
seq
=
unsafe
{
(
*
node
.get
())
.sequence
.load
(
Acquire
)
};
let
diff
:
int
=
seq
as
int
-
pos
as
int
;
...
...
@@ -118,7 +118,7 @@ fn pop(&self) -> Option<T> {
let
mask
=
self
.mask
;
let
mut
pos
=
self
.dequeue_pos
.load
(
Relaxed
);
loop
{
let
node
=
self
.buffer
.get
(
pos
&
mask
)
;
let
node
=
&
self
.buffer
[
pos
&
mask
]
;
let
seq
=
unsafe
{
(
*
node
.get
())
.sequence
.load
(
Acquire
)
};
let
diff
:
int
=
seq
as
int
-
(
pos
+
1
)
as
int
;
if
diff
==
0
{
...
...
src/libsync/raw.rs
浏览文件 @
aa760a84
...
...
@@ -243,7 +243,7 @@ pub fn wait_on(&self, condvar_id: uint) {
}
// Create waiter nobe, and enqueue ourself to
// be woken up by a signaller.
wait_end
=
Some
(
state
.blocked
.get
(
condvar_id
)
.wait_end
());
wait_end
=
Some
(
state
.blocked
[
condvar_id
]
.wait_end
());
}
else
{
out_of_bounds
=
Some
(
state
.blocked
.len
());
}
...
...
@@ -281,7 +281,7 @@ pub fn signal_on(&self, condvar_id: uint) -> bool {
let
mut
result
=
false
;
self
.sem
.with
(|
state
|
{
if
condvar_id
<
state
.blocked
.len
()
{
result
=
state
.blocked
.get
(
condvar_id
)
.signal
();
result
=
state
.blocked
[
condvar_id
]
.signal
();
}
else
{
out_of_bounds
=
Some
(
state
.blocked
.len
());
}
...
...
src/libterm/terminfo/parm.rs
浏览文件 @
aa760a84
...
...
@@ -512,13 +512,13 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
assert
!
(
!
s
.is_empty
(),
"string conversion produced empty result"
);
match
op
{
FormatDigit
=>
{
if
flags
.space
&&
!
(
*
s
.get
(
0
)
==
'-'
as
u8
||
*
s
.get
(
0
)
==
'+'
as
u8
)
{
if
flags
.space
&&
!
(
s
[
0
]
==
'-'
as
u8
||
s
[
0
]
==
'+'
as
u8
)
{
s
.unshift
(
' '
as
u8
);
}
}
FormatOctal
=>
{
if
flags
.alternate
&&
*
s
.get
(
0
)
!=
'0'
as
u8
{
if
flags
.alternate
&&
s
[
0
]
!=
'0'
as
u8
{
s
.unshift
(
'0'
as
u8
);
}
}
...
...
src/libtest/lib.rs
浏览文件 @
aa760a84
...
...
@@ -373,7 +373,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
if
matches
.opt_present
(
"h"
)
{
usage
(
args
[
0
]
.as_slice
());
return
None
;
}
let
filter
=
if
matches
.free
.len
()
>
0
{
let
s
=
matches
.free
.get
(
0
)
.as_slice
();
let
s
=
matches
.free
[
0
]
.as_slice
();
match
Regex
::
new
(
s
)
{
Ok
(
re
)
=>
Some
(
re
),
Err
(
e
)
=>
return
Some
(
Err
(
format!
(
"could not parse /{}/: {}"
,
s
,
e
)))
...
...
src/libtest/stats.rs
浏览文件 @
aa760a84
...
...
@@ -175,7 +175,7 @@ fn sum(self) -> T {
// This inner loop applies `hi`/`lo` summation to each
// partial so that the list of partial sums remains exact.
for
i
in
range
(
0
,
partials
.len
())
{
let
mut
y
=
*
partials
.get
(
i
)
;
let
mut
y
=
partials
[
i
]
;
if
num
::
abs
(
x
)
<
num
::
abs
(
y
)
{
mem
::
swap
(
&
mut
x
,
&
mut
y
);
}
...
...
src/libuuid/lib.rs
浏览文件 @
aa760a84
...
...
@@ -398,8 +398,8 @@ pub fn parse_string(us: &str) -> Result<Uuid, ParseError> {
match
group_lens
.len
()
{
// Single group, no hyphens
1
=>
{
if
*
group_lens
.get
(
0
)
!=
32
{
return
Err
(
ErrorInvalidLength
(
*
group_lens
.get
(
0
)
));
if
group_lens
[
0
]
!=
32
{
return
Err
(
ErrorInvalidLength
(
group_lens
[
0
]
));
}
},
// Five groups, hyphens in between each
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录