chore: add more CompactString::const_new instead of new (#1230)

This commit is contained in:
Josh McKinney 2024-07-15 20:29:32 -07:00 committed by GitHub
parent 6d210b3b6b
commit 7bab9f0d80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -41,7 +41,7 @@ impl Cell {
/// ///
/// This works at compile time and puts the symbol onto the stack. Fails to build when the /// This works at compile time and puts the symbol onto the stack. Fails to build when the
/// symbol doesnt fit onto the stack and requires to be placed on the heap. Use /// symbol doesnt fit onto the stack and requires to be placed on the heap. Use
/// `Self::default().set_symbol()` in that case. See [`CompactString::new_inline`] for more /// `Self::default().set_symbol()` in that case. See [`CompactString::const_new`] for more
/// details on this. /// details on this.
pub const fn new(symbol: &'static str) -> Self { pub const fn new(symbol: &'static str) -> Self {
Self { Self {
@ -139,7 +139,7 @@ impl Cell {
/// Resets the cell to the empty state. /// Resets the cell to the empty state.
pub fn reset(&mut self) { pub fn reset(&mut self) {
self.symbol = CompactString::new(" "); self.symbol = CompactString::const_new(" ");
self.fg = Color::Reset; self.fg = Color::Reset;
self.bg = Color::Reset; self.bg = Color::Reset;
#[cfg(feature = "underline-color")] #[cfg(feature = "underline-color")]
@ -167,7 +167,7 @@ mod tests {
assert_eq!( assert_eq!(
cell, cell,
Cell { Cell {
symbol: CompactString::new(""), symbol: CompactString::const_new(""),
fg: Color::Reset, fg: Color::Reset,
bg: Color::Reset, bg: Color::Reset,
#[cfg(feature = "underline-color")] #[cfg(feature = "underline-color")]