Skip to content

Commit

Permalink
feat: replace std::home_dir() with dirs::home_dir()
Browse files Browse the repository at this point in the history
`std::home_dir()` is deprecated since 1.29
rust-lang/rust#51656
  • Loading branch information
hoodie committed Jul 11, 2018
1 parent f1b1876 commit 4a2cc45
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ itertools = "0.7"
base64 = "0.9"
rustyline = {version = "1.0.0", optional = true }
linked-hash-map = {version = "0.5", features = ["serde_impl"]}
dirs = "1.0"

rocket = {version = "0.3", optional = true }
rocket_codegen = {version = "0.3", optional = true }
Expand Down
5 changes: 4 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@
//#![warn(missing_debug_implementations)]


use std::env::{self, home_dir, current_dir};
use std::env::{self, current_dir};
use std::path::{Path, PathBuf};

use dirs::home_dir;

use util::yaml::{self, Yaml, YamlError};

/// Name of the configfile
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern crate tempdir;
extern crate bill;
extern crate open;
extern crate toml;
extern crate dirs;
extern crate semver;
extern crate term_size;
extern crate icalendar;
Expand Down
5 changes: 3 additions & 2 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
//!
use rayon::prelude::*;
use dirs::home_dir;

use std::fs;
use std::env::{self, home_dir, current_dir};
use std::env::{self, current_dir};
use std::path::{Path, PathBuf};
use std::marker::PhantomData;

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

fn replace_home_tilde(p:&Path) -> PathBuf{
let path = p.to_str().unwrap();
PathBuf::from( path.replace("~",home_dir().unwrap().to_str().unwrap()))
PathBuf::from( path.replace("~", home_dir().unwrap().to_str().unwrap()))
}

/// Interprets storage path from config.
Expand Down
6 changes: 4 additions & 2 deletions src/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
//! Utility functions that are needed all over the places.
#![allow(dead_code)]
use std::{env, io, fs};
use std::env::{home_dir, current_dir};
use std::env::current_dir;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};
use std::process::{self, Command, ExitStatus};
use chrono::NaiveTime;

use dirs::home_dir;

use env_logger;
use log::LevelFilter;

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

/// Opens the passed paths in the editor set int config.
Expand Down

0 comments on commit 4a2cc45

Please sign in to comment.