From 4a2cc4511190c24b135fe9c037a78cc0ed42d821 Mon Sep 17 00:00:00 2001 From: Hendrik Sollich Date: Thu, 12 Jul 2018 00:14:06 +0200 Subject: [PATCH] feat: replace `std::home_dir()` with `dirs::home_dir()` `std::home_dir()` is deprecated since 1.29 https://github.com/rust-lang/rust/pull/51656 --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + src/config.rs | 5 ++++- src/lib.rs | 1 + src/storage/mod.rs | 5 +++-- src/util/mod.rs | 6 ++++-- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5ce0d2840..68ae35ee8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -33,6 +33,7 @@ dependencies = [ "crowbook-intl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "crowbook-intl-runtime 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "enum_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -268,6 +269,15 @@ name = "difference" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "dirs" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "dtoa" version = "0.4.3" @@ -1346,6 +1356,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum crowbook-intl-runtime 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "62cf6ec512b4d7fb7d8683efa703b17e5b8f5e24a9eb7ec9fb92237f039d941c" "checksum custom_derive 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" "checksum difference 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" +"checksum dirs 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "37a76dd8b997af7107d0bb69d43903cf37153a18266f8b3fdb9911f28efb5444" "checksum dtoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6d301140eb411af13d3115f9a562c85cc6b541ade9dfa314132244aaee7489dd" "checksum either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3be565ca5c557d7f59e7cfcf1844f9e3033650c929c6566f511e8005f205c1d0" "checksum encode_unicode 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "28d65f1f5841ef7c6792861294b72beda34c664deb8be27970f36c306b7da1ce" diff --git a/Cargo.toml b/Cargo.toml index 5a3a68d62..daf987c43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/config.rs b/src/config.rs index bc75af72e..e5d0514e2 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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 diff --git a/src/lib.rs b/src/lib.rs index 3da4b7a29..bbd2b7c6c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 6f52d6109..5a67f1b34 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -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; @@ -152,7 +153,7 @@ pub fn list_path_content(path:&Path) -> StorageResult> { 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. diff --git a/src/util/mod.rs b/src/util/mod.rs index 8f1b24861..3e282b37f 100644 --- a/src/util/mod.rs +++ b/src/util/mod.rs @@ -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; @@ -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.