pub struct FloatRange {
pub min: Option<f64>,
pub max: Option<f64>,
pub min_open: bool,
pub max_open: bool,
pub clamp: bool,
}Expand description
A floating-point type restricted to a range of values.
If min or max are None, the range is unbounded in that direction.
If clamp is true, out-of-range values are clamped to the boundary
instead of producing an error. Note: clamping is not supported with
open bounds.
Fields§
§min: Option<f64>Minimum allowed value (inclusive unless min_open is true).
max: Option<f64>Maximum allowed value (inclusive unless max_open is true).
min_open: boolIf true, the minimum bound is exclusive (value must be > min).
max_open: boolIf true, the maximum bound is exclusive (value must be < max).
clamp: boolIf true, clamp out-of-range values instead of failing. Not supported with open bounds.
Implementations§
Source§impl FloatRange
impl FloatRange
Sourcepub fn min_open(self, open: bool) -> Self
pub fn min_open(self, open: bool) -> Self
Make the minimum bound exclusive (value must be > min).
§Panics
Panics if clamping is enabled, as clamping is not supported for open bounds.
Trait Implementations§
Source§impl Clone for FloatRange
impl Clone for FloatRange
Source§fn clone(&self) -> FloatRange
fn clone(&self) -> FloatRange
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for FloatRange
Source§impl Debug for FloatRange
impl Debug for FloatRange
Source§impl Default for FloatRange
impl Default for FloatRange
Source§impl TypeConverter for FloatRange
impl TypeConverter for FloatRange
Source§fn convert(&self, value: &str) -> Result<Self::Value, String>
fn convert(&self, value: &str) -> Result<Self::Value, String>
Convert a string value to the target type. Read more
Source§fn get_metavar(&self) -> Option<String>
fn get_metavar(&self) -> Option<String>
Returns the metavar for this type (used in help text). Read more
Source§fn get_missing_message(&self) -> Option<String>
fn get_missing_message(&self) -> Option<String>
Returns an optional message when a required value is missing.
Source§fn split_envvar_value(&self, value: &str) -> Vec<String>
fn split_envvar_value(&self, value: &str) -> Vec<String>
Split an environment variable value into multiple values. Read more
Source§fn shell_complete(&self, _incomplete: &str) -> Vec<CompletionItem>
fn shell_complete(&self, _incomplete: &str) -> Vec<CompletionItem>
Returns shell completion items for the given incomplete value. Read more
Source§fn is_composite(&self) -> bool
fn is_composite(&self) -> bool
Whether this type is a composite type (like Tuple).
Auto Trait Implementations§
impl Freeze for FloatRange
impl RefUnwindSafe for FloatRange
impl Send for FloatRange
impl Sync for FloatRange
impl Unpin for FloatRange
impl UnsafeUnpin for FloatRange
impl UnwindSafe for FloatRange
Blanket Implementations§
Source§impl<T> AnyTypeConverter for T
impl<T> AnyTypeConverter for T
Source§fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Sync + Send>, String>
fn convert_any(&self, value: &str) -> Result<Box<dyn Any + Sync + Send>, String>
Convert a string value to the target type, returning as Box.
Source§fn convert_multi(
&self,
values: &[String],
) -> Result<Box<dyn Any + Sync + Send>, String>
fn convert_multi( &self, values: &[String], ) -> Result<Box<dyn Any + Sync + Send>, String>
Convert multiple string values to the target type, returning as Box. Read more
Source§fn get_metavar(&self) -> Option<String>
fn get_metavar(&self) -> Option<String>
Returns the metavar for this type.
Source§fn split_envvar_value(&self, value: &str) -> Vec<String>
fn split_envvar_value(&self, value: &str) -> Vec<String>
Split an environment variable value into multiple values.
Source§fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
fn shell_complete(&self, incomplete: &str) -> Vec<CompletionItem>
Returns shell completion items for the given incomplete value.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more