Skip to content

Commit 0be64de

Browse files
authored
Rollup merge of #161415 - cdcp2:fix-path-expect-messages, r=nia-e
Update expect messages in path docs to better follow guidelines Updates the `.expect()` messages in `library/std/src/path.rs` to better follow the guidance for `expect` messages. Related to #159751.
2 parents f71b322 + 176a865 commit 0be64de

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎library/std/src/path.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3329,7 +3329,7 @@ impl Path {
33293329
/// use std::path::Path;
33303330
///
33313331
/// let path = Path::new("/Minas/tirith");
3332-
/// let metadata = path.metadata().expect("metadata call failed");
3332+
/// let metadata = path.metadata().expect("the path should point to an existing file or directory");
33333333
/// println!("{:?}", metadata.file_type());
33343334
/// ```
33353335
#[stable(feature = "path_ext", since = "1.5.0")]
@@ -3348,7 +3348,7 @@ impl Path {
33483348
/// use std::path::Path;
33493349
///
33503350
/// let path = Path::new("/Minas/tirith");
3351-
/// let metadata = path.symlink_metadata().expect("symlink_metadata call failed");
3351+
/// let metadata = path.symlink_metadata().expect("the path should exist");
33523352
/// println!("{:?}", metadata.file_type());
33533353
/// ```
33543354
#[stable(feature = "path_ext", since = "1.5.0")]
@@ -3483,7 +3483,7 @@ impl Path {
34833483
/// use std::path::Path;
34843484
///
34853485
/// let path = Path::new("/laputa/sky_castle.rs");
3486-
/// let path_link = path.read_link().expect("read_link call failed");
3486+
/// let path_link = path.read_link().expect("the path should be an existing symbolic link");
34873487
/// ```
34883488
#[stable(feature = "path_ext", since = "1.5.0")]
34893489
#[inline]
@@ -3504,7 +3504,7 @@ impl Path {
35043504
/// use std::path::Path;
35053505
///
35063506
/// let path = Path::new("/laputa");
3507-
/// for entry in path.read_dir().expect("read_dir call failed") {
3507+
/// for entry in path.read_dir().expect("the path should point to an existing directory") {
35083508
/// if let Ok(entry) = entry {
35093509
/// println!("{:?}", entry.path());
35103510
/// }
@@ -3569,7 +3569,7 @@ impl Path {
35693569
///
35703570
/// ```no_run
35713571
/// use std::path::Path;
3572-
/// assert!(!Path::new("does_not_exist.txt").try_exists().expect("Can't check existence of file does_not_exist.txt"));
3572+
/// assert!(!Path::new("does_not_exist.txt").try_exists().expect("the path's existence should be verifiable"));
35733573
/// assert!(Path::new("/root/secret_file.txt").try_exists().is_err());
35743574
/// ```
35753575
///

0 commit comments

Comments
 (0)