rust icon indicating copy to clipboard operation
rust copied to clipboard

os::mkdir and friends should maybe not take u32

Open brson opened this issue 13 years ago • 14 comments

These are Rust functions, not C.

brson avatar Apr 26 '13 23:04 brson

What should it take instead of c_int?

sammykim avatar May 08 '13 04:05 sammykim

Here's some discussion from IRC

22:05 < strcat> brson: well, ideally not an enum
22:05 <@brson> yichoi: graydon could disagree though. I'm not sure what his vision for that module is and 
               he usually likes less abstraction than I
22:05 < strcat> we just need a flag type with | overloaded
22:05 < strcat> and some constants
22:05 < strcat> casting to an int to OR them would be annoying

@thestinger has some opinions

brson avatar May 08 '13 05:05 brson

@thestinger refered https://github.com/thestinger/rust-magic/commit/16a4fe0505f3c35cd4fa8fb051a5e6f396d2b2eb

yichoi avatar May 08 '13 05:05 yichoi

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 (match assumes it knows all of the variants, and so do the loads in the IR now).

It's much nicer to be able to do let base = FlagA | FlagC | FlagE and then call a function with base | FlagB than building up vectors.

thestinger avatar May 08 '13 06:05 thestinger

We might want to use @nikomatsakis' EnumSet: https://github.com/nikomatsakis/rust/commit/75df9af9b5b56ea931059298930254d26466667c#L10L-1

brson avatar May 08 '13 18:05 brson

Visiting for triage; still relevant. EnumSet still a viable solution.

emberian avatar Jul 12 '13 19:07 emberian

It's still taking c_int and remains an issue.

sammykim avatar Sep 03 '13 05:09 sammykim

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?

martindemello avatar Sep 25 '13 03:09 martindemello

#8054 moved EnumSet to libextra.

sanxiyn avatar Oct 21 '13 05:10 sanxiyn

I'm interested in working on this. It looks like EnumSet has landed in core (Based on the hits for git grep EnumSet in the main repo).

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)

richo avatar Mar 29 '14 11:03 richo

I did some preliminary work to allow the use of EnumSet in std here: #13196

I'll tentatively start work on porting the permission flags, and then rebase when I found out the fate of that PR.

richo avatar Mar 29 '14 13:03 richo

Is this still an issue? This commit moved the functionality from os to std::io::fs and converted to u32 values with explicit flag constants. Do we want to replace this with something like the bitflags! macro?

/cc @brson @alexcrichton

aturon avatar Apr 25 '14 18:04 aturon

While they've been changed to u32, it's not clear (at least to me) that this is the correct type to use for these flags. One could imagine a bit set (using some primitive construct), but I'm not entirely convinced that it's the best representation either.

(updated title to be a bit more relevant)

alexcrichton avatar Apr 25 '14 18:04 alexcrichton

\o/

richo avatar May 06 '14 21:05 richo