-
Notifications
You must be signed in to change notification settings - Fork 13.3k
os::mkdir and friends should maybe not take u32 #6085
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
What should it take instead of |
Here's some discussion from IRC
@thestinger has some opinions |
I think structs are better for flags, because you're not restricted to the pre-defined variants. It wouldn't be safe to OR enum variants together unless you added a variant for each combination ( It's much nicer to be able to do |
We might want to use @nikomatsakis' EnumSet: nikomatsakis@75df9af#L10L-1 |
Visiting for triage; still relevant. EnumSet still a viable solution. |
It's still taking |
I can take a shot at this. Is EnumSet still the way to go? And if so, would it need to be moved into libstd first? |
#8054 moved EnumSet to libextra. |
I'm interested in working on this. It looks like EnumSet has landed in core (Based on the hits for Is there anything special I should know before I dive in? (Found this as a result of digging through issues tagged easy to play with) |
I did some preliminary work to allow the use of I'll tentatively start work on porting the permission flags, and then rebase when I found out the fate of that PR. |
Is this still an issue? This commit moved the functionality from /cc @brson @alexcrichton |
While they've been changed to (updated title to be a bit more relevant) |
This patch changes `std::io::FilePermissions` from an exposed `u32` representation to a typesafe representation (that only allows valid flag combinations) using the `std::bitflags`, thus ensuring a greater degree of safety on the Rust side. Despite the change to the type, most code should continue to work as-is, sincde the new type provides bit operations in the style of C flags. To get at the underlying integer representation, use the `bits` method; to (unsafely) convert to `FilePermissions`, use `FilePermissions::from_bits`. Closes rust-lang#6085. [breaking-change]
The `std::bitflags::bitflags!` macro did not provide support for adding attributes to the generates structure, due to limitations in the parser for macros. This patch works around the parser limitations by requiring a `flags` keyword in the `bitflags!` invocations: bitflags!( #[deriving(Hash)] #[doc="Three flags"] flags Flags: u32 { FlagA = 0x00000001, FlagB = 0x00000010, FlagC = 0x00000100 } ) The intent of `std::bitflags` is to allow building type-safe wrappers around C-style flags APIs. But in addition to construction these flags from the Rust side, we need a way to convert them from the C side. This patch adds a `from_bits` function, which is unsafe since the bits in question may not represent a valid combination of flags. Finally, this patch changes `std::io::FilePermissions` from an exposed `u32` representation to a typesafe representation (that only allows valid flag combinations) using the `std::bitflags`. Closes #6085.
\o/ |
These are Rust functions, not C.
The text was updated successfully, but these errors were encountered: