@@ -512,18 +512,20 @@ impl Error for JoinPathsError {
512
512
///
513
513
/// # Unix
514
514
///
515
- /// Returns the value of the 'HOME' environment variable if it is set
516
- /// and not equal to the empty string. Otherwise, it tries to determine the
517
- /// home directory by invoking the `getpwuid_r` function on the UID of the
518
- /// current user.
515
+ /// - Returns the value of the 'HOME' environment variable if it is set
516
+ /// (including to an empty string).
517
+ /// - Otherwise, it tries to determine the home directory by invoking the `getpwuid_r` function
518
+ /// using the UID of the current user. An empty home directory field returned from the
519
+ /// `getpwuid_r` function is considered to be a valid value.
520
+ /// - Returns `None` if the current user has no entry in the /etc/passwd file.
519
521
///
520
522
/// # Windows
521
523
///
522
- /// Returns the value of the 'HOME' environment variable if it is
523
- /// set and not equal to the empty string. Otherwise, returns the value of the
524
- /// 'USERPROFILE' environment variable if it is set and not equal to the empty
525
- /// string. If both do not exist, [`GetUserProfileDirectory`][msdn] is used to
526
- /// return the appropriate path.
524
+ /// - Returns the value of the 'HOME' environment variable if it is set
525
+ /// (including to an empty string).
526
+ /// - Otherwise, returns the value of the 'USERPROFILE' environment variable if it is set
527
+ /// (including to an empty string).
528
+ /// - If both do not exist, [`GetUserProfileDirectory`][msdn] is used to return the path.
527
529
///
528
530
/// [msdn]: https://msdn.microsoft.com/en-us/library/windows/desktop/bb762280(v=vs.85).aspx
529
531
///
@@ -533,10 +535,13 @@ impl Error for JoinPathsError {
533
535
/// use std::env;
534
536
///
535
537
/// match env::home_dir() {
536
- /// Some(path) => println!("{}", path.display()),
538
+ /// Some(path) => println!("Your home directory, probably: {}", path.display()),
537
539
/// None => println!("Impossible to get your home dir!"),
538
540
/// }
539
541
/// ```
542
+ #[ rustc_deprecated( since = "1.29.0" ,
543
+ reason = "This function's behavior is unexpected and probably not what you want. \
544
+ Consider using the home_dir function from crates.io/crates/dirs instead.") ]
540
545
#[ stable( feature = "env" , since = "1.0.0" ) ]
541
546
pub fn home_dir ( ) -> Option < PathBuf > {
542
547
os_imp:: home_dir ( )
0 commit comments