Vendor things
This commit is contained in:
parent
5deceec006
commit
977e3c17e5
19434 changed files with 10682014 additions and 0 deletions
46
third-party/vendor/Inflector/src/string/demodulize/mod.rs
vendored
Normal file
46
third-party/vendor/Inflector/src/string/demodulize/mod.rs
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#[cfg(feature = "heavyweight")]
|
||||
use cases::classcase::to_class_case;
|
||||
|
||||
#[cfg(feature = "heavyweight")]
|
||||
/// Demodulize a `&str`
|
||||
///
|
||||
/// ```
|
||||
/// use inflector::string::demodulize::demodulize;
|
||||
/// let mock_string: &str = "Bar";
|
||||
/// let expected_string: String = "Bar".to_owned();
|
||||
/// let asserted_string: String = demodulize(mock_string);
|
||||
/// assert!(asserted_string == expected_string);
|
||||
///
|
||||
/// ```
|
||||
/// ```
|
||||
/// use inflector::string::demodulize::demodulize;
|
||||
/// let mock_string: &str = "::Bar";
|
||||
/// let expected_string: String = "Bar".to_owned();
|
||||
/// let asserted_string: String = demodulize(mock_string);
|
||||
/// assert!(asserted_string == expected_string);
|
||||
///
|
||||
/// ```
|
||||
/// ```
|
||||
/// use inflector::string::demodulize::demodulize;
|
||||
/// let mock_string: &str = "Foo::Bar";
|
||||
/// let expected_string: String = "Bar".to_owned();
|
||||
/// let asserted_string: String = demodulize(mock_string);
|
||||
/// assert!(asserted_string == expected_string);
|
||||
///
|
||||
/// ```
|
||||
/// ```
|
||||
/// use inflector::string::demodulize::demodulize;
|
||||
/// let mock_string: &str = "Test::Foo::Bar";
|
||||
/// let expected_string: String = "Bar".to_owned();
|
||||
/// let asserted_string: String = demodulize(mock_string);
|
||||
/// assert!(asserted_string == expected_string);
|
||||
///
|
||||
/// ```
|
||||
pub fn demodulize(non_demodulize_string: &str) -> String {
|
||||
if non_demodulize_string.contains("::") {
|
||||
let split_string: Vec<&str> = non_demodulize_string.split("::").collect();
|
||||
to_class_case(split_string[split_string.len() - 1])
|
||||
} else {
|
||||
non_demodulize_string.to_owned()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue