Skip to content

Commit 29efe8c

Browse files
committed
Add #[inline] to trivial functions on core::sync::Exclusive
1 parent 9279c54 commit 29efe8c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

library/core/src/sync/exclusive.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,15 @@ impl<T: Sized> Exclusive<T> {
100100
/// Wrap a value in an `Exclusive`
101101
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
102102
#[must_use]
103+
#[inline]
103104
pub const fn new(t: T) -> Self {
104105
Self { inner: t }
105106
}
106107

107108
/// Unwrap the value contained in the `Exclusive`
108109
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
109110
#[must_use]
111+
#[inline]
110112
pub const fn into_inner(self) -> T {
111113
self.inner
112114
}
@@ -116,6 +118,7 @@ impl<T: ?Sized> Exclusive<T> {
116118
/// Get exclusive access to the underlying value.
117119
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
118120
#[must_use]
121+
#[inline]
119122
pub const fn get_mut(&mut self) -> &mut T {
120123
&mut self.inner
121124
}
@@ -128,6 +131,7 @@ impl<T: ?Sized> Exclusive<T> {
128131
/// produce _pinned_ access to the underlying value.
129132
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
130133
#[must_use]
134+
#[inline]
131135
pub const fn get_pin_mut(self: Pin<&mut Self>) -> Pin<&mut T> {
132136
// SAFETY: `Exclusive` can only produce `&mut T` if itself is unpinned
133137
// `Pin::map_unchecked_mut` is not const, so we do this conversion manually
@@ -139,6 +143,7 @@ impl<T: ?Sized> Exclusive<T> {
139143
/// building an `Exclusive` with [`Exclusive::new`].
140144
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
141145
#[must_use]
146+
#[inline]
142147
pub const fn from_mut(r: &'_ mut T) -> &'_ mut Exclusive<T> {
143148
// SAFETY: repr is ≥ C, so refs have the same layout; and `Exclusive` properties are `&mut`-agnostic
144149
unsafe { &mut *(r as *mut T as *mut Exclusive<T>) }
@@ -149,6 +154,7 @@ impl<T: ?Sized> Exclusive<T> {
149154
/// building an `Exclusive` with [`Exclusive::new`].
150155
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
151156
#[must_use]
157+
#[inline]
152158
pub const fn from_pin_mut(r: Pin<&'_ mut T>) -> Pin<&'_ mut Exclusive<T>> {
153159
// SAFETY: `Exclusive` can only produce `&mut T` if itself is unpinned
154160
// `Pin::map_unchecked_mut` is not const, so we do this conversion manually
@@ -158,6 +164,7 @@ impl<T: ?Sized> Exclusive<T> {
158164

159165
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
160166
impl<T> From<T> for Exclusive<T> {
167+
#[inline]
161168
fn from(t: T) -> Self {
162169
Self::new(t)
163170
}
@@ -166,7 +173,7 @@ impl<T> From<T> for Exclusive<T> {
166173
#[unstable(feature = "exclusive_wrapper", issue = "98407")]
167174
impl<T: Future + ?Sized> Future for Exclusive<T> {
168175
type Output = T::Output;
169-
176+
#[inline]
170177
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
171178
self.get_pin_mut().poll(cx)
172179
}

0 commit comments

Comments
 (0)