pub struct LowerCamel<P>(/* private fields */);Expand description
A case adapter for a character profile that accepts uncased and lowercase characters on the first character of a chunk or identifier.
§Note
If you’re using the regular unicode profile, it’s possible that you can construct valid strings which appear to break the requirements of this type.
use typed_ident::presets::unicode::LowerCamelIdent;
assert!(LowerCamelIdent::new("_A").is_err()); // Doesn't work (expected).
assert!(LowerCamelIdent::new("_゙A").is_ok()); // Works?The payload provided for that second case is:
_(U+005F) LOW LINE゙(U+3099) COMBINING KATAKANA-HIRAGANA VOICED SOUND MARKA(U+0041) LATIN CAPITAL LETTER A
The way to prevent this is to disallow Mn/Mc/Me characters on chunk start.
You can get a profile which does this by enabling unicode-strict. This
will enable the Strict profile which can be used directly - or if you
have presets enabled - used indirectly through strict presets.
use typed_ident::presets::strict::LowerCamelIdent;
assert!(LowerCamelIdent::new("_A").is_err()); // Doesn't work (expected).
assert!(LowerCamelIdent::new("_゙A").is_err()); // Now it doesn't work!See Strict for more details on when you should do this.
Trait Implementations§
impl<P: CharProfile> CasedProfile for LowerCamel<P>
Source§impl<P: CharProfile> Profile for LowerCamel<P>
impl<P: CharProfile> Profile for LowerCamel<P>
Source§const APPEND_CLOSED: AppendClosed
const APPEND_CLOSED: AppendClosed
LowerCamel cannot be append-closed for >=Fragment, because
is_chunk_start is not identical to is_chunk_continue.
See Profile::APPEND_CLOSED for details.
Source§type BaseProfile = P
type BaseProfile = P
Source§type Segmentation = <P as Profile>::Segmentation
type Segmentation = <P as Profile>::Segmentation
Source§fn is_ident_start(c: char) -> bool
fn is_ident_start(c: char) -> bool
Source§fn is_chunk_start(c: char) -> bool
fn is_chunk_start(c: char) -> bool
Source§fn in_profile(c: char) -> bool
fn in_profile(c: char) -> bool
Source§fn is_chunk_continue(c: char) -> bool
fn is_chunk_continue(c: char) -> bool
impl<Superset, Subset> SubsetOf<LowerCamel<Superset>> for Lower<Subset>
Proof: If Super ⊆ Subset, then LowerCamel<Super> ⊆ Lower<Subset>
(because LowerCamel ⊆ Lower).
Let’s pretend that Superset=Unicode, and Subset=Ascii.
If Ascii: SubsetOf<Unicode> (true), then this implies the following:
Lower<Ascii>: SubsetOf<LowerCamel<Unicode>>
§Proof
left_is_subset_of_right::<Lower<Ascii>, LowerCamel<Ascii>>();
left_is_subset_of_right::<Lower<Unicode>, LowerCamel<Unicode>>();
left_is_subset_of_right::<Lower<Ascii>, LowerCamel<Unicode>>();impl<Superset, Subset> SubsetOf<LowerCamel<Superset>> for LowerCamel<Subset>
Proof: If Super ⊆ Subset, then LowerCamel<Super> ⊆ LowerCamel<Subset>.
Let’s pretend that Superset=Unicode, and Subset=Ascii.
If Ascii: SubsetOf<Unicode> (true), then this implies the following:
LowerCamel<Ascii>: SubsetOf<LowerCamel<Unicode>>
§Proof
left_is_subset_of_right::<LowerCamel<Ascii>, LowerCamel<Ascii>>();
left_is_subset_of_right::<LowerCamel<Unicode>, LowerCamel<Unicode>>();
left_is_subset_of_right::<LowerCamel<Ascii>, LowerCamel<Unicode>>();impl<Superset, Subset> SubsetOf<Superset> for LowerCamel<Subset>
Proof: If Super ⊆ Subset, then Super ⊆ LowerCamel<Subset>.
Let’s pretend that Superset=Unicode, and Subset=Ascii.
If Ascii: SubsetOf<Unicode> (true), then this implies the following:
LowerCamel<Ascii>: SubsetOf<Unicode>
§Proof
left_is_subset_of_right::<LowerCamel<Ascii>, Ascii>();
left_is_subset_of_right::<LowerCamel<Unicode>, Unicode>();
left_is_subset_of_right::<LowerCamel<Ascii>, Unicode>();