Skip to content

*Flags don't implement set-like combinators #609

@cyphar

Description

@cyphar

One thing I ran into almost immediately when trying to nicely define a set of flags like you would in C (with something like CLONE_NEWUSER|CLONE_NEWUTS|CLONE_NEWNS or whatever) is that you can't do it with the nix structs without declaring a variable mut and operating on it.

let mut sigmask = signal::SigSet::empty();
sigmask.add(signal::Signal::SIGTTOU);
sigmask.add(signal::Signal::SIGTTIN);
// etc

What if we made it so you could do this instead?

let sigmask = signal::SigSet::empty()
                             .add(signal::Signal::SIGTTOU)
                             .add(signal::Signal::SIGTTIN);

Which allows you to write it (IMO) more concisely but also doesn't mean that you have to make the variable mutable. It also better matches the Iterator combinators.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions