Update to rust 2021

This commit is contained in:
2021-11-12 14:48:03 +01:00
parent a726a701e6
commit 7cc798fcab
4 changed files with 145 additions and 95 deletions

View File

@ -51,7 +51,7 @@ async fn dir(cfg: &Config, env: &Env, relative: PathBuf) -> Result<(), Errors> {
let mut dir_tasks = vec![];
let mut file_tasks = vec![];
while let Some(entry) = walker.next_entry().await.with_location(&&template_path)? {
while let Some(entry) = walker.next_entry().await.with_location(&template_path)? {
let meta = entry.metadata().await.with_location(&entry.path())?;
let new_relative = relative.join(entry.file_name());
@ -98,7 +98,7 @@ async fn file(cfg: &Config, env: &Env, relative: PathBuf) -> Result<(), Error> {
let mut rendered = Vec::<u8>::new();
parse_template(&file_str)
.with_location(&template_path)?
.write(&env, &mut rendered)
.write(env, &mut rendered)
.with_location(&template_path)?;
let rendered = std::str::from_utf8(&rendered).unwrap();
@ -122,7 +122,7 @@ fn get_username() -> String {
env::var("USER")
.ok()
.or_else(|| env::var("USERNAME").ok())
.unwrap_or_else(|| String::new())
.unwrap_or_else(String::new)
}
async fn get_hostname() -> String {
@ -140,8 +140,8 @@ async fn get_hostname() -> String {
read_hostname_file()
.await
.or_else(|| run_hostname_cmd())
.unwrap_or_else(|| String::new())
.or_else(run_hostname_cmd)
.unwrap_or_else(String::new)
.trim()
.to_string()
}