@@ -190,10 +190,10 @@ pub trait EngineEnum: Copy {
190
190
191
191
/// The name of the enumerator, as it appears in Rust.
192
192
///
193
- /// Note that **this may not match the Rust constant name! ** In case of multiple constants with the same ordinal value, this method returns
194
- /// the first one in the order of definition. For example, `LayoutDirection::LOCALE.as_str()` (ord 1) returns `"APPLICATION_LOCALE"`, because
195
- /// that happens to be the first constant with ordinal `1`. See [`all_constants()`][Self::all_constants] for a more robust and general
196
- /// approach to introspection of enum constants.
193
+ /// Note that **this may not match the Rust constant name. ** In case of multiple constants with the same ordinal value, this method returns
194
+ /// the first one in the order of definition. For example, [ `LayoutDirection::LOCALE.as_str()`][crate::classes::window::LayoutDirection::LOCALE]
195
+ /// (ord 1) returns `"APPLICATION_LOCALE"`, because that happens to be the first constant with ordinal `1`.
196
+ /// See [`all_constants()`][Self::all_constants] for a more robust and general approach to introspection of enum constants.
197
197
///
198
198
/// If the value does not match one of the known enumerators, the empty string is returned.
199
199
fn as_str ( & self ) -> & ' static str ;
@@ -205,9 +205,10 @@ pub trait EngineEnum: Copy {
205
205
206
206
/// Returns a slice of distinct enum values.
207
207
///
208
- /// This excludes MAX constants and deduplicates aliases, providing only meaningful enum values.
208
+ /// This excludes `MAX` constants at the end (existing only to express the number of enumerators) and deduplicates aliases,
209
+ /// providing only meaningful enum values. See [`all_constants()`][Self::all_constants] for a complete list of all constants.
209
210
///
210
- /// This enables iteration over distinct enum variants:
211
+ /// Enables iteration over distinct enum variants:
211
212
/// ```no_run
212
213
/// use godot::classes::window;
213
214
/// use godot::obj::EngineEnum;
@@ -220,18 +221,19 @@ pub trait EngineEnum: Copy {
220
221
221
222
/// Returns metadata for all enum constants.
222
223
///
223
- /// This includes all constants as they appear in the enum definition, including duplicates and MAX constants.
224
+ /// This includes all constants as they appear in the enum definition, including duplicates and `MAX` constants.
225
+ /// For a list of useful, distinct values, use [`values()`][Self::values].
224
226
///
225
- /// This enables complete introspection and debugging :
227
+ /// Enables introspection of available constants :
226
228
/// ```no_run
227
229
/// use godot::classes::window;
228
230
/// use godot::obj::EngineEnum;
229
231
///
230
232
/// for constant in window::Mode::all_constants() {
231
- /// println!("* {}: {} (ord: {})",
233
+ /// println!("* window::Mode. {} (original {}) has ordinal value {}. ",
232
234
/// constant.rust_name(),
233
235
/// constant.godot_name(),
234
- /// constant.ord()
236
+ /// constant.value(). ord()
235
237
/// );
236
238
/// }
237
239
/// ```
@@ -254,6 +256,25 @@ pub trait EngineBitfield: Copy {
254
256
fn is_set ( self , flag : Self ) -> bool {
255
257
self . ord ( ) & flag. ord ( ) != 0
256
258
}
259
+
260
+ /// Returns metadata for all bitfield constants.
261
+ ///
262
+ /// This includes all constants as they appear in the bitfield definition.
263
+ ///
264
+ /// Enables introspection of available constants:
265
+ /// ```no_run
266
+ /// use godot::global::KeyModifierMask;
267
+ /// use godot::obj::EngineBitfield;
268
+ ///
269
+ /// for constant in KeyModifierMask::all_constants() {
270
+ /// println!("* KeyModifierMask.{} (original {}) has ordinal value {}.",
271
+ /// constant.rust_name(),
272
+ /// constant.godot_name(),
273
+ /// constant.value().ord()
274
+ /// );
275
+ /// }
276
+ /// ```
277
+ fn all_constants ( ) -> & ' static [ EnumConstant < Self > ] ;
257
278
}
258
279
259
280
/// Trait for enums that can be used as indices in arrays.
0 commit comments