File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -628,18 +628,36 @@ impl GenericPath for Path {
628628}
629629
630630impl 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)
You can’t perform that action at this time.
0 commit comments