Skip to content

Commit

Permalink
relax unnecessarily restricted lifetime
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Dec 1, 2024
1 parent 1d7904e commit 332fdc9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion gen/src/airline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct ModeColors<'a> {

#[derive(Debug)]
pub struct AirlineTheme<'a> {
palette: &'a Palette,
palette: &'a Palette<'a>,
modes: HashMap<&'a str, ModeColors<'a>>,
paste: &'a str,
info_mod: &'a str,
Expand Down
2 changes: 1 addition & 1 deletion gen/src/alacritty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type Color<'a> = (&'a str, &'a str); // Pair of foreground/background colors

#[derive(Debug)]
pub struct AlacrittyTheme<'a> {
palette: &'a Palette,
palette: &'a Palette<'a>,
background: &'a str,
dim: AnsiColors<'a>,
normal: AnsiColors<'a>,
Expand Down
2 changes: 1 addition & 1 deletion gen/src/colorscheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn indent(level: u8) -> &'static str {

#[derive(Debug)]
pub struct Colorscheme<'a> {
palette: &'a Palette,
palette: &'a Palette<'a>,
highlights: &'a [Highlight],
term_colors: [&'static str; 16],
}
Expand Down
18 changes: 9 additions & 9 deletions gen/src/palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::fmt::Display;
use std::ops::Deref;

#[derive(Debug, PartialEq)]
pub struct Color {
pub gui: ColorCode<&'static str>,
pub struct Color<'a> {
pub gui: ColorCode<&'a str>,
pub cterm: ColorCode<u8>,
}

Expand All @@ -23,26 +23,26 @@ impl<T: Display> ColorCode<T> {
}
}

type Colors = HashMap<&'static str, Color>;
type Colors<'a> = HashMap<&'a str, Color<'a>>;

#[derive(Debug)]
pub struct Palette(Colors);
pub struct Palette<'a>(Colors<'a>);

impl Deref for Palette {
type Target = Colors;
impl<'a> Deref for Palette<'a> {
type Target = Colors<'a>;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl From<Colors> for Palette {
fn from(m: Colors) -> Self {
impl<'a> From<Colors<'a>> for Palette<'a> {
fn from(m: Colors<'a>) -> Self {
Self(m)
}
}

impl Default for Palette {
impl<'a> Default for Palette<'a> {
#[rustfmt::skip]
fn default() -> Self {
use ColorCode::{Normal, Contrast};
Expand Down

0 comments on commit 332fdc9

Please sign in to comment.