Skip to main content

Module stdx

Module stdx 

Source
Expand description

stdx module provides utilities and extensions for working with Rust’s standard library.

§Submodules

  • error: It defines custom errors present in the stdx module.
  • primitive_number: It is dedicated to working with numbers, providing useful types or complementary methods.
  • collections: It is dedicated to collections, providing utilities for iteration, transformation or validation.
  • string: It is dedicated to strings, providing useful types or complementary methods.
  • extension: Contains utilities for working with scope functions like closures and higher-order functions and additional utilities for some <type|struct> manipulation.

§Usage

Import the specific functionality required into your project, e.g.:

use catalyser::stdx::{
    extension::{
        str_extension::MultilineStr,
        scope_functions_extension::TakeIf
    },
    collections::NonEmptyVec,
    primitive_number::BoundedI32,
    string::NonEmptyString
};

let non_empty_string = NonEmptyString::new("hello world".to_string());
let bounded_i32 = BoundedI32::<-10,10>::new(0)
    .take_if(|it| it.is_ok());
let non_empty_vec = NonEmptyVec::new(vec![0, 1, 2, 3]);
let multiline_string = "\
    |Indented line 1
    |Indented line 2
".trim_margin();

Modules§

collections
This module defines a generic wrapper, NonEmptyCollection, to ensure that collections are non-empty. It provides implementations for commonly used Rust collections, such as HashSet, Vec, VecDeque, BTreeMap, and others, and verifies their non-empty nature at runtime.
error
This module defines custom errors present in the stdx module.
extension
extension module provides utilities and extensions for working with Rust’s standard library.
primitive_number
This module provides a mechanism to define and work with numeric types that are bounded between a specified minimum and maximum value, both for integer and floating-point types. This ensures that invalid values outside the range are caught at runtime, providing additional safety and correctness in computations.
string
This module provides functionality for working with validated strings in a type-safe manner, ensuring that strings adhere to specific content rules during their creation and use.