Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
e72ddbdc
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,发现更多精彩内容 >>
提交
e72ddbdc
编写于
2月 14, 2014
作者:
A
Alex Crichton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix all code examples
上级
6667f902
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
103 addition
and
67 deletion
+103
-67
src/libextra/json.rs
src/libextra/json.rs
+1
-1
src/libextra/stats.rs
src/libextra/stats.rs
+1
-1
src/libglob/lib.rs
src/libglob/lib.rs
+1
-1
src/libstd/comm/mod.rs
src/libstd/comm/mod.rs
+1
-1
src/libstd/fmt/mod.rs
src/libstd/fmt/mod.rs
+6
-6
src/libstd/io/comm_adapters.rs
src/libstd/io/comm_adapters.rs
+13
-4
src/libstd/io/net/unix.rs
src/libstd/io/net/unix.rs
+8
-5
src/libstd/kinds.rs
src/libstd/kinds.rs
+7
-2
src/libstd/logging.rs
src/libstd/logging.rs
+2
-2
src/libstd/num/int_macros.rs
src/libstd/num/int_macros.rs
+22
-19
src/libstd/num/mod.rs
src/libstd/num/mod.rs
+4
-2
src/libstd/rand/distributions/gamma.rs
src/libstd/rand/distributions/gamma.rs
+1
-1
src/libstd/str.rs
src/libstd/str.rs
+1
-1
src/libstd/task.rs
src/libstd/task.rs
+1
-1
src/libstd/unstable/finally.rs
src/libstd/unstable/finally.rs
+10
-4
src/libstd/vec.rs
src/libstd/vec.rs
+4
-4
src/libsyntax/ext/deriving/encodable.rs
src/libsyntax/ext/deriving/encodable.rs
+6
-0
src/libsyntax/ext/deriving/generic.rs
src/libsyntax/ext/deriving/generic.rs
+14
-12
未找到文件。
src/libextra/json.rs
浏览文件 @
e72ddbdc
...
...
@@ -30,7 +30,7 @@
Arrays are enclosed in square brackets ([ ... ]) and objects in curly brackets ({ ... }).
A simple JSON document encoding a person, his/her age, address and phone numbers could look like:
```
```
ignore
{
"FirstName": "John",
"LastName": "Doe",
...
...
src/libextra/stats.rs
浏览文件 @
e72ddbdc
...
...
@@ -341,7 +341,7 @@ pub fn write_5_number_summary(w: &mut io::Writer,
/// As an example, the summary with 5-number-summary `(min=15, q1=17, med=20, q3=24, max=31)` might
/// display as:
///
/// ~~~~
/// ~~~~
ignore
/// 10 | [--****#******----------] | 40
/// ~~~~
...
...
src/libglob/lib.rs
浏览文件 @
e72ddbdc
...
...
@@ -67,7 +67,7 @@ pub struct Paths {
///
/// The above code will print:
///
/// ```
/// ```
ignore
/// /media/pictures/kittens.jpg
/// /media/pictures/puppies.jpg
/// ```
...
...
src/libstd/comm/mod.rs
浏览文件 @
e72ddbdc
...
...
@@ -61,7 +61,7 @@
//! let (port, chan) = Chan::new();
//! spawn(proc() {
//! chan.send(10);
//! })
//! })
;
//! assert_eq!(port.recv(), 10);
//!
//! // Create a shared channel which can be sent along from many tasks
...
...
src/libstd/fmt/mod.rs
浏览文件 @
e72ddbdc
...
...
@@ -82,7 +82,7 @@
leverage named parameters. Named parameters are listed at the end of the
argument list and have the syntax:
```
```
ignore
identifier '=' expression
```
...
...
@@ -107,7 +107,7 @@
is used (the type's rust-representation is printed). For example, this is an
invalid format string:
```
```
ignore
{0:d} {0:s}
```
...
...
@@ -123,7 +123,7 @@
illegal to reference an argument as such. For example, this is another invalid
format string:
```
```
ignore
{:.*s} {0:u}
```
...
...
@@ -334,7 +334,7 @@ fn main() {
The select method is a switch over a `&str` parameter, and the parameter *must*
be of the type `&str`. An example of the syntax is:
```
```
ignore
{0, select, male{...} female{...} other{...}}
```
...
...
@@ -353,7 +353,7 @@ fn main() {
parameter *must* be a `uint`. A plural method in its full glory can be specified
as:
```
```
ignore
{0, plural, offset=1 =1{...} two{...} many{...} other{...}}
```
...
...
@@ -381,7 +381,7 @@ fn main() {
meaning that arguments are surrounded by `{}` instead of the C-like `%`. The
actual grammar for the formatting syntax is:
```
```
ignore
format_string := <text> [ format <text> ] *
format := '{' [ argument ] [ ':' format_spec ] [ ',' function_spec ] '}'
argument := integer | identifier
...
...
src/libstd/io/comm_adapters.rs
浏览文件 @
e72ddbdc
...
...
@@ -22,12 +22,16 @@
/// # Example
///
/// ```
/// let reader = PortReader::new(port);
/// use std::io::PortReader;
///
/// let (port, chan) = Chan::new();
/// # drop(chan);
/// let mut reader = PortReader::new(port);
///
/// let mut buf = ~[0u8, ..100];
/// match reader.read(buf) {
///
Some
(nread) => println!("Read {} bytes", nread),
///
None => println!("At the end of the stream!")
///
Ok
(nread) => println!("Read {} bytes", nread),
///
Err(e) => println!("read error: {}", e),
/// }
/// ```
pub
struct
PortReader
{
...
...
@@ -83,7 +87,12 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
/// # Example
///
/// ```
/// let writer = ChanWriter::new(chan);
/// # #[allow(unused_must_use)];
/// use std::io::ChanWriter;
///
/// let (port, chan) = Chan::new();
/// # drop(port);
/// let mut writer = ChanWriter::new(chan);
/// writer.write("hello, world".as_bytes());
/// ```
pub
struct
ChanWriter
{
...
...
src/libstd/io/net/unix.rs
浏览文件 @
e72ddbdc
...
...
@@ -91,15 +91,18 @@ impl UnixListener {
/// # Example
///
/// ```
/// # fn main() {}
/// # fn foo() {
/// # #[allow(unused_must_use)];
/// use std::io::net::unix::UnixListener;
/// use std::io::
Listener
;
/// use std::io::
{Listener, Acceptor}
;
///
/// let server = Path::new("path/to/my/socket");
/// let mut stream = UnixListener::bind(&server);
/// for client in stream.incoming() {
/// let mut client = client;
/// let server = Path::new("/path/to/my/socket");
/// let stream = UnixListener::bind(&server);
/// for mut client in stream.listen().incoming() {
/// client.write([1, 2, 3, 4]);
/// }
/// # }
/// ```
pub
fn
bind
<
P
:
ToCStr
>
(
path
:
&
P
)
->
IoResult
<
UnixListener
>
{
LocalIo
::
maybe_raise
(|
io
|
{
...
...
src/libstd/kinds.rs
浏览文件 @
e72ddbdc
...
...
@@ -69,7 +69,9 @@ pub mod marker {
/// Given a struct `S` that includes a type parameter `T`
/// but does not actually *reference* that type parameter:
///
/// ```
/// ```ignore
/// use std::cast;
///
/// struct S<T> { x: *() }
/// fn get<T>(s: &S<T>) -> T {
/// unsafe {
...
...
@@ -109,6 +111,8 @@ pub mod marker {
/// but does not actually *reference* that type parameter:
///
/// ```
/// use std::cast;
///
/// struct S<T> { x: *() }
/// fn get<T>(s: &S<T>, v: T) {
/// unsafe {
...
...
@@ -147,7 +151,8 @@ pub mod marker {
/// "interior" mutability:
///
/// ```
/// struct Cell<T> { priv value: T }
/// pub struct Cell<T> { priv value: T }
/// # fn main() {}
/// ```
///
/// The type system would infer that `value` is only read here and
...
...
src/libstd/logging.rs
浏览文件 @
e72ddbdc
...
...
@@ -42,7 +42,7 @@
`RUST_LOG` environment variable. The value of this environment variable is a
comma-separated list of logging directives. A logging directive is of the form:
```
```
ignore
path::to::module=log_level
```
...
...
@@ -65,7 +65,7 @@
Some examples of valid values of `RUST_LOG` are:
```
```
ignore
hello // turns on all logging for the 'hello' module
info // turns on all info logging
hello=debug // turns on debug logging for 'hello'
...
...
src/libstd/num/int_macros.rs
浏览文件 @
e72ddbdc
...
...
@@ -119,6 +119,8 @@ impl Rem<$T,$T> for $T {
/// Returns the integer remainder after division, satisfying:
///
/// ```
/// # let n = 1;
/// # let d = 2;
/// assert!((n / d) * d + (n % d) == n)
/// ```
///
...
...
@@ -194,15 +196,15 @@ impl Integer for $T {
/// # Examples
///
/// ```
/// assert!(( 8
).div_floor(
3) == 2);
/// assert!(( 8
).div_floor(
-3) == -3);
/// assert!((-8
).div_floor(
3) == -3);
/// assert!((-8
).div_floor(
-3) == 2);
///
/// assert!(( 1
).div_floor(
2) == 0);
/// assert!(( 1
).div_floor(
-2) == -1);
/// assert!((-1
).div_floor(
2) == -1);
/// assert!((-1
).div_floor(
-2) == 0);
/// assert!(( 8
i).div_floor(&
3) == 2);
/// assert!(( 8
i).div_floor(&
-3) == -3);
/// assert!((-8
i).div_floor(&
3) == -3);
/// assert!((-8
i).div_floor(&
-3) == 2);
///
/// assert!(( 1
i).div_floor(&
2) == 0);
/// assert!(( 1
i).div_floor(&
-2) == -1);
/// assert!((-1
i).div_floor(&
2) == -1);
/// assert!((-1
i).div_floor(&
-2) == 0);
/// ```
///
#[inline]
...
...
@@ -220,21 +222,22 @@ fn div_floor(&self, other: &$T) -> $T {
/// Integer modulo, satisfying:
///
/// ```
/// assert!(n.div_floor(d) * d + n.mod_floor(d) == n)
/// # let n = 1i; let d = 1i;
/// assert!(n.div_floor(&d) * d + n.mod_floor(&d) == n)
/// ```
///
/// # Examples
///
/// ```
/// assert!(( 8
).mod_floor(
3) == 2);
/// assert!(( 8
).mod_floor(
-3) == -1);
/// assert!((-8
).mod_floor(
3) == 1);
/// assert!((-8
).mod_floor(
-3) == -2);
///
/// assert!(( 1
).mod_floor(
2) == 1);
/// assert!(( 1
).mod_floor(
-2) == -1);
/// assert!((-1
).mod_floor(
2) == 1);
/// assert!((-1
).mod_floor(
-2) == -1);
/// assert!(( 8
i).mod_floor(&
3) == 2);
/// assert!(( 8
i).mod_floor(&
-3) == -1);
/// assert!((-8
i).mod_floor(&
3) == 1);
/// assert!((-8
i).mod_floor(&
-3) == -2);
///
/// assert!(( 1
i).mod_floor(&
2) == 1);
/// assert!(( 1
i).mod_floor(&
-2) == -1);
/// assert!((-1
i).mod_floor(&
2) == 1);
/// assert!((-1
i).mod_floor(&
-2) == -1);
/// ```
///
#[inline]
...
...
src/libstd/num/mod.rs
浏览文件 @
e72ddbdc
...
...
@@ -45,7 +45,7 @@ pub trait Zero: Add<Self, Self> {
///
/// # Laws
///
/// ~~~
/// ~~~
ignore
/// a + 0 = a ∀ a ∈ Self
/// 0 + a = a ∀ a ∈ Self
/// ~~~
...
...
@@ -71,7 +71,7 @@ pub trait One: Mul<Self, Self> {
///
/// # Laws
///
/// ~~~
/// ~~~
ignore
/// a * 1 = a ∀ a ∈ Self
/// 1 * a = a ∀ a ∈ Self
/// ~~~
...
...
@@ -964,6 +964,8 @@ impl FromPrimitive for $T {
/// # Example
///
/// ```
/// use std::num;
///
/// let twenty: f32 = num::cast(0x14).unwrap();
/// assert_eq!(twenty, 20f32);
/// ```
...
...
src/libstd/rand/distributions/gamma.rs
浏览文件 @
e72ddbdc
...
...
@@ -20,7 +20,7 @@
///
/// The density function of this distribution is
///
/// ```
/// ```
ignore
/// f(x) = x^(k - 1) * exp(-x / θ) / (Γ(k) * θ^k)
/// ```
///
...
...
src/libstd/str.rs
浏览文件 @
e72ddbdc
...
...
@@ -2011,7 +2011,7 @@ pub trait StrSlice<'a> {
///
/// ## Output
///
/// ```
/// ```
ignore
/// 0: 中
/// 3: 华
/// 6: V
...
...
src/libstd/task.rs
浏览文件 @
e72ddbdc
...
...
@@ -46,7 +46,7 @@
*
* ```
* spawn(proc() {
*
log(error,
"Hello, World!");
*
println!(
"Hello, World!");
* })
* ```
*/
...
...
src/libstd/unstable/finally.rs
浏览文件 @
e72ddbdc
...
...
@@ -19,13 +19,16 @@
# Example
```
```
use std::unstable::finally::Finally;
# fn always_run_this() {}
(|| {
...
//
...
}).finally(|| {
always_run_this();
})
```
```
*/
use
ops
::
Drop
;
...
...
@@ -69,13 +72,16 @@ fn finally(&self, dtor: ||) -> T {
* # Example
*
* ```
* use std::unstable::finally::try_finally;
*
* struct State<'a> { buffer: &'a mut [u8], len: uint }
* # let mut buf = [];
* let mut state = State { buffer: buf, len: 0 };
* try_finally(
* &mut state, (),
* |state, ()| {
* // use state.buffer, state.len
* }
* }
,
* |state| {
* // use state.buffer, state.len to cleanup
* })
...
...
src/libstd/vec.rs
浏览文件 @
e72ddbdc
...
...
@@ -955,7 +955,7 @@ pub trait ImmutableVector<'a, T> {
*
* Equivalent to:
*
* ```
* ```
ignore
* if self.len() == 0 { return None }
* let head = &self[0];
* *self = self.slice_from(1);
...
...
@@ -973,7 +973,7 @@ pub trait ImmutableVector<'a, T> {
*
* Equivalent to:
*
* ```
* ```
ignore
* if self.len() == 0 { return None; }
* let tail = &self[self.len() - 1];
* *self = self.slice_to(self.len() - 1);
...
...
@@ -2075,7 +2075,7 @@ pub trait MutableVector<'a, T> {
*
* Equivalent to:
*
* ```
* ```
ignore
* if self.len() == 0 { return None; }
* let head = &mut self[0];
* *self = self.mut_slice_from(1);
...
...
@@ -2093,7 +2093,7 @@ pub trait MutableVector<'a, T> {
*
* Equivalent to:
*
* ```
* ```
ignore
* if self.len() == 0 { return None; }
* let tail = &mut self[self.len() - 1];
* *self = self.mut_slice_to(self.len() - 1);
...
...
src/libsyntax/ext/deriving/encodable.rs
浏览文件 @
e72ddbdc
...
...
@@ -17,8 +17,10 @@
For example, a type like:
```ignore
#[deriving(Encodable, Decodable)]
struct Node {id: uint}
```
would generate two implementations like:
...
...
@@ -43,11 +45,14 @@ fn decode(d: &D) -> Node {
Other interesting scenarios are whe the item has type parameters or
references other non-built-in types. A type definition like:
```ignore
#[deriving(Encodable, Decodable)]
struct spanned<T> {node: T, span: Span}
```
would yield functions like:
```ignore
impl<
S: Encoder,
T: Encodable<S>
...
...
@@ -73,6 +78,7 @@ fn decode(d: &D) -> spanned<T> {
})
}
}
```
*/
use
ast
::{
MetaItem
,
Item
,
Expr
,
MutMutable
};
...
...
src/libsyntax/ext/deriving/generic.rs
浏览文件 @
e72ddbdc
...
...
@@ -59,7 +59,7 @@
an identifier in the source code. For example, the `x`s in the
following snippet
~~~
~~~
ignore
struct A { x : int }
struct B(int);
...
...
@@ -83,7 +83,7 @@ enum C {
The following simplified `Eq` is used for in-code examples:
~~~
~~~
ignore
trait Eq {
fn eq(&self, other: &Self);
}
...
...
@@ -101,7 +101,7 @@ fn eq(&self, other: &int) -> bool {
When generating the `expr` for the `A` impl, the `SubstructureFields` is
~~~
~~~
ignore
Struct(~[FieldInfo {
span: <span of x>
name: Some(<ident of x>),
...
...
@@ -112,7 +112,7 @@ fn eq(&self, other: &int) -> bool {
For the `B` impl, called with `B(a)` and `B(b)`,
~~~
~~~
ignore
Struct(~[FieldInfo {
span: <span of `int`>,
name: None,
...
...
@@ -126,7 +126,7 @@ fn eq(&self, other: &int) -> bool {
When generating the `expr` for a call with `self == C0(a)` and `other
== C0(b)`, the SubstructureFields is
~~~
~~~
ignore
EnumMatching(0, <ast::Variant for C0>,
~[FieldInfo {
span: <span of int>
...
...
@@ -138,7 +138,7 @@ fn eq(&self, other: &int) -> bool {
For `C1 {x}` and `C1 {x}`,
~~~
~~~
ignore
EnumMatching(1, <ast::Variant for C1>,
~[FieldInfo {
span: <span of x>
...
...
@@ -150,7 +150,7 @@ fn eq(&self, other: &int) -> bool {
For `C0(a)` and `C1 {x}` ,
~~~
~~~
ignore
EnumNonMatching(~[(0, <ast::Variant for B0>,
~[(<span of int>, None, <expr for &a>)]),
(1, <ast::Variant for B1>,
...
...
@@ -164,7 +164,7 @@ fn eq(&self, other: &int) -> bool {
A static method on the above would result in,
~~~~
~~~~
ignore
StaticStruct(<ast::StructDef of A>, Named(~[(<ident of x>, <span of x>)]))
StaticStruct(<ast::StructDef of B>, Unnamed(~[<span of x>]))
...
...
@@ -346,7 +346,9 @@ pub fn expand(&self,
* Given that we are deriving a trait `Tr` for a type `T<'a, ...,
* 'z, A, ..., Z>`, creates an impl like:
*
* ```ignore
* impl<'a, ..., 'z, A:Tr B1 B2, ..., Z: Tr B1 B2> Tr for T<A, ..., Z> { ... }
* ```
*
* where B1, B2, ... are the bounds given by `bounds_paths`.'
*
...
...
@@ -620,7 +622,7 @@ fn create_method(&self,
}
/**
~~~
~~~
ignore
#[deriving(Eq)]
struct A { x: int, y: int }
...
...
@@ -719,7 +721,7 @@ fn expand_static_struct_method_body(&self,
}
/**
~~~
~~~
ignore
#[deriving(Eq)]
enum A {
A1
...
...
@@ -762,7 +764,7 @@ fn expand_enum_method_body(&self,
/**
Creates the nested matches for an enum definition recursively, i.e.
~~~
~~~
ignore
match self {
Variant1 => match other { Variant1 => matching, Variant2 => nonmatching, ... },
Variant2 => match other { Variant1 => nonmatching, Variant2 => matching, ... },
...
...
@@ -1166,7 +1168,7 @@ pub fn cs_fold(use_foldl: bool,
Call the method that is being derived on all the fields, and then
process the collected results. i.e.
~~~
~~~
ignore
f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1),
self_2.method(__arg_1_2, __arg_2_2)])
~~~
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录