1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
pub use std::fmt::Error; use std::{ collections::hash_map::DefaultHasher, env, ffi::OsString, hash::{Hash, Hasher}, process::Command, }; pub type Result<I> = ::std::result::Result<I, Error>; #[cfg(feature = "config")] pub mod config; #[cfg(feature = "config")] pub mod recompile; #[cfg(any( feature = "big-num-32", feature = "display-fn", feature = "io-fmt", feature = "markup", ))] pub mod helpers; pub fn calculate_hash<T: Hash>(t: &T) -> u64 { let mut s = DefaultHasher::new(); t.hash(&mut s); s.finish() } pub fn definitely_not_nightly() -> bool { let mut cmd = Command::new(cargo_binary()); cmd.arg("--version"); let output = match cmd.output() { Ok(output) => output, Err(_) => return false, }; let version = match String::from_utf8(output.stdout) { Ok(version) => version, Err(_) => return false, }; version.starts_with("cargo 1") && !version.contains("nightly") } fn cargo_binary() -> OsString { env::var_os("CARGO").unwrap_or_else(|| "cargo".to_owned().into()) }