Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hex support #200

Merged
merged 8 commits into from
Mar 4, 2025
Merged

Add hex support #200

merged 8 commits into from
Mar 4, 2025

Conversation

gorilskij
Copy link
Contributor

Add support for hex strings ("#abc" or "#abcdef") in place of color names when using .color(...). For example

"this will be pink".color("#efabea")

The case of the hex string is ignored. If an invalid hex string is passed (including missing #), the color defaults to white.

Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Great idea!

@gorilskij gorilskij requested a review from spenserblack March 3, 2025 17:04
@spenserblack
Copy link
Collaborator

Thank you!

@spenserblack spenserblack added the bump-minor New non-breaking features label Mar 3, 2025
@gorilskij
Copy link
Contributor Author

Tbh I don't understand the semver issue, I didn't add or change any #[must_use] attributes.

@spenserblack
Copy link
Collaborator

Tbh I don't understand the semver issue, I didn't add or change any #[must_use] attributes.

No worries, you didn't do anything wrong. It reports a failure whenever the semver is not bumped appropriately from the last release, as far as I understand it. So it will almost always fail on new feature PRs, since we don't bump the version until right before release. Or, more accurately, bumping the version triggers a release, so we can't bump it until we're ready to release.

Because we assert length, we can index directly into strings. Also,
since we're already checking for the string to start with `#`, we can
drop that first character so simplify parsing.
@spenserblack spenserblack merged commit b780cf2 into colored-rs:master Mar 4, 2025
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump-minor New non-breaking features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants