feat: Make the constructors for Event const

This allows the Event struct to be used in constants.

Signed-off-by: tison <wander4096@gmail.com>
This commit is contained in:
tison 2023-08-22 09:32:21 +08:00 committed by GitHub
parent c7cc91a1f1
commit d8595b56a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 10 deletions

View File

@ -337,7 +337,7 @@ pub struct EventExtra {
impl EventExtra { impl EventExtra {
/// Create an empty version of the data. /// Create an empty version of the data.
#[inline] #[inline]
pub fn empty() -> EventExtra { pub const fn empty() -> EventExtra {
EventExtra { EventExtra {
flags: epoll::EventFlags::empty(), flags: epoll::EventFlags::empty(),
} }

View File

@ -81,7 +81,7 @@ impl AfdPollMask {
pub(crate) const CONNECT_FAIL: AfdPollMask = AfdPollMask(0x100); pub(crate) const CONNECT_FAIL: AfdPollMask = AfdPollMask(0x100);
/// Creates an empty mask. /// Creates an empty mask.
pub(crate) fn empty() -> AfdPollMask { pub(crate) const fn empty() -> AfdPollMask {
AfdPollMask(0) AfdPollMask(0)
} }

View File

@ -651,7 +651,7 @@ pub struct EventExtra {
impl EventExtra { impl EventExtra {
/// Create a new, empty version of this struct. /// Create a new, empty version of this struct.
#[inline] #[inline]
pub fn empty() -> EventExtra { pub const fn empty() -> EventExtra {
EventExtra { EventExtra {
flags: AfdPollMask::empty(), flags: AfdPollMask::empty(),
} }

View File

@ -268,7 +268,7 @@ pub struct EventExtra;
impl EventExtra { impl EventExtra {
/// Create a new, empty version of this struct. /// Create a new, empty version of this struct.
#[inline] #[inline]
pub fn empty() -> EventExtra { pub const fn empty() -> EventExtra {
EventExtra EventExtra
} }

View File

@ -186,7 +186,7 @@ impl Event {
/// All kinds of events (readable and writable). /// All kinds of events (readable and writable).
/// ///
/// Equivalent to: `Event { key, readable: true, writable: true }` /// Equivalent to: `Event { key, readable: true, writable: true }`
pub fn all(key: usize) -> Event { pub const fn all(key: usize) -> Event {
Event { Event {
key, key,
readable: true, readable: true,
@ -198,7 +198,7 @@ impl Event {
/// Only the readable event. /// Only the readable event.
/// ///
/// Equivalent to: `Event { key, readable: true, writable: false }` /// Equivalent to: `Event { key, readable: true, writable: false }`
pub fn readable(key: usize) -> Event { pub const fn readable(key: usize) -> Event {
Event { Event {
key, key,
readable: true, readable: true,
@ -210,7 +210,7 @@ impl Event {
/// Only the writable event. /// Only the writable event.
/// ///
/// Equivalent to: `Event { key, readable: false, writable: true }` /// Equivalent to: `Event { key, readable: false, writable: true }`
pub fn writable(key: usize) -> Event { pub const fn writable(key: usize) -> Event {
Event { Event {
key, key,
readable: false, readable: false,
@ -222,7 +222,7 @@ impl Event {
/// No events. /// No events.
/// ///
/// Equivalent to: `Event { key, readable: false, writable: false }` /// Equivalent to: `Event { key, readable: false, writable: false }`
pub fn none(key: usize) -> Event { pub const fn none(key: usize) -> Event {
Event { Event {
key, key,
readable: false, readable: false,

View File

@ -398,7 +398,7 @@ pub struct EventExtra {
impl EventExtra { impl EventExtra {
/// Creates an empty set of extra information. /// Creates an empty set of extra information.
#[inline] #[inline]
pub fn empty() -> Self { pub const fn empty() -> Self {
Self { Self {
flags: PollFlags::empty(), flags: PollFlags::empty(),
} }

View File

@ -221,7 +221,7 @@ pub struct EventExtra {
impl EventExtra { impl EventExtra {
/// Create a new, empty version of this struct. /// Create a new, empty version of this struct.
#[inline] #[inline]
pub fn empty() -> EventExtra { pub const fn empty() -> EventExtra {
EventExtra { EventExtra {
flags: PollFlags::empty(), flags: PollFlags::empty(),
} }