Revert "Revert "Reformat imports to a consistent style for imports""

This reverts commit d7377d4794.
This commit is contained in:
Tyera Eulberg
2021-12-16 14:21:32 -07:00
committed by Tyera Eulberg
parent 9fff4aa8b8
commit 9f53f3455a
380 changed files with 6072 additions and 5298 deletions

View File

@@ -154,8 +154,7 @@ fn extract_release_archive(
archive: &Path,
extract_dir: &Path,
) -> Result<(), Box<dyn std::error::Error>> {
use bzip2::bufread::BzDecoder;
use tar::Archive;
use {bzip2::bufread::BzDecoder, tar::Archive};
let progress_bar = new_spinner_progress_bar();
progress_bar.set_message(&format!("{}Extracting...", PACKAGE));
@@ -308,8 +307,7 @@ fn check_env_path_for_bin_dir(config: &Config) {
/// Encodes a UTF-8 string as a null-terminated UCS-2 string in bytes
#[cfg(windows)]
pub fn string_to_winreg_bytes(s: &str) -> Vec<u8> {
use std::ffi::OsString;
use std::os::windows::ffi::OsStrExt;
use std::{ffi::OsString, os::windows::ffi::OsStrExt};
let v: Vec<_> = OsString::from(format!("{}\x00", s)).encode_wide().collect();
unsafe { std::slice::from_raw_parts(v.as_ptr() as *const u8, v.len() * 2).to_vec() }
}
@@ -320,8 +318,7 @@ pub fn string_to_winreg_bytes(s: &str) -> Vec<u8> {
// conversion.
#[cfg(windows)]
pub fn string_from_winreg_value(val: &winreg::RegValue) -> Option<String> {
use std::slice;
use winreg::enums::RegType;
use {std::slice, winreg::enums::RegType};
match val.vtype {
RegType::REG_SZ | RegType::REG_EXPAND_SZ => {
@@ -347,8 +344,10 @@ pub fn string_from_winreg_value(val: &winreg::RegValue) -> Option<String> {
// should not mess with it.
#[cfg(windows)]
fn get_windows_path_var() -> Result<Option<String>, String> {
use winreg::enums::{HKEY_CURRENT_USER, KEY_READ, KEY_WRITE};
use winreg::RegKey;
use winreg::{
enums::{HKEY_CURRENT_USER, KEY_READ, KEY_WRITE},
RegKey,
};
let root = RegKey::predef(HKEY_CURRENT_USER);
let environment = root
@@ -372,13 +371,19 @@ fn get_windows_path_var() -> Result<Option<String>, String> {
#[cfg(windows)]
fn add_to_path(new_path: &str) -> bool {
use std::ptr;
use winapi::shared::minwindef::*;
use winapi::um::winuser::{
SendMessageTimeoutA, HWND_BROADCAST, SMTO_ABORTIFHUNG, WM_SETTINGCHANGE,
use {
std::ptr,
winapi::{
shared::minwindef::*,
um::winuser::{
SendMessageTimeoutA, HWND_BROADCAST, SMTO_ABORTIFHUNG, WM_SETTINGCHANGE,
},
},
winreg::{
enums::{RegType, HKEY_CURRENT_USER, KEY_READ, KEY_WRITE},
RegKey, RegValue,
},
};
use winreg::enums::{RegType, HKEY_CURRENT_USER, KEY_READ, KEY_WRITE};
use winreg::{RegKey, RegValue};
let old_path = if let Some(s) =
get_windows_path_var().unwrap_or_else(|err| panic!("Unable to get PATH: {}", err))

View File

@@ -2,9 +2,11 @@ use {
crate::update_manifest::UpdateManifest,
serde::{Deserialize, Serialize},
solana_sdk::pubkey::Pubkey,
std::fs::{create_dir_all, File},
std::io::{self, Write},
std::path::{Path, PathBuf},
std::{
fs::{create_dir_all, File},
io::{self, Write},
path::{Path, PathBuf},
},
};
#[derive(Serialize, Deserialize, Debug, PartialEq)]

View File

@@ -1,5 +1,4 @@
use std::io;
use std::process::Child;
use std::{io, process::Child};
fn kill_process(process: &mut Child) -> Result<(), io::Error> {
if let Ok(()) = process.kill() {
@@ -17,13 +16,19 @@ pub fn stop_process(process: &mut Child) -> Result<(), io::Error> {
#[cfg(not(windows))]
pub fn stop_process(process: &mut Child) -> Result<(), io::Error> {
use nix::errno::Errno::{EINVAL, EPERM, ESRCH};
use nix::sys::signal::{kill, Signal};
use nix::unistd::Pid;
use nix::Error::Sys;
use std::io::ErrorKind;
use std::thread;
use std::time::{Duration, Instant};
use {
nix::{
errno::Errno::{EINVAL, EPERM, ESRCH},
sys::signal::{kill, Signal},
unistd::Pid,
Error::Sys,
},
std::{
io::ErrorKind,
thread,
time::{Duration, Instant},
},
};
let nice_wait = Duration::from_secs(5);
let pid = Pid::from_raw(process.id() as i32);