Skip to content

Commit 4a2cc45

Browse files
committed
feat: replace std::home_dir() with dirs::home_dir()
`std::home_dir()` is deprecated since 1.29 rust-lang/rust#51656
1 parent f1b1876 commit 4a2cc45

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ itertools = "0.7"
5151
base64 = "0.9"
5252
rustyline = {version = "1.0.0", optional = true }
5353
linked-hash-map = {version = "0.5", features = ["serde_impl"]}
54+
dirs = "1.0"
5455

5556
rocket = {version = "0.3", optional = true }
5657
rocket_codegen = {version = "0.3", optional = true }

src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,11 @@
1212
//#![warn(missing_debug_implementations)]
1313

1414

15-
use std::env::{self, home_dir, current_dir};
15+
use std::env::{self, current_dir};
1616
use std::path::{Path, PathBuf};
17+
18+
use dirs::home_dir;
19+
1720
use util::yaml::{self, Yaml, YamlError};
1821

1922
/// Name of the configfile

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extern crate tempdir;
3535
extern crate bill;
3636
extern crate open;
3737
extern crate toml;
38+
extern crate dirs;
3839
extern crate semver;
3940
extern crate term_size;
4041
extern crate icalendar;

src/storage/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
//!
2121
2222
use rayon::prelude::*;
23+
use dirs::home_dir;
2324

2425
use std::fs;
25-
use std::env::{self, home_dir, current_dir};
26+
use std::env::{self, current_dir};
2627
use std::path::{Path, PathBuf};
2728
use std::marker::PhantomData;
2829

@@ -152,7 +153,7 @@ pub fn list_path_content(path:&Path) -> StorageResult<Vec<PathBuf>> {
152153

153154
fn replace_home_tilde(p:&Path) -> PathBuf{
154155
let path = p.to_str().unwrap();
155-
PathBuf::from( path.replace("~",home_dir().unwrap().to_str().unwrap()))
156+
PathBuf::from( path.replace("~", home_dir().unwrap().to_str().unwrap()))
156157
}
157158

158159
/// Interprets storage path from config.

src/util/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
//! Utility functions that are needed all over the places.
22
#![allow(dead_code)]
33
use std::{env, io, fs};
4-
use std::env::{home_dir, current_dir};
4+
use std::env::current_dir;
55
use std::ffi::OsStr;
66
use std::path::{Path, PathBuf};
77
use std::process::{self, Command, ExitStatus};
88
use chrono::NaiveTime;
99

10+
use dirs::home_dir;
11+
1012
use env_logger;
1113
use log::LevelFilter;
1214

@@ -80,7 +82,7 @@ pub fn ls(path:&str){
8082
/// **TODO** ~ must be first character
8183
pub fn replace_home_tilde(p:&Path) -> PathBuf{
8284
let path = p.to_str().unwrap();
83-
PathBuf::from( path.replace("~",home_dir().unwrap().to_str().unwrap()))
85+
PathBuf::from(path.replace("~", home_dir().unwrap().to_str().unwrap()))
8486
}
8587

8688
/// Opens the passed paths in the editor set int config.

0 commit comments

Comments
 (0)