use alloc::{
borrow::ToOwned,
string::{String, ToString},
};
usecrate::{capitalize, transform};
/// This trait defines a title case conversion. /// /// In Title Case, word boundaries are indicated by spaces, and every word is /// capitalized. /// /// ## Example: /// /// ```rust /// use heck::ToTitleCase; /// /// let sentence = "We have always lived in slums and holes in the wall."; /// assert_eq!(sentence.to_title_case(), "We Have Always Lived In Slums And Holes In The Wall"); /// ``` pubtrait ToTitleCase: ToOwned { /// Convert this type to title case. fn to_title_case(&self) -> Self::Owned;
}
/// This wrapper performs a title case conversion in [`fmt::Display`]. /// /// ## Example: /// /// ``` /// use heck::AsTitleCase; /// /// let sentence = "We have always lived in slums and holes in the wall."; /// assert_eq!(format!("{}", AsTitleCase(sentence)), "We Have Always Lived In Slums And Holes In The Wall"); /// ``` pubstruct AsTitleCase<T: AsRef<str>>(pub T);
t!(test1: "CamelCase" => "Camel Case");
t!(test2: "This is Human case." => "This Is Human Case");
t!(test3: "MixedUP CamelCase, with some Spaces" => "Mixed Up Camel Case With Some Spaces");
t!(test4: "mixed_up_ snake_case, with some _spaces" => "Mixed Up Snake Case With Some Spaces");
t!(test5: "kebab-case" => "Kebab Case");
t!(test6: "SHOUTY_SNAKE_CASE" => "Shouty Snake Case");
t!(test7: "snake_case" => "Snake Case");
t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "This Contains All Kinds Of Word Boundaries");
t!(test9: "XΣXΣ baffle" => "Xσxς Baffle");
t!(test10: "XMLHttpRequest" => "Xml Http Request");
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet am 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.