Skip to content

Commit

Permalink
feat: impl std::ops::BitOr<Signal> for SigSet
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWoollett-Light committed Oct 1, 2023
1 parent a24a74f commit 3a45608
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
([#1959](https://github.com/nix-rust/nix/pull/1959))
- Added `impl std::ops::BitOr for Signal`.
([#1959](https://github.com/nix-rust/nix/pull/1959))
- Added `impl std::ops::BitOr<Signal> for SigSet`
([#1959](https://github.com/nix-rust/nix/pull/1959))

### Changed

Expand Down
16 changes: 12 additions & 4 deletions src/sys/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use cfg_if::cfg_if;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::mem;
use std::ops::BitOr;
#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))]
use std::os::unix::io::RawFd;
use std::ptr;
Expand Down Expand Up @@ -612,11 +613,9 @@ impl From<Signal> for SigSet {
}
}


impl std::ops::BitOr for Signal {
impl BitOr for Signal {
type Output = SigSet;

// rhs is the "right-hand side" of the expression `a | b`
fn bitor(self, rhs: Self) -> Self::Output {
let mut sigset = SigSet::empty();
sigset.add(self);
Expand All @@ -625,7 +624,16 @@ impl std::ops::BitOr for Signal {
}
}

impl std::ops::BitOr for SigSet {
impl BitOr<Signal> for SigSet {
type Output = SigSet;

fn bitor(mut self, rhs: Signal) -> Self::Output {
self.add(rhs);
self
}
}

impl BitOr for SigSet {
type Output = Self;

fn bitor(self, rhs: Self) -> Self::Output {
Expand Down

0 comments on commit 3a45608

Please sign in to comment.