Skip to content

Add const methods to ColorSpec#59

Open
Property404 wants to merge 2 commits intoBurntSushi:masterfrom
Property404:Property404/const-colorspec
Open

Add const methods to ColorSpec#59
Property404 wants to merge 2 commits intoBurntSushi:masterfrom
Property404:Property404/const-colorspec

Conversation

@Property404
Copy link

Can now do

const RED: ColorSpec = ColorSpec::new().with_fg(Some(Color::Red));

instead of

let mut red = ColorSpec::new();
let red = red.set_fg(Some(Color::Red));

This is a convenience because:

  • A ColorSpec can be defined in a single line
  • A ColorSpec can be defined once and used in multiple scopes, without using statics or struct literal syntax

@dimo414
Copy link

dimo414 commented Oct 5, 2022

The .with_ methods in particular would be great additions, thanks!

@Property404 Property404 force-pushed the Property404/const-colorspec branch from 46c0557 to 34b6100 Compare January 16, 2023 00:03
@Property404 Property404 force-pushed the Property404/const-colorspec branch 2 times, most recently from 28f5e85 to 2d27132 Compare November 14, 2023 03:36
@Property404 Property404 force-pushed the Property404/const-colorspec branch from 2d27132 to bba7346 Compare November 14, 2023 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants