Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c5830a95
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,发现更多精彩内容 >>
提交
c5830a95
编写于
5月 29, 2014
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
doc: Fix a number of broken links
cc #14515
上级
8c669d7f
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
52 addition
and
35 deletion
+52
-35
src/doc/complement-cheatsheet.md
src/doc/complement-cheatsheet.md
+19
-18
src/doc/complement-lang-faq.md
src/doc/complement-lang-faq.md
+3
-3
src/doc/guide-unsafe.md
src/doc/guide-unsafe.md
+5
-4
src/liballoc/lib.rs
src/liballoc/lib.rs
+1
-0
src/libcore/lib.rs
src/libcore/lib.rs
+2
-0
src/libcore/result.rs
src/libcore/result.rs
+2
-2
src/librustdoc/html/format.rs
src/librustdoc/html/format.rs
+10
-4
src/librustdoc/html/render.rs
src/librustdoc/html/render.rs
+9
-4
src/librustuv/homing.rs
src/librustuv/homing.rs
+1
-0
未找到文件。
src/doc/complement-cheatsheet.md
浏览文件 @
c5830a95
...
...
@@ -4,7 +4,7 @@
**Int to string**
Use
[
`ToStr`
](
../
std/to_str/trait.ToStr.html
)
.
Use
[
`ToStr`
](
std/to_str/trait.ToStr.html
)
.
~~~
let x: int = 42;
...
...
@@ -13,8 +13,8 @@ let y: String = x.to_str().to_string();
**String to int**
Use
[
`FromStr`
](
../
std/from_str/trait.FromStr.html
)
, and its helper function,
[
`from_str`
](
../
std/from_str/fn.from_str.html
)
.
Use
[
`FromStr`
](
std/from_str/trait.FromStr.html
)
, and its helper function,
[
`from_str`
](
std/from_str/fn.from_str.html
)
.
~~~
let x: Option<int> = from_str("42");
...
...
@@ -35,8 +35,8 @@ let y: String = format!("{:X}", x); // uppercase hexadecimal
**String to int, in non-base-10**
Use
[
`FromStrRadix`
](
../
std/num/trait.FromStrRadix.html
)
, and its helper
function,
[
`from_str_radix`
](
../
std/num/fn.from_str_radix.html
)
.
Use
[
`FromStrRadix`
](
std/num/trait.FromStrRadix.html
)
, and its helper
function,
[
`from_str_radix`
](
std/num/fn.from_str_radix.html
)
.
~~~
use std::num;
...
...
@@ -48,7 +48,7 @@ let y: i64 = x.unwrap();
**Vector of Bytes to String**
To return a Borrowed String Slice (&str) use the str helper function
[
`from_utf8`
](
../
std/str/fn.from_utf8.html
)
.
[
`from_utf8`
](
std/str/fn.from_utf8.html
)
.
~~~
use std::str;
...
...
@@ -58,7 +58,7 @@ let x: &str = str::from_utf8(bytes).unwrap();
~~~
To return an Owned String use the str helper function
[
`from_utf8_owned`
](
../
std/str/fn.from_utf8_owned.html
)
.
[
`from_utf8_owned`
](
std/str/fn.from_utf8_owned.html
)
.
~~~
use std::str;
...
...
@@ -68,8 +68,8 @@ let x: Option<String> =
let y: String = x.unwrap();
~~~
To return a
[
`MaybeOwned`
](
../std/str/enum
.MaybeOwned.html
)
use the str helper
function
[
`from_utf8_lossy`
](
../
std/str/fn.from_utf8_owned.html
)
.
To return a
[
`MaybeOwned`
](
std/str/type
.MaybeOwned.html
)
use the str helper
function
[
`from_utf8_lossy`
](
std/str/fn.from_utf8_owned.html
)
.
This function also replaces non-valid utf-8 sequences with U+FFFD replacement
character.
...
...
@@ -85,11 +85,11 @@ let y = str::from_utf8_lossy(x);
## How do I read from a file?
Use
[
`File::open`
](
../
std/io/fs/struct.File.html#method.open
)
[
`File::open`
](
std/io/fs/struct.File.html#method.open
)
to create a
[
`File`
](
../
std/io/fs/struct.File.html
)
[
`File`
](
std/io/fs/struct.File.html
)
struct, which implements the
[
`Reader`
](
../
std/io/trait.Reader.html
)
[
`Reader`
](
std/io/trait.Reader.html
)
trait.
~~~
{.ignore}
...
...
@@ -103,7 +103,8 @@ let reader : File = File::open(&path).unwrap_or_else(on_error);
## How do I iterate over the lines in a file?
Use the
[
`lines`
](
../std/io/trait.Buffer.html#method.lines
)
method on a
[
`BufferedReader`
](
../std/io/buffered/struct.BufferedReader.html
)
.
Use the
[
`lines`
](
std/io/trait.Buffer.html#method.lines
)
method on a
[
`BufferedReader`
](
std/io/struct.BufferedReader.html
)
.
~~~
use std::io::BufferedReader;
...
...
@@ -121,7 +122,7 @@ for line in reader.lines() {
## How do I search for a substring?
Use the
[
`find_str`
](
../
std/str/trait.StrSlice.html#tymethod.find_str
)
method.
Use the
[
`find_str`
](
std/str/trait.StrSlice.html#tymethod.find_str
)
method.
~~~
let str = "Hello, this is some random string";
...
...
@@ -132,7 +133,7 @@ let index: Option<uint> = str.find_str("rand");
## How do I get the length of a vector?
The
[
`Container`
](
../
std/container/trait.Container.html
)
trait provides the
`len`
method.
The
[
`Container`
](
std/container/trait.Container.html
)
trait provides the
`len`
method.
~~~
let u: Vec<u32> = vec![0, 1, 2];
...
...
@@ -144,7 +145,7 @@ println!("u: {}, v: {}, w: {}", u.len(), v.len(), w.len()); // 3, 4, 5
## How do I iterate over a vector?
Use the
[
`iter`
](
../std/vec
/trait.ImmutableVector.html#tymethod.iter
)
method.
Use the
[
`iter`
](
std/slice
/trait.ImmutableVector.html#tymethod.iter
)
method.
~~~
let values: Vec<int> = vec![1, 2, 3, 4, 5];
...
...
@@ -153,9 +154,9 @@ for value in values.iter() { // value: &int
}
~~~
(See also
[
`mut_iter`
](
../std/vec
/trait.MutableVector.html#tymethod.mut_iter
)
(See also
[
`mut_iter`
](
std/slice
/trait.MutableVector.html#tymethod.mut_iter
)
which yields
`&mut int`
and
[
`move_iter`
](
../std/vec
/trait.OwnedVector.html#tymethod.move_iter
)
which yields
[
`move_iter`
](
std/slice
/trait.OwnedVector.html#tymethod.move_iter
)
which yields
`int`
while consuming the
`values`
vector.)
# Type system
...
...
src/doc/complement-lang-faq.md
浏览文件 @
c5830a95
...
...
@@ -21,7 +21,7 @@ Some examples that demonstrate different aspects of the language:
*
The extra library's [json] module. Enums and pattern matching
[
sprocketnes
]:
https://github.com/pcwalton/sprocketnes
[
hash
]:
https://github.com/mozilla/rust/blob/master/src/libstd/hash.rs
[
hash
]:
https://github.com/mozilla/rust/blob/master/src/libstd/hash
/mod
.rs
[
HashMap
]:
https://github.com/mozilla/rust/blob/master/src/libcollections/hashmap.rs
[
json
]:
https://github.com/mozilla/rust/blob/master/src/libserialize/json.rs
...
...
@@ -149,6 +149,6 @@ example we were setting RUST_LOG to the name of the hello crate. Multiple paths
can be combined to control the exact logging you want to see. For example, when
debugging linking in the compiler you might set
`RUST_LOG=rustc::metadata::creader,rustc::util::filesearch,rustc::back::rpath`
For a full description see
[
the l
anguage referenc
e
][
1
]
.
For a full description see
[
the l
ogging crat
e
][
1
]
.
[
1
]:
http://doc.rust-lang.org/doc/master/rust.html#logging-system
[
1
]:
log/index.html
src/doc/guide-unsafe.md
浏览文件 @
c5830a95
...
...
@@ -499,9 +499,9 @@ shouldn't get triggered.
The second of these two functions,
`eh_personality`
, is used by the failure
mechanisms of the compiler. This is often mapped to GCC's personality function
(see the
[
libstd implementation
](
../std/rt/unwind/
)
for more information), but
crates which do not trigger failure can be assured that this function is never
called.
(see the
[
libstd implementation
](
std/rt/unwind/index.html
)
for more
information), but crates which do not trigger failure can be assured that this
function is never
called.
## Using libcore
...
...
@@ -511,7 +511,8 @@ called.
With the above techniques, we've got a bare-metal executable running some Rust
code. There is a good deal of functionality provided by the standard library,
however, that is necessary to be productive in Rust. If the standard library is
not sufficient, then
[
libcore
](
../core/
)
is designed to be used instead.
not sufficient, then
[
libcore
](
../core/index.html
)
is designed to be used
instead.
The core library has very few dependencies and is much more portable than the
standard library itself. Additionally, the core library has most of the
...
...
src/liballoc/lib.rs
浏览文件 @
c5830a95
...
...
@@ -97,6 +97,7 @@
pub
mod
rc
;
#[cfg(not(test))]
#[doc(hidden)]
mod
std
{
pub
use
core
::
fmt
;
pub
use
core
::
option
;
...
...
src/libcore/lib.rs
浏览文件 @
c5830a95
...
...
@@ -134,10 +134,12 @@
// crate.
mod
should_not_exist
;
#[doc(hidden)]
mod
core
{
pub
use
failure
;
}
#[doc(hidden)]
mod
std
{
pub
use
clone
;
pub
use
cmp
;
...
...
src/libcore/result.rs
浏览文件 @
c5830a95
...
...
@@ -234,8 +234,8 @@
//! similar and complementary: they are often employed to indicate a
//! lack of a return value; and they are trivially converted between
//! each other, so `Result`s are often handled by first converting to
//! `Option` with the [`ok`](
enum
.Result.html#method.ok) and
//! [`err`](
enum
.Result.html#method.ok) methods.
//! `Option` with the [`ok`](
type
.Result.html#method.ok) and
//! [`err`](
type
.Result.html#method.ok) methods.
//!
//! Whereas `Option` only indicates the lack of a value, `Result` is
//! specifically for error reporting, and carries with it an error
...
...
src/librustdoc/html/format.rs
浏览文件 @
c5830a95
...
...
@@ -278,18 +278,24 @@ fn primitive_link(f: &mut fmt::Formatter,
needs_termination
=
true
;
}
Some
(
&
cnum
)
=>
{
let
path
=
m
.paths
.get
(
&
ast
::
DefId
{
krate
:
cnum
,
node
:
ast
::
CRATE_NODE_ID
,
});
let
loc
=
match
*
m
.extern_locations
.get
(
&
cnum
)
{
render
::
Remote
(
ref
s
)
=>
Some
(
s
.to_string
()),
render
::
Local
=>
{
let
loc
=
current_location_key
.get
()
.unwrap
();
Some
(
(
"../"
.repeat
(
loc
.len
()))
.to_string
(
))
Some
(
"../"
.repeat
(
loc
.len
()
))
}
render
::
Unknown
=>
None
,
};
match
loc
{
Some
(
s
)
=>
{
try!
(
write!
(
f
,
"<a href='{}/primitive.{}.html'>"
,
s
,
prim
.to_url_str
()));
Some
(
root
)
=>
{
try!
(
write!
(
f
,
"<a href='{}{}/primitive.{}.html'>"
,
root
,
path
.ref0
()
.as_slice
()
.head
()
.unwrap
(),
prim
.to_url_str
()));
needs_termination
=
true
;
}
None
=>
{}
...
...
src/librustdoc/html/render.rs
浏览文件 @
c5830a95
...
...
@@ -1380,8 +1380,13 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if
s
.len
()
==
0
{
return
Ok
(());
}
try!
(
write!
(
f
,
"<code> = </code>"
));
if
s
.contains
(
"
\n
"
)
{
write!
(
f
,
"<a href='{}'>[definition]</a>"
,
item
.href
())
match
item
.href
()
{
Some
(
url
)
=>
{
write!
(
f
,
"<a href='{}'>[definition]</a>"
,
url
)
}
None
=>
Ok
(()),
}
}
else
{
write!
(
f
,
"<code>{}</code>"
,
s
.as_slice
())
}
...
...
@@ -1547,8 +1552,8 @@ fn meth(w: &mut fmt::Formatter, m: &clean::TraitMethod) -> fmt::Result {
}
try!
(
write!
(
w
,
"</ul>"
));
try!
(
write!
(
w
,
r#"<script type="text/javascript" async
src="{root_path}/implementors/{path}/
\
{ty}.{name}.js">
</script>"#
,
src="{root_path}/implementors/{path}/
{ty}.{name}.js">
</script>"#
,
root_path
=
Vec
::
from_elem
(
cx
.current
.len
(),
".."
)
.connect
(
"/"
),
path
=
if
ast_util
::
is_local
(
it
.def_id
)
{
cx
.current
.connect
(
"/"
)
...
...
src/librustuv/homing.rs
浏览文件 @
c5830a95
...
...
@@ -82,6 +82,7 @@ pub fn local_id() -> uint {
}
}
#[doc(hidden)]
pub
trait
HomingIO
{
fn
home
<
'r
>
(
&
'r
mut
self
)
->
&
'r
mut
HomeHandle
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录