This repository has been archived on 2026-08-31. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
donglora/vendor/heck/src/upper_camel.rs
T
swaitsandClaude Opus 4.6 3102fc747a feat: add display UI with splash screen, dashboard, and RSSI sparkline
Implement full SSD1306 OLED display support:
- Splash screen on boot (1.5s) with project name, version, board
- Dashboard showing radio state, config, counters, RSSI/SNR
- RSSI history sparkline (64-sample ring buffer, 2px-wide bars)
- DisplayOn/DisplayOff host commands routed via dedicated channel
- Pure render functions against generic DrawTarget (no hardware coupling)
- Display on/off control bypasses radio task entirely

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 20:42:54 -06:00

89 lines
2.5 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
use core::fmt;
use alloc::{
borrow::ToOwned,
string::{String, ToString},
};
use crate::{capitalize, transform};
/// This trait defines an upper camel case conversion.
///
/// In UpperCamelCase, word boundaries are indicated by capital letters,
/// including the first word.
///
/// ## Example:
///
/// ```rust
/// use heck::ToUpperCamelCase;
///
/// let sentence = "We are not in the least afraid of ruins.";
/// assert_eq!(sentence.to_upper_camel_case(), "WeAreNotInTheLeastAfraidOfRuins");
/// ```
pub trait ToUpperCamelCase: ToOwned {
/// Convert this type to upper camel case.
fn to_upper_camel_case(&self) -> Self::Owned;
}
impl ToUpperCamelCase for str {
fn to_upper_camel_case(&self) -> String {
AsUpperCamelCase(self).to_string()
}
}
/// `ToPascalCase` is an alias for [`ToUpperCamelCase`]. See ToUpperCamelCase for more
/// documentation.
pub trait ToPascalCase: ToOwned {
/// Convert this type to upper camel case.
fn to_pascal_case(&self) -> Self::Owned;
}
impl<T: ?Sized + ToUpperCamelCase> ToPascalCase for T {
fn to_pascal_case(&self) -> Self::Owned {
self.to_upper_camel_case()
}
}
/// This wrapper performs a upper camel case conversion in [`fmt::Display`].
///
/// ## Example:
///
/// ```
/// use heck::AsUpperCamelCase;
///
/// let sentence = "We are not in the least afraid of ruins.";
/// assert_eq!(format!("{}", AsUpperCamelCase(sentence)), "WeAreNotInTheLeastAfraidOfRuins");
/// ```
pub struct AsUpperCamelCase<T: AsRef<str>>(pub T);
impl<T: AsRef<str>> fmt::Display for AsUpperCamelCase<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
transform(self.0.as_ref(), capitalize, |_| Ok(()), f)
}
}
#[cfg(test)]
mod tests {
use super::ToUpperCamelCase;
macro_rules! t {
($t:ident : $s1:expr => $s2:expr) => {
#[test]
fn $t() {
assert_eq!($s1.to_upper_camel_case(), $s2)
}
};
}
t!(test1: "CamelCase" => "CamelCase");
t!(test2: "This is Human case." => "ThisIsHumanCase");
t!(test3: "MixedUP_CamelCase, with some Spaces" => "MixedUpCamelCaseWithSomeSpaces");
t!(test4: "mixed_up_ snake_case, with some _spaces" => "MixedUpSnakeCaseWithSomeSpaces");
t!(test5: "kebab-case" => "KebabCase");
t!(test6: "SHOUTY_SNAKE_CASE" => "ShoutySnakeCase");
t!(test7: "snake_case" => "SnakeCase");
t!(test8: "this-contains_ ALLKinds OfWord_Boundaries" => "ThisContainsAllKindsOfWordBoundaries");
t!(test9: "XΣXΣ baffle" => "XσxςBaffle");
t!(test10: "XMLHttpRequest" => "XmlHttpRequest");
}