Skip to content

std: Deprecate 'x'/'X'/'e'/'E' special cases for u8 slices #8007

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

Merged
merged 1 commit into from
Mar 1, 2021

Conversation

LemonBoy
Copy link
Contributor

Let's follow the road paved by the removal of 'z'/'Z', the Formatter
pattern is nice enough to let us remove the remaining four special cases
and declare u8 slices free from any special casing!

@marler8997
Copy link
Contributor

Maybe x and X are common enough to remain?

@LemonBoy
Copy link
Contributor Author

No.

@LemonBoy
Copy link
Contributor Author

Rebased, note that this reverts #8031 as the deprecation warnings were added (and removed) within the same release.

Let's follow the road paved by the removal of 'z'/'Z', the Formatter
pattern is nice enough to let us remove the remaining four special cases
and declare u8 slices free from any special casing!

/// Return a Formatter for a []const u8 where every byte is formatted as a pair
/// of uppercase hexadecimal digits.
pub fn fmtSliceHexUpper(bytes: []const u8) std.fmt.Formatter(formatSliceHexUpper) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't love that we have different functions for this for upper vs lower case.
Could we instead take the case as an argument?

pub fn fmtSliceHex(bytes: []const u8, case: enum{Upper, Lower}) std.fmt.Formatter(formatSliceHex) {

Copy link
Contributor Author

@LemonBoy LemonBoy Mar 2, 2021

Choose a reason for hiding this comment

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

No strong opinion on having a single formatter, I went with two separate ones to keep it close to the x / X.

(IIRC there's a stage1 bug regarding comptime anonymous enum arguments, check out #3707)

@andrewrk andrewrk added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library. labels Mar 1, 2021
@andrewrk andrewrk merged commit cd7c870 into ziglang:master Mar 1, 2021
LemonBoy added a commit to LemonBoy/zig that referenced this pull request Mar 6, 2021
Following ziglang#8007 and ziglang#8137 let's get rid of the last weird format.
LemonBoy added a commit to LemonBoy/zig that referenced this pull request Mar 6, 2021
Following ziglang#8007 and ziglang#8137 let's get rid of the last weird format.
LemonBoy added a commit to LemonBoy/zig that referenced this pull request Mar 6, 2021
Following ziglang#8007 and ziglang#8137 let's get rid of the last weird format.
Vexu pushed a commit that referenced this pull request Mar 7, 2021
Following #8007 and #8137 let's get rid of the last weird format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants