1pub mod detection;
14pub mod target;
15
16#[cfg(feature = "nightly")]
17pub mod simd;
18
19pub use detection::{cpu_count, detect_host_architecture_only, detect_host_os};
21pub use target::{HOST_ARCH_LIST, Target, TargetArchitecture, TargetOperatingSystem};
22
23#[cfg(feature = "nightly")]
24pub use simd::{ArmSimdExtension, RiscvSimdExtension, SimdCapabilities, X86SimdExtension};
25
26#[cfg(test)]
27mod tests {
28 #![allow(clippy::expect_used)]
29
30 use super::*;
31 use std::str::FromStr;
32
33 #[test]
34 fn test_from_str_roundtrip() {
35 let host = Target::detect_host();
36 let str_repr = host.to_str();
37 let parsed_back = Target::from_str(&str_repr).expect("Valid target should parse");
38
39 assert_eq!(
40 host, parsed_back,
41 "from_str/to_str should be a roundtrip operation"
42 );
43 }
44
45 #[test]
46 fn test_detect_functions_consistency() {
47 let combined = Target::detect_host();
49 let arch_str = detect_host_architecture_only();
50 let os_str = detect_host_os();
51
52 assert_eq!(
53 combined.architecture,
54 TargetArchitecture::from_str(arch_str).unwrap_or(TargetArchitecture::Unknown)
55 );
56 assert_eq!(
57 combined.operating_system,
58 TargetOperatingSystem::from_str(os_str).unwrap_or(TargetOperatingSystem::Unknown)
59 );
60 }
61
62 #[cfg(feature = "nightly")]
63 #[test]
64 fn test_target_simd_capabilities() {
65 let target = Target::detect_host();
66 let caps = target.simd_capabilities();
67 assert!(caps.max_vector_width <= 2048);
69 }
70}