Enum Boundary
pub enum Boundary
Conditions for splitting an identifier into words.
Some boundaries, Hyphen, Underscore, and Space,
consume the character they split on, whereas the other boundaries do not.
Boundary includes methods that return useful groups of boundaries. It also
contains the defaults_from method which will generate a subset
of default boundaries based on the boundaries present in a string.
You can also create custom delimiter boundaries using the delim_boundary
macro or directly instantiate Boundary for complex boundary conditions.
use ;
assert_eq!;
let conv = new
.set_boundaries
.to_case;
assert_eq!;
Example
For more complex boundaries, such as splitting based on the first character being a certain symbol and the second is lowercase, you can instantiate a boundary directly.
# use ;
let at_then_letter = Custom ;
assert_eq!
Variants
-
Custom { condition: fn(&[&str]) -> bool, start: usize, len: usize } -
Hyphen Splits on
-, consuming the character on segmentation.# use Boundary; assert_eq!;-
Underscore Splits on
_, consuming the character on segmentation.# use Boundary; assert_eq!;-
Space Splits on space, consuming the character on segmentation.
# use Boundary; assert_eq!;-
UpperLower Splits where an uppercase letter is followed by a lowercase letter. This is seldom used, and is not included in the defaults.
# use Boundary; assert!;-
LowerUpper Splits where a lowercase letter is followed by an uppercase letter.
# use Boundary; assert_eq!;-
DigitUpper Splits where digit is followed by an uppercase letter.
# use Boundary; assert_eq!;-
UpperDigit Splits where an uppercase letter is followed by a digit.
# use Boundary; assert_eq!;-
DigitLower Splits where digit is followed by a lowercase letter.
# use Boundary; assert_eq!;-
LowerDigit Splits where a lowercase letter is followed by a digit.
# use Boundary; assert_eq!;-
Acronym Acronyms are identified by two uppercase letters followed by a lowercase letter. The word boundary is between the two uppercase letters. For example, "HTTPRequest" would have an acronym boundary identified at "PRe" and split into "HTTP" and "Request".
# use Boundary; assert_eq!;
Implementations
impl Boundary
fn matches(self, s: &[&str]) -> boolfn len(self) -> usizeThe number of graphemes consumed when splitting at the boundary.
fn start(self) -> usizeThe index of the character to split at.
const fn defaults() -> [Boundary; 9]The default list of boundaries used when
Casing::to_caseis called directly and in aConvertergenerated fromConverter::new().# use Boundary; assert_eq!;const fn digits() -> [Boundary; 4]Returns the boundaries that involve digits.
# use Boundary; assert_eq!;const fn letter_digit() -> [Boundary; 2]Returns the boundaries that are letters followed by digits.
# use Boundary; assert_eq!;const fn digit_letter() -> [Boundary; 2]Returns the boundaries that are digits followed by letters.
# use Boundary; assert_eq!;fn defaults_from(pattern: &str) -> Vec<Boundary>Returns a list of all boundaries that are identified within the given string. Could be a short of writing out all the boundaries in a list directly. This will not identify boundary
UpperLowerif it also used as part ofAcronym.If you want to be very explicit and not overlap boundaries, it is recommended to use a colon character.
# use Boundary; assert_eq!; assert_eq!;
Trait Implementations
impl Clone for Boundary
fn clone(&self) -> Boundary
impl Copy for Boundary
impl Debug for Boundary
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Boundary
impl Hash for Boundary
fn hash<__H: Hasher>(&self, state: &mut __H)
impl PartialEq for Boundary
fn eq(&self, other: &Boundary) -> bool
impl StructuralPartialEq for Boundary
Auto Trait Implementations
impl Freeze for Boundary
impl RefUnwindSafe for Boundary
impl Send for Boundary
impl Sync for Boundary
impl Unpin for Boundary
impl UnsafeUnpin for Boundary
impl UnwindSafe for Boundary
Blanket Implementations
impl<T> Any for Boundary
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Boundary
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Boundary
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Boundary
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Boundary
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Boundary
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Boundary
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Boundary
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for Boundary
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>