File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -449,15 +449,30 @@ impl<'cfg> ConfigEntry<'cfg> {
449
449
/// Gets the value of this entry.
450
450
///
451
451
/// May return `None` if the value is not valid utf-8
452
+ ///
453
+ /// # Panics
454
+ ///
455
+ /// Panics when no value is defined.
452
456
pub fn value ( & self ) -> Option < & str > {
453
457
str:: from_utf8 ( self . value_bytes ( ) ) . ok ( )
454
458
}
455
459
456
460
/// Gets the value of this entry as a byte slice.
461
+ ///
462
+ /// # Panics
463
+ ///
464
+ /// Panics when no value is defined.
457
465
pub fn value_bytes ( & self ) -> & [ u8 ] {
458
466
unsafe { crate :: opt_bytes ( self , ( * self . raw ) . value ) . unwrap ( ) }
459
467
}
460
468
469
+ /// Returns `true` when a value is defined otherwise `false`.
470
+ ///
471
+ /// No value defined is a short-hand to represent a Boolean `true`.
472
+ pub fn has_value ( & self ) -> bool {
473
+ unsafe { !( * self . raw ) . value . is_null ( ) }
474
+ }
475
+
461
476
/// Gets the configuration level of this entry.
462
477
pub fn level ( & self ) -> ConfigLevel {
463
478
unsafe { ConfigLevel :: from_raw ( ( * self . raw ) . level ) }
You can’t perform that action at this time.
0 commit comments