Skip to content

Commit e8ba20c

Browse files
committed
Remove Trait constraint for Port::new()
Signed-off-by: Joe Richey <[email protected]>
1 parent 5ee0802 commit e8ba20c

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

src/instructions/port.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -100,37 +100,37 @@ impl PortReadWrite for u32 {}
100100

101101
/// A read only I/O port.
102102
#[derive(Debug, Clone, PartialEq, Eq)]
103-
pub struct PortReadOnly<T: PortRead> {
103+
pub struct PortReadOnly<T> {
104104
port: u16,
105105
phantom: PhantomData<T>,
106106
}
107107

108108
/// A write only I/O port.
109109
#[derive(Debug, Clone, PartialEq, Eq)]
110-
pub struct PortWriteOnly<T: PortWrite> {
110+
pub struct PortWriteOnly<T> {
111111
port: u16,
112112
phantom: PhantomData<T>,
113113
}
114114

115115
/// An I/O port.
116116
#[derive(Debug, Clone, PartialEq, Eq)]
117-
pub struct Port<T: PortReadWrite> {
117+
pub struct Port<T> {
118118
port: u16,
119119
phantom: PhantomData<T>,
120120
}
121121

122-
impl<T: PortRead> PortReadOnly<T> {
123-
const_fn! {
124-
/// Creates a read only I/O port with the given port number.
125-
#[inline]
126-
pub fn new(port: u16) -> PortReadOnly<T> {
127-
PortReadOnly {
128-
port,
129-
phantom: PhantomData,
130-
}
122+
impl<T> PortReadOnly<T> {
123+
/// Creates a read only I/O port with the given port number.
124+
#[inline]
125+
pub const fn new(port: u16) -> PortReadOnly<T> {
126+
PortReadOnly {
127+
port,
128+
phantom: PhantomData,
131129
}
132130
}
131+
}
133132

133+
impl<T: PortRead> PortReadOnly<T> {
134134
/// Reads from the port.
135135
///
136136
/// ## Safety
@@ -143,18 +143,18 @@ impl<T: PortRead> PortReadOnly<T> {
143143
}
144144
}
145145

146-
impl<T: PortWrite> PortWriteOnly<T> {
147-
const_fn! {
148-
/// Creates a write only I/O port with the given port number.
149-
#[inline]
150-
pub fn new(port: u16) -> PortWriteOnly<T> {
151-
PortWriteOnly {
152-
port,
153-
phantom: PhantomData,
154-
}
146+
impl<T> PortWriteOnly<T> {
147+
/// Creates a write only I/O port with the given port number.
148+
#[inline]
149+
pub const fn new(port: u16) -> PortWriteOnly<T> {
150+
PortWriteOnly {
151+
port,
152+
phantom: PhantomData,
155153
}
156154
}
155+
}
157156

157+
impl<T: PortWrite> PortWriteOnly<T> {
158158
/// Writes to the port.
159159
///
160160
/// ## Safety
@@ -167,18 +167,18 @@ impl<T: PortWrite> PortWriteOnly<T> {
167167
}
168168
}
169169

170-
impl<T: PortReadWrite> Port<T> {
171-
const_fn! {
172-
/// Creates an I/O port with the given port number.
173-
#[inline]
174-
pub fn new(port: u16) -> Port<T> {
175-
Port {
176-
port,
177-
phantom: PhantomData,
178-
}
170+
impl<T> Port<T> {
171+
/// Creates an I/O port with the given port number.
172+
#[inline]
173+
pub const fn new(port: u16) -> Port<T> {
174+
Port {
175+
port,
176+
phantom: PhantomData,
179177
}
180178
}
179+
}
181180

181+
impl<T: PortReadWrite> Port<T> {
182182
/// Reads from the port.
183183
///
184184
/// ## Safety

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! and access to various system registers.
33
44
#![cfg_attr(not(test), no_std)]
5-
#![cfg_attr(feature = "const_fn", feature(const_fn))]
5+
#![cfg_attr(feature = "const_fn", feature(const_fn))] // Needed for generic access to associated consts
66
#![cfg_attr(feature = "const_fn", feature(const_mut_refs))]
77
#![cfg_attr(feature = "const_fn", feature(const_fn_fn_ptr_basics))]
88
#![cfg_attr(feature = "const_fn", feature(const_in_array_repeat_expressions))]

0 commit comments

Comments
 (0)