Skip to content

Commit

Permalink
feat: Make the constructors for Event const
Browse files Browse the repository at this point in the history
This allows the Event struct to be used in constants.

Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun authored Aug 22, 2023
1 parent c7cc91a commit d8595b5
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ pub struct EventExtra {
impl EventExtra {
/// Create an empty version of the data.
#[inline]
pub fn empty() -> EventExtra {
pub const fn empty() -> EventExtra {
EventExtra {
flags: epoll::EventFlags::empty(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/iocp/afd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl AfdPollMask {
pub(crate) const CONNECT_FAIL: AfdPollMask = AfdPollMask(0x100);

/// Creates an empty mask.
pub(crate) fn empty() -> AfdPollMask {
pub(crate) const fn empty() -> AfdPollMask {
AfdPollMask(0)
}

Expand Down
2 changes: 1 addition & 1 deletion src/iocp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ pub struct EventExtra {
impl EventExtra {
/// Create a new, empty version of this struct.
#[inline]
pub fn empty() -> EventExtra {
pub const fn empty() -> EventExtra {
EventExtra {
flags: AfdPollMask::empty(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub struct EventExtra;
impl EventExtra {
/// Create a new, empty version of this struct.
#[inline]
pub fn empty() -> EventExtra {
pub const fn empty() -> EventExtra {
EventExtra
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl Event {
/// All kinds of events (readable and writable).
///
/// Equivalent to: `Event { key, readable: true, writable: true }`
pub fn all(key: usize) -> Event {
pub const fn all(key: usize) -> Event {
Event {
key,
readable: true,
Expand All @@ -198,7 +198,7 @@ impl Event {
/// Only the readable event.
///
/// Equivalent to: `Event { key, readable: true, writable: false }`
pub fn readable(key: usize) -> Event {
pub const fn readable(key: usize) -> Event {
Event {
key,
readable: true,
Expand All @@ -210,7 +210,7 @@ impl Event {
/// Only the writable event.
///
/// Equivalent to: `Event { key, readable: false, writable: true }`
pub fn writable(key: usize) -> Event {
pub const fn writable(key: usize) -> Event {
Event {
key,
readable: false,
Expand All @@ -222,7 +222,7 @@ impl Event {
/// No events.
///
/// Equivalent to: `Event { key, readable: false, writable: false }`
pub fn none(key: usize) -> Event {
pub const fn none(key: usize) -> Event {
Event {
key,
readable: false,
Expand Down
2 changes: 1 addition & 1 deletion src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ pub struct EventExtra {
impl EventExtra {
/// Creates an empty set of extra information.
#[inline]
pub fn empty() -> Self {
pub const fn empty() -> Self {
Self {
flags: PollFlags::empty(),
}
Expand Down
2 changes: 1 addition & 1 deletion src/port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ pub struct EventExtra {
impl EventExtra {
/// Create a new, empty version of this struct.
#[inline]
pub fn empty() -> EventExtra {
pub const fn empty() -> EventExtra {
EventExtra {
flags: PollFlags::empty(),
}
Expand Down

0 comments on commit d8595b5

Please sign in to comment.