File tree 1 file changed +22
-4
lines changed
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 {
628
628
}
629
629
630
630
impl Path {
631
- /// Returns a new Path from a byte vector or string
631
+ /// Returns a new ` Path` from a `BytesContainer`.
632
632
///
633
633
/// # Failure
634
634
///
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
+ /// ```
637
642
#[ inline]
638
643
pub fn new < T : BytesContainer > ( path : T ) -> Path {
639
644
GenericPath :: new ( path)
640
645
}
641
646
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
+ /// ```
643
661
#[ inline]
644
662
pub fn new_opt < T : BytesContainer > ( path : T ) -> Option < Path > {
645
663
GenericPath :: new_opt ( path)
You can’t perform that action at this time.
0 commit comments