Skip to content

Commit 6063f79

Browse files
committed
auto merge of #16443 : steveklabnik/rust/fix_path_docs, r=kballard
Originally discovered here: http://www.reddit.com/r/rust/comments/2dbg3j/hm_unwrap_is_being_renamed_to_assert/cjnxiax
2 parents 4dfdc69 + e918733 commit 6063f79

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

src/libstd/path/windows.rs

+22-4
Original file line numberDiff line numberDiff line change
@@ -628,18 +628,36 @@ impl GenericPath for Path {
628628
}
629629

630630
impl Path {
631-
/// Returns a new Path from a byte vector or string
631+
/// Returns a new `Path` from a `BytesContainer`.
632632
///
633633
/// # Failure
634634
///
635-
/// Fails the task if the vector contains a NUL.
636-
/// Fails if invalid UTF-8.
635+
/// Fails if the vector contains a `NUL`, or if it contains invalid UTF-8.
636+
///
637+
/// # Example
638+
///
639+
/// ```
640+
/// println!("{}", Path::new(r"C:\some\path").display());
641+
/// ```
637642
#[inline]
638643
pub fn new<T: BytesContainer>(path: T) -> Path {
639644
GenericPath::new(path)
640645
}
641646

642-
/// Returns a new Path from a byte vector or string, if possible
647+
/// Returns a new `Some(Path)` from a `BytesContainer`.
648+
///
649+
/// Returns `None` if the vector contains a `NUL`, or if it contains invalid UTF-8.
650+
///
651+
/// # Example
652+
///
653+
/// ```
654+
/// let path = Path::new_opt(r"C:\some\path");
655+
///
656+
/// match path {
657+
/// Some(path) => println!("{}", path.display()),
658+
/// None => println!("There was a problem with your path."),
659+
/// }
660+
/// ```
643661
#[inline]
644662
pub fn new_opt<T: BytesContainer>(path: T) -> Option<Path> {
645663
GenericPath::new_opt(path)

0 commit comments

Comments
 (0)