pub struct Name {
pub parts: Vec<String>,
}Expand description
A multi-part identifier that can be rendered in various casing conventions.
Name stores the identifier as individual lowercase words (parts). It is
created from a string in any common casing style (snake_case, camelCase,
PascalCase) and can be converted back to any of those forms.
§Examples
use toasty_core::schema::Name;
let name = Name::new("UserProfile");
assert_eq!(name.snake_case(), "user_profile");
assert_eq!(name.upper_camel_case(), "UserProfile");
assert_eq!(name.camel_case(), "userProfile");
assert_eq!(name.upper_snake_case(), "USER_PROFILE");Fields§
§parts: Vec<String>The individual lowercase word parts of this name.
Implementations§
Source§impl Name
impl Name
Sourcepub fn new(src: &str) -> Self
pub fn new(src: &str) -> Self
Creates a new Name by splitting src into word parts.
The input is first converted to snake_case, then split on underscores.
§Examples
use toasty_core::schema::Name;
let name = Name::new("myField");
assert_eq!(name.parts, vec!["my", "field"]);Sourcepub fn camel_case(&self) -> String
pub fn camel_case(&self) -> String
Returns this name in camelCase.
§Examples
use toasty_core::schema::Name;
assert_eq!(Name::new("user_id").camel_case(), "userId");Sourcepub fn upper_camel_case(&self) -> String
pub fn upper_camel_case(&self) -> String
Returns this name in UpperCamelCase (PascalCase).
§Examples
use toasty_core::schema::Name;
assert_eq!(Name::new("user_id").upper_camel_case(), "UserId");Sourcepub fn snake_case(&self) -> String
pub fn snake_case(&self) -> String
Returns this name in snake_case.
§Examples
use toasty_core::schema::Name;
assert_eq!(Name::new("UserProfile").snake_case(), "user_profile");Sourcepub fn upper_snake_case(&self) -> String
pub fn upper_snake_case(&self) -> String
Returns this name in UPPER_SNAKE_CASE.
§Examples
use toasty_core::schema::Name;
assert_eq!(Name::new("user_id").upper_snake_case(), "USER_ID");Trait Implementations§
impl Eq for Name
impl StructuralPartialEq for Name
Auto Trait Implementations§
impl Freeze for Name
impl RefUnwindSafe for Name
impl Send for Name
impl Sync for Name
impl Unpin for Name
impl UnwindSafe for Name
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.