Skip to content

Commit 8c810ef

Browse files
authored
Rollup merge of rust-lang#34995 - GuillaumeGomez:dir_builder_doc, r=steveklabnik
Add DirBuilder doc examples r? @steveklabnik Part of rust-lang#29329 and of rust-lang#29356.
2 parents 4d44503 + 90bb8d4 commit 8c810ef

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/libstd/fs.rs

+18-1
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,14 @@ pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions)
13971397
impl DirBuilder {
13981398
/// Creates a new set of options with default mode/security settings for all
13991399
/// platforms and also non-recursive.
1400+
///
1401+
/// # Examples
1402+
///
1403+
/// ```
1404+
/// use std::fs::DirBuilder;
1405+
///
1406+
/// let builder = DirBuilder::new();
1407+
/// ```
14001408
#[stable(feature = "dir_builder", since = "1.6.0")]
14011409
pub fn new() -> DirBuilder {
14021410
DirBuilder {
@@ -1409,7 +1417,16 @@ impl DirBuilder {
14091417
/// all parent directories if they do not exist with the same security and
14101418
/// permissions settings.
14111419
///
1412-
/// This option defaults to `false`
1420+
/// This option defaults to `false`.
1421+
///
1422+
/// # Examples
1423+
///
1424+
/// ```
1425+
/// use std::fs::DirBuilder;
1426+
///
1427+
/// let mut builder = DirBuilder::new();
1428+
/// builder.recursive(true);
1429+
/// ```
14131430
#[stable(feature = "dir_builder", since = "1.6.0")]
14141431
pub fn recursive(&mut self, recursive: bool) -> &mut Self {
14151432
self.recursive = recursive;

src/libstd/sys/unix/ext/fs.rs

+10
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,16 @@ pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>
239239
pub trait DirBuilderExt {
240240
/// Sets the mode to create new directories with. This option defaults to
241241
/// 0o777.
242+
///
243+
/// # Examples
244+
///
245+
/// ```ignore
246+
/// use std::fs::DirBuilder;
247+
/// use std::os::unix::fs::DirBuilderExt;
248+
///
249+
/// let mut builder = DirBuilder::new();
250+
/// builder.mode(0o755);
251+
/// ```
242252
#[stable(feature = "dir_builder", since = "1.6.0")]
243253
fn mode(&mut self, mode: u32) -> &mut Self;
244254
}

0 commit comments

Comments
 (0)