1
Fork 0

Rollup merge of #34995 - GuillaumeGomez:dir_builder_doc, r=steveklabnik

Add DirBuilder doc examples

r? @steveklabnik

Part of #29329 and of #29356.
This commit is contained in:
Steve Klabnik 2016-07-26 17:21:12 -04:00 committed by GitHub
commit ae05e62ede
2 changed files with 28 additions and 1 deletions

View file

@ -1397,6 +1397,14 @@ pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions)
impl DirBuilder { impl DirBuilder {
/// Creates a new set of options with default mode/security settings for all /// Creates a new set of options with default mode/security settings for all
/// platforms and also non-recursive. /// platforms and also non-recursive.
///
/// # Examples
///
/// ```
/// use std::fs::DirBuilder;
///
/// let builder = DirBuilder::new();
/// ```
#[stable(feature = "dir_builder", since = "1.6.0")] #[stable(feature = "dir_builder", since = "1.6.0")]
pub fn new() -> DirBuilder { pub fn new() -> DirBuilder {
DirBuilder { DirBuilder {
@ -1409,7 +1417,16 @@ impl DirBuilder {
/// all parent directories if they do not exist with the same security and /// all parent directories if they do not exist with the same security and
/// permissions settings. /// permissions settings.
/// ///
/// This option defaults to `false` /// This option defaults to `false`.
///
/// # Examples
///
/// ```
/// use std::fs::DirBuilder;
///
/// let mut builder = DirBuilder::new();
/// builder.recursive(true);
/// ```
#[stable(feature = "dir_builder", since = "1.6.0")] #[stable(feature = "dir_builder", since = "1.6.0")]
pub fn recursive(&mut self, recursive: bool) -> &mut Self { pub fn recursive(&mut self, recursive: bool) -> &mut Self {
self.recursive = recursive; self.recursive = recursive;

View file

@ -239,6 +239,16 @@ pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>
pub trait DirBuilderExt { pub trait DirBuilderExt {
/// Sets the mode to create new directories with. This option defaults to /// Sets the mode to create new directories with. This option defaults to
/// 0o777. /// 0o777.
///
/// # Examples
///
/// ```ignore
/// use std::fs::DirBuilder;
/// use std::os::unix::fs::DirBuilderExt;
///
/// let mut builder = DirBuilder::new();
/// builder.mode(0o755);
/// ```
#[stable(feature = "dir_builder", since = "1.6.0")] #[stable(feature = "dir_builder", since = "1.6.0")]
fn mode(&mut self, mode: u32) -> &mut Self; fn mode(&mut self, mode: u32) -> &mut Self;
} }