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
use std::{ collections::hash_map::DefaultHasher, env, ffi::OsString, hash::{Hash, Hasher}, process::Command, }; #[cfg(feature = "big-num-32")] pub mod big_num_32; #[cfg(feature = "display-fn")] pub mod display_fn; #[cfg(feature = "io-fmt")] pub mod io_fmt; mod markup; pub use markup::Render; 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()) }