Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
4f5f3faa
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,发现更多精彩内容 >>
提交
4f5f3faa
编写于
8月 11, 2017
作者:
G
Guillaume Gomez
提交者:
GitHub
8月 11, 2017
浏览文件
操作
浏览文件
下载
差异文件
Rollup merge of #43791 - GuillaumeGomez:file-docs, r=QuietMisdreavus
File docs r? @rust-lang/docs
上级
3e6e2624
972d67ce
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
30 addition
and
19 deletion
+30
-19
src/libstd/fs.rs
src/libstd/fs.rs
+9
-7
src/libstd/io/error.rs
src/libstd/io/error.rs
+15
-8
src/libstd/io/mod.rs
src/libstd/io/mod.rs
+6
-4
未找到文件。
src/libstd/fs.rs
浏览文件 @
4f5f3faa
...
...
@@ -28,7 +28,7 @@
/// A reference to an open file on the filesystem.
///
/// An instance of a `File` can be read and/or written depending on what options
/// it was opened with. Files also implement
`Seek`
to alter the logical cursor
/// it was opened with. Files also implement
[`Seek`]
to alter the logical cursor
/// that the file contains internally.
///
/// Files are automatically closed when they go out of scope.
...
...
@@ -48,7 +48,7 @@
/// # }
/// ```
///
/// Read the contents of a file into a
`String`
:
/// Read the contents of a file into a
[`String`]
:
///
/// ```no_run
/// use std::fs::File;
...
...
@@ -81,6 +81,8 @@
/// # }
/// ```
///
/// [`Seek`]: ../io/trait.Seek.html
/// [`String`]: ../string/struct.String.html
/// [`Read`]: ../io/trait.Read.html
/// [`BufReader<R>`]: ../io/struct.BufReader.html
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
@@ -104,19 +106,19 @@ pub struct File {
/// Iterator over the entries in a directory.
///
/// This iterator is returned from the [`read_dir`] function of this module and
/// will yield instances of
`io::Result<DirEntry
>`. Through a [`DirEntry`]
/// will yield instances of
[`io::Result`]`<`[`DirEntry`]`
>`. Through a [`DirEntry`]
/// information like the entry's path and possibly other metadata can be
/// learned.
///
/// [`read_dir`]: fn.read_dir.html
/// [`DirEntry`]: struct.DirEntry.html
///
/// # Errors
///
/// This [`io::Result`] will be an
`Err`
if there's some sort of intermittent
/// This [`io::Result`] will be an
[`Err`]
if there's some sort of intermittent
/// IO error during iteration.
///
/// [`read_dir`]: fn.read_dir.html
/// [`DirEntry`]: struct.DirEntry.html
/// [`io::Result`]: ../io/type.Result.html
/// [`Err`]: ../result/enum.Result.html#variant.Err
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
#[derive(Debug)]
pub
struct
ReadDir
(
fs_imp
::
ReadDir
);
...
...
src/libstd/io/error.rs
浏览文件 @
4f5f3faa
...
...
@@ -17,17 +17,21 @@
/// A specialized [`Result`](../result/enum.Result.html) type for I/O
/// operations.
///
/// This type is broadly used across
`std::io`
for any operation which may
/// This type is broadly used across
[`std::io`]
for any operation which may
/// produce an error.
///
/// This typedef is generally used to avoid writing out
`io::Error`
directly and
/// is otherwise a direct mapping to
`Result`
.
/// This typedef is generally used to avoid writing out
[`io::Error`]
directly and
/// is otherwise a direct mapping to
[`Result`]
.
///
/// While usual Rust style is to import types directly, aliases of
`Result`
/// often are not, to make it easier to distinguish between them.
`Result`
is
/// generally assumed to be
`std::result::Result`
, and so users of this alias
/// While usual Rust style is to import types directly, aliases of
[`Result`]
/// often are not, to make it easier to distinguish between them.
[`Result`]
is
/// generally assumed to be
[`std::result::Result`][`Result`]
, and so users of this alias
/// will generally use `io::Result` instead of shadowing the prelude's import
/// of `std::result::Result`.
/// of [`std::result::Result`][`Result`].
///
/// [`std::io`]: ../io/index.html
/// [`io::Error`]: ../io/struct.Error.html
/// [`Result`]: ../result/enum.Result.html
///
/// # Examples
///
...
...
@@ -47,13 +51,16 @@
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
pub
type
Result
<
T
>
=
result
::
Result
<
T
,
Error
>
;
/// The error type for I/O operations of the
`Read`, `Write`, `Seek`
, and
/// The error type for I/O operations of the
[`Read`], [`Write`], [`Seek`]
, and
/// associated traits.
///
/// Errors mostly originate from the underlying OS, but custom instances of
/// `Error` can be created with crafted error messages and a particular value of
/// [`ErrorKind`].
///
/// [`Read`]: ../io/trait.Read.html
/// [`Write`]: ../io/trait.Write.html
/// [`Seek`]: ../io/trait.Seek.html
/// [`ErrorKind`]: enum.ErrorKind.html
#[derive(Debug)]
#[stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
src/libstd/io/mod.rs
浏览文件 @
4f5f3faa
...
...
@@ -22,7 +22,7 @@
//! you'll see a few different types of I/O throughout the documentation in
//! this module: [`File`]s, [`TcpStream`]s, and sometimes even [`Vec<T>`]s. For
//! example, [`Read`] adds a [`read`][`Read::read`] method, which we can use on
//!
`File`
s:
//!
[`File`]
s:
//!
//! ```
//! use std::io;
...
...
@@ -146,9 +146,9 @@
//! # }
//! ```
//!
//! Note that you cannot use the
`?` operator
in functions that do not return
//! a
`Result<T, E>` (e.g. `main`). Instead, you can call `.unwrap()` or `match`
//! on the return value to catch any possible errors:
//! Note that you cannot use the
[`?` operator]
in functions that do not return
//! a
[`Result<T, E>`][`Result`] (e.g. `main`). Instead, you can call [`.unwrap()`]
//! o
r `match` o
n the return value to catch any possible errors:
//!
//! ```
//! use std::io;
...
...
@@ -265,6 +265,8 @@
//! [`io::Result`]: type.Result.html
//! [`?` operator]: ../../book/first-edition/syntax-index.html
//! [`Read::read`]: trait.Read.html#tymethod.read
//! [`Result`]: ../result/enum.Result.html
//! [`.unwrap()`]: ../result/enum.Result.html#method.unwrap
#![stable(feature
=
"rust1"
,
since
=
"1.0.0"
)]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录