Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 //! # Target features
2 //! A database of target features available to the Rust compiler.
3 //!
4 #![doc = include_strrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include_str!!(concat!(env!("OUT_DIR"), "/generated.md"))]
5 #![no_std]
6
7 includerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include!!(concatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/concat!!(envrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/env!!("OUT_DIR"), "/generated.rs"));
8
9 /// List of features available for each architecture.
10 pub mod docsrust-analyzer cargo target-features 0.1.6 docs/ {
11 includerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/include!!(concatrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/concat!!(envrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/env!!("OUT_DIR"), "/docs.rs"));
12 }
13
14 mod simdrust-analyzer cargo target-features 0.1.6 simd/;
15 pub use simdrust-analyzer cargo target-features 0.1.6 simd/::*;
16
17 const fn str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(a: &str, b: &str) -> bool {
18 let a = a.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().();
19 let b = b.as_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_bytes().();
20
21 if a.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().b.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
22 return false;
23 }
24
25 let mut i = 0;
26 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().a.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
27 if a[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().b[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
28 return false;
29 }
30 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
31 }
32 true
33 }
34
35 /// A target architecture.
36 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
37 pub enum Architecturerust-analyzer cargo target-features 0.1.6 Architecture# {
38 /// Arm
39 Armrust-analyzer cargo target-features 0.1.6 Architecture#Arm#,
40 /// AArch64
41 AArch64rust-analyzer cargo target-features 0.1.6 Architecture#AArch64#,
42 /// BPF
43 Bpfrust-analyzer cargo target-features 0.1.6 Architecture#Bpf#,
44 /// Hexagon
45 Hexagonrust-analyzer cargo target-features 0.1.6 Architecture#Hexagon#,
46 /// MIPS
47 Mipsrust-analyzer cargo target-features 0.1.6 Architecture#Mips#,
48 /// PowerPC
49 PowerPCrust-analyzer cargo target-features 0.1.6 Architecture#PowerPC#,
50 /// RISC-V
51 RiscVrust-analyzer cargo target-features 0.1.6 Architecture#RiscV#,
52 /// WASM
53 Wasmrust-analyzer cargo target-features 0.1.6 Architecture#Wasm#,
54 /// x86 and x86-64
55 X86rust-analyzer cargo target-features 0.1.6 Architecture#X86#,
56 /// Another target, which doesn't have features
57 Unsupportedrust-analyzer cargo target-features 0.1.6 Architecture#Unsupported#,
58 }
59
60 impl Architecturerust-analyzer cargo target-features 0.1.6 Architecture# {
61 /// Create a new `Architecture` from its name.
62 pub const fn from_strrust-analyzer cargo target-features 0.1.6 impl#[Architecture]from_str().(architecture: &str) -> Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture] {
63 if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "arm") {
64 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::Armrust-analyzer cargo target-features 0.1.6 Architecture#Arm#
65 } else if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "aarch64") {
66 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::AArch64rust-analyzer cargo target-features 0.1.6 Architecture#AArch64#
67 } else if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "bpf") {
68 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::Bpfrust-analyzer cargo target-features 0.1.6 Architecture#Bpf#
69 } else if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "hexagon") {
70 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::Hexagonrust-analyzer cargo target-features 0.1.6 Architecture#Hexagon#
71 } else if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "mips") || str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "mips64") {
72 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::Mipsrust-analyzer cargo target-features 0.1.6 Architecture#Mips#
73 } else if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "powerpc") || str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "powerpc64") {
74 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::PowerPCrust-analyzer cargo target-features 0.1.6 Architecture#PowerPC#
75 } else if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "riscv32") || str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "riscv64") {
76 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::RiscVrust-analyzer cargo target-features 0.1.6 Architecture#RiscV#
77 } else if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "wasm32") || str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "wasm64") {
78 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::Wasmrust-analyzer cargo target-features 0.1.6 Architecture#Wasm#
79 } else if str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "x86") || str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(architecture, "x86_64") {
80 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::X86rust-analyzer cargo target-features 0.1.6 Architecture#X86#
81 } else {
82 Selfrust-analyzer cargo target-features 0.1.6 impl#[Architecture]::Unsupportedrust-analyzer cargo target-features 0.1.6 Architecture#Unsupported#
83 }
84 }
85 }
86
87 /// Returned by [`Feature::new`] when the requested feature can't be found.
88 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
89 pub struct UnknownFeaturerust-analyzer cargo target-features 0.1.6 UnknownFeature#;
90
91 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for UnknownFeaturerust-analyzer cargo target-features 0.1.6 UnknownFeature# {
92 fn fmtrust-analyzer cargo target-features 0.1.6 impl#[UnknownFeature][Display]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
93 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "unknown target feature")
94 }
95 }
96
97 /// Returned by [`Target::from_cpu`] when the requested CPU can't be found.
98 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
99 pub struct UnknownCpurust-analyzer cargo target-features 0.1.6 UnknownCpu#;
100
101 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for UnknownCpurust-analyzer cargo target-features 0.1.6 UnknownCpu# {
102 fn fmtrust-analyzer cargo target-features 0.1.6 impl#[UnknownCpu][Display]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
103 writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/write!!(f, "unknown target CPU")
104 }
105 }
106
107 /// A target feature.
108 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
109 pub struct Featurerust-analyzer cargo target-features 0.1.6 Feature#(usize);
110
111 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Featurerust-analyzer cargo target-features 0.1.6 Feature# {
112 fn fmtrust-analyzer cargo target-features 0.1.6 impl#[Feature][Debug]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> {
113 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Feature")
114 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("architecture", &self.architecturerust-analyzer cargo target-features 0.1.6 impl#[Feature]architecture().())
115 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("name", &self.namerust-analyzer cargo target-features 0.1.6 impl#[Feature]name().())
116 .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
117 }
118 }
119
120 impl Featurerust-analyzer cargo target-features 0.1.6 Feature# {
121 /// Look up a feature.
122 pub const fn newrust-analyzer cargo target-features 0.1.6 impl#[Feature]new().(architecture: Architecturerust-analyzer cargo target-features 0.1.6 Architecture#, feature: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo target-features 0.1.6 impl#[Feature], UnknownFeaturerust-analyzer cargo target-features 0.1.6 UnknownFeature#> {
123 let mut i = 0;
124 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
125 if (architecture as u8) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().(FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..0 as u8) && str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(feature, FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..1) {
126 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo target-features 0.1.6 impl#[Feature](i));
127 }
128 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
129 }
130
131 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(UnknownFeaturerust-analyzer cargo target-features 0.1.6 UnknownFeature#)
132 }
133
134 /// Get the name of the feature.
135 pub const fn namerust-analyzer cargo target-features 0.1.6 impl#[Feature]name().(&self) -> &'static str {
136 FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.0rust-analyzer cargo target-features 0.1.6 Feature#0.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..1
137 }
138
139 /// Get the architecture this feature is for.
140 pub const fn architecturerust-analyzer cargo target-features 0.1.6 impl#[Feature]architecture().(&self) -> Architecturerust-analyzer cargo target-features 0.1.6 Architecture# {
141 FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.0rust-analyzer cargo target-features 0.1.6 Feature#0.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..0
142 }
143
144 /// Get a human-readable description of the feature.
145 pub const fn descriptionrust-analyzer cargo target-features 0.1.6 impl#[Feature]description().(&self) -> &'static str {
146 FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.0rust-analyzer cargo target-features 0.1.6 Feature#0.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..2
147 }
148
149 /// Return all features which are implied by the existence of this feature.
150 ///
151 /// For example, "avx2" implies the existence of "avx" on x86 architectures.
152 pub const fn impliesrust-analyzer cargo target-features 0.1.6 impl#[Feature]implies().(&self) -> &'static [Featurerust-analyzer cargo target-features 0.1.6 Feature#] {
153 FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.0rust-analyzer cargo target-features 0.1.6 Feature#0.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..3
154 }
155 }
156
157 /// Iterator returned by [`Target::features`].
158 pub struct FeaturesIterrust-analyzer cargo target-features 0.1.6 FeaturesIter# {
159 targetrust-analyzer cargo target-features 0.1.6 FeaturesIter#target.: Targetrust-analyzer cargo target-features 0.1.6 Target#,
160 indexrust-analyzer cargo target-features 0.1.6 FeaturesIter#index.: usize,
161 }
162
163 impl Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator# for FeaturesIterrust-analyzer cargo target-features 0.1.6 FeaturesIter# {
164 type Itemrust-analyzer cargo target-features 0.1.6 impl#[FeaturesIter][Iterator]Item# = Featurerust-analyzer cargo target-features 0.1.6 Feature#;
165
166 fn nextrust-analyzer cargo target-features 0.1.6 impl#[FeaturesIter][Iterator]next().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Selfrust-analyzer cargo target-features 0.1.6 impl#[FeaturesIter][Iterator]::Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item#> {
167 while self.indexrust-analyzer cargo target-features 0.1.6 FeaturesIter#index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().self.targetrust-analyzer cargo target-features 0.1.6 FeaturesIter#target..featuresrust-analyzer cargo target-features 0.1.6 Target#features..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
168 let feature = if self.targetrust-analyzer cargo target-features 0.1.6 FeaturesIter#target..featuresrust-analyzer cargo target-features 0.1.6 Target#features.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().self.indexrust-analyzer cargo target-features 0.1.6 FeaturesIter#index.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
169 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Featurerust-analyzer cargo target-features 0.1.6 Feature#(self.indexrust-analyzer cargo target-features 0.1.6 FeaturesIter#index.))
170 } else {
171 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
172 };
173 self.indexrust-analyzer cargo target-features 0.1.6 FeaturesIter#index. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
174 if feature.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
175 return feature;
176 }
177 }
178 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#
179 }
180 }
181
182 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for Targetrust-analyzer cargo target-features 0.1.6 Target# {
183 fn fmtrust-analyzer cargo target-features 0.1.6 impl#[Target][Debug]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> {
184 struct FeaturesHelperrust-analyzer cargo target-features 0.1.6 FeaturesHelper#(Targetrust-analyzer cargo target-features 0.1.6 Target#);
185 impl corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug# for FeaturesHelperrust-analyzer cargo target-features 0.1.6 FeaturesHelper# {
186 fn fmtrust-analyzer cargo target-features 0.1.6 impl#[FeaturesHelper][Debug]fmt().(&self, f: &mut corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Error#> {
187 f.debug_listrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_list().().entriesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugList<'a, 'b>`]entries().(self.0rust-analyzer cargo target-features 0.1.6 FeaturesHelper#0..featuresrust-analyzer cargo target-features 0.1.6 impl#[Target]features().()).finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugList<'a, 'b>`]finish().()
188 }
189 }
190
191 f.debug_structrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/impl#[`Formatter<'a>`]debug_struct().("Target")
192 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("architecture", &self.architecturerust-analyzer cargo target-features 0.1.6 impl#[Target]architecture().())
193 .fieldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]field().("features", &FeaturesHelperrust-analyzer cargo target-features 0.1.6 FeaturesHelper#(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self))
194 .finishrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/builders/impl#[`DebugStruct<'a, 'b>`]finish().()
195 }
196 }
197
198 /// A target architecture with optional features.
199 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:)]
200 pub struct Targetrust-analyzer cargo target-features 0.1.6 Target# {
201 architecturerust-analyzer cargo target-features 0.1.6 Target#architecture.: Architecturerust-analyzer cargo target-features 0.1.6 Architecture#,
202 featuresrust-analyzer cargo target-features 0.1.6 Target#features.: [bool; FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES..len()],
203 }
204
205 impl Targetrust-analyzer cargo target-features 0.1.6 Target# {
206 /// Create a target with no specified features.
207 pub const fn newrust-analyzer cargo target-features 0.1.6 impl#[Target]new().(architecture: Architecturerust-analyzer cargo target-features 0.1.6 Architecture#) -> Selfrust-analyzer cargo target-features 0.1.6 impl#[Target] {
208 Selfrust-analyzer cargo target-features 0.1.6 impl#[Target] {
209 architecturerust-analyzer cargo target-features 0.1.6 Target#architecture.,
210 featuresrust-analyzer cargo target-features 0.1.6 Target#features.: [false; FEATURESrust-analyzer cargo target-features 0.1.6 FEATURES..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().()],
211 }
212 }
213
214 /// Create a target based on a particular CPU.
215 pub const fn from_cpurust-analyzer cargo target-features 0.1.6 impl#[Target]from_cpu().(architecture: Architecturerust-analyzer cargo target-features 0.1.6 Architecture#, cpu: &str) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo target-features 0.1.6 impl#[Target], UnknownCpurust-analyzer cargo target-features 0.1.6 UnknownCpu#> {
216 let mut target = Selfrust-analyzer cargo target-features 0.1.6 impl#[Target]::newrust-analyzer cargo target-features 0.1.6 impl#[Target]new().(architecture);
217 let mut i = 0;
218 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().CPUSrust-analyzer cargo target-features 0.1.6 CPUS..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
219 if architecture as u8 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().CPUSrust-analyzer cargo target-features 0.1.6 CPUS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..0 as u8 && str_eqrust-analyzer cargo target-features 0.1.6 str_eq().(cpu, CPUSrust-analyzer cargo target-features 0.1.6 CPUS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..1) {
220 let mut j = 0;
221 while j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().CPUSrust-analyzer cargo target-features 0.1.6 CPUS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..2.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
222 target = target.with_featurerust-analyzer cargo target-features 0.1.6 impl#[Target]with_feature().(CPUSrust-analyzer cargo target-features 0.1.6 CPUS.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..2[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().j]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().);
223 j rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
224 }
225 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(target);
226 }
227 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
228 }
229 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(UnknownCpurust-analyzer cargo target-features 0.1.6 UnknownCpu#)
230 }
231
232 /// Returns the target architecture.
233 pub const fn architecturerust-analyzer cargo target-features 0.1.6 impl#[Target]architecture().(&self) -> Architecturerust-analyzer cargo target-features 0.1.6 Architecture# {
234 self.architecturerust-analyzer cargo target-features 0.1.6 Target#architecture.
235 }
236
237 /// Returns an iterator over the features.
238 pub const fn featuresrust-analyzer cargo target-features 0.1.6 impl#[Target]features().(&self) -> FeaturesIterrust-analyzer cargo target-features 0.1.6 FeaturesIter# {
239 FeaturesIterrust-analyzer cargo target-features 0.1.6 FeaturesIter# {
240 targetrust-analyzer cargo target-features 0.1.6 FeaturesIter#target.: *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().self,
241 indexrust-analyzer cargo target-features 0.1.6 FeaturesIter#index.: 0,
242 }
243 }
244
245 /// Returns whether the target supports the specified feature.
246 pub const fn supports_featurerust-analyzer cargo target-features 0.1.6 impl#[Target]supports_feature().(&self, feature: Featurerust-analyzer cargo target-features 0.1.6 Feature#) -> bool {
247 self.featuresrust-analyzer cargo target-features 0.1.6 Target#features.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().feature.0rust-analyzer cargo target-features 0.1.6 Feature#0.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
248 }
249
250 /// Returns whether the target supports the specified feature.
251 ///
252 /// # Panics
253 /// Panics if the feature doesn't belong to the target architecture.
254 pub const fn supports_feature_strrust-analyzer cargo target-features 0.1.6 impl#[Target]supports_feature_str().(&self, feature: &str) -> bool {
255 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(feature) = Featurerust-analyzer cargo target-features 0.1.6 Feature#::newrust-analyzer cargo target-features 0.1.6 impl#[Feature]new().(self.architecturerust-analyzer cargo target-features 0.1.6 Target#architecture., feature) {
256 self.supports_featurerust-analyzer cargo target-features 0.1.6 impl#[Target]supports_feature().(feature)
257 } else {
258 panicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/panic!!("unknown feature");
259 }
260 }
261
262 /// Add a feature to the target.
263 ///
264 /// # Panics
265 /// Panics if the feature doesn't belong to the target architecture.
266 pub const fn with_featurerust-analyzer cargo target-features 0.1.6 impl#[Target]with_feature().(mut self, feature: Featurerust-analyzer cargo target-features 0.1.6 Feature#) -> Selfrust-analyzer cargo target-features 0.1.6 impl#[Target] {
267 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(feature.architecturerust-analyzer cargo target-features 0.1.6 impl#[Feature]architecture().() as u8 == self.architecturerust-analyzer cargo target-features 0.1.6 Target#architecture. as u8);
268 self.featuresrust-analyzer cargo target-features 0.1.6 Target#features.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().feature.0rust-analyzer cargo target-features 0.1.6 Feature#0.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = true;
269
270 let mut i = 0;
271 let implies = feature.impliesrust-analyzer cargo target-features 0.1.6 impl#[Feature]implies().();
272 while i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().implies.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() {
273 self.featuresrust-analyzer cargo target-features 0.1.6 Target#features.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().implies[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..0rust-analyzer cargo target-features 0.1.6 Feature#0.]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). = true;
274 i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().1;
275 }
276
277 self
278 }
279
280 /// Add a feature to the target.
281 ///
282 /// # Panics
283 /// Panics if the requested feature name doesn't exist for the target architecture.
284 pub const fn with_feature_strrust-analyzer cargo target-features 0.1.6 impl#[Target]with_feature_str().(self, feature: &str) -> Selfrust-analyzer cargo target-features 0.1.6 impl#[Target] {
285 if let Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(feature) = Featurerust-analyzer cargo target-features 0.1.6 Feature#::newrust-analyzer cargo target-features 0.1.6 impl#[Feature]new().(self.architecturerust-analyzer cargo target-features 0.1.6 Target#architecture., feature) {
286 self.with_featurerust-analyzer cargo target-features 0.1.6 impl#[Target]with_feature().(feature)
287 } else {
288 panicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/panic!!("unknown feature");
289 }
290 }
291 }