Skip to content

Commit 8d3f20f

Browse files
Add doc examples for std::fs::unix::OpenOptionsExt
1 parent 52c50ba commit 8d3f20f

File tree

1 file changed

+12
-0
lines changed
  • src/libstd/sys/unix/ext

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ pub trait OpenOptionsExt {
6363
/// If no `mode` is set, the default of `0o666` will be used.
6464
/// The operating system masks out bits with the systems `umask`, to produce
6565
/// the final permissions.
66+
///
67+
/// # Examples
68+
///
69+
/// ```rust,ignore
70+
/// extern crate libc;
71+
/// use std::fs::OpenOptions;
72+
/// use std::os::unix::fs::OpenOptionsExt;
73+
///
74+
/// let mut options = OpenOptions::new();
75+
/// options.mode(0o644); // Give read/write for owner and read for others.
76+
/// let file = options.open("foo.txt");
77+
/// ```
6678
#[stable(feature = "fs_ext", since = "1.1.0")]
6779
fn mode(&mut self, mode: u32) -> &mut Self;
6880

0 commit comments

Comments
 (0)