pub struct LineLength(/* private fields */);Expand description
A line length value that can be 0 (meaning no limit) or a positive value (≥1)
Many configuration values for line length need to support both:
- 0: Special value meaning “no line length limit”
- ≥1: Actual line length limit
This type enforces those constraints at deserialization time.
Implementations§
Source§impl LineLength
impl LineLength
Sourcepub fn new(value: usize) -> Self
pub fn new(value: usize) -> Self
Create a new LineLength, where 0 means no limit and values ≥1 are actual limits.
Sourcepub fn get(self) -> usize
pub fn get(self) -> usize
Get the underlying value (0 for no limit, otherwise the actual limit).
Sourcepub fn is_unlimited(self) -> bool
pub fn is_unlimited(self) -> bool
Check if this represents “no limit” (value was 0).
Sourcepub fn effective_limit(self) -> usize
pub fn effective_limit(self) -> usize
Get the effective limit for comparisons. Returns usize::MAX for unlimited, otherwise the actual limit.
Sourcepub const fn from_const(value: usize) -> Self
pub const fn from_const(value: usize) -> Self
Convert from a default value (for use in config defaults).
§Panics
Never panics - accepts any value including 0.
Trait Implementations§
Source§impl Clone for LineLength
impl Clone for LineLength
Source§fn clone(&self) -> LineLength
fn clone(&self) -> LineLength
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LineLength
impl Debug for LineLength
Source§impl Default for LineLength
impl Default for LineLength
Source§impl<'de> Deserialize<'de> for LineLength
We don’t need a separate error type since LineLength accepts all values.
The validation is implicit in the conversion.
impl<'de> Deserialize<'de> for LineLength
We don’t need a separate error type since LineLength accepts all values. The validation is implicit in the conversion.
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for LineLength
impl Display for LineLength
Source§impl From<LineLength> for usize
impl From<LineLength> for usize
Source§fn from(val: LineLength) -> Self
fn from(val: LineLength) -> Self
Converts to this type from the input type.
Source§impl Hash for LineLength
impl Hash for LineLength
Source§impl JsonSchema for LineLength
impl JsonSchema for LineLength
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Ord for LineLength
impl Ord for LineLength
Source§fn cmp(&self, other: &LineLength) -> Ordering
fn cmp(&self, other: &LineLength) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for LineLength
impl PartialEq for LineLength
Source§impl PartialOrd for LineLength
impl PartialOrd for LineLength
Source§impl Serialize for LineLength
impl Serialize for LineLength
impl Copy for LineLength
impl Eq for LineLength
impl StructuralPartialEq for LineLength
Auto Trait Implementations§
impl Freeze for LineLength
impl RefUnwindSafe for LineLength
impl Send for LineLength
impl Sync for LineLength
impl Unpin for LineLength
impl UnwindSafe for LineLength
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more