mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +02:00
sync: add ?Sized bound to {MutexGuard,OwnedMutexGuard}::map (#5997)
This commit is contained in:
@@ -846,6 +846,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn map<U, F>(mut this: Self, f: F) -> MappedMutexGuard<'a, U>
|
pub fn map<U, F>(mut this: Self, f: F) -> MappedMutexGuard<'a, U>
|
||||||
where
|
where
|
||||||
|
U: ?Sized,
|
||||||
F: FnOnce(&mut T) -> &mut U,
|
F: FnOnce(&mut T) -> &mut U,
|
||||||
{
|
{
|
||||||
let data = f(&mut *this) as *mut U;
|
let data = f(&mut *this) as *mut U;
|
||||||
@@ -894,6 +895,7 @@ impl<'a, T: ?Sized> MutexGuard<'a, T> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_map<U, F>(mut this: Self, f: F) -> Result<MappedMutexGuard<'a, U>, Self>
|
pub fn try_map<U, F>(mut this: Self, f: F) -> Result<MappedMutexGuard<'a, U>, Self>
|
||||||
where
|
where
|
||||||
|
U: ?Sized,
|
||||||
F: FnOnce(&mut T) -> Option<&mut U>,
|
F: FnOnce(&mut T) -> Option<&mut U>,
|
||||||
{
|
{
|
||||||
let data = match f(&mut *this) {
|
let data = match f(&mut *this) {
|
||||||
@@ -1026,6 +1028,7 @@ impl<T: ?Sized> OwnedMutexGuard<T> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn map<U, F>(mut this: Self, f: F) -> OwnedMappedMutexGuard<T, U>
|
pub fn map<U, F>(mut this: Self, f: F) -> OwnedMappedMutexGuard<T, U>
|
||||||
where
|
where
|
||||||
|
U: ?Sized,
|
||||||
F: FnOnce(&mut T) -> &mut U,
|
F: FnOnce(&mut T) -> &mut U,
|
||||||
{
|
{
|
||||||
let data = f(&mut *this) as *mut U;
|
let data = f(&mut *this) as *mut U;
|
||||||
@@ -1074,6 +1077,7 @@ impl<T: ?Sized> OwnedMutexGuard<T> {
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_map<U, F>(mut this: Self, f: F) -> Result<OwnedMappedMutexGuard<T, U>, Self>
|
pub fn try_map<U, F>(mut this: Self, f: F) -> Result<OwnedMappedMutexGuard<T, U>, Self>
|
||||||
where
|
where
|
||||||
|
U: ?Sized,
|
||||||
F: FnOnce(&mut T) -> Option<&mut U>,
|
F: FnOnce(&mut T) -> Option<&mut U>,
|
||||||
{
|
{
|
||||||
let data = match f(&mut *this) {
|
let data = match f(&mut *this) {
|
||||||
|
|||||||
Reference in New Issue
Block a user