Skip to content

Commit

Permalink
fixup! try_map_guardからT: 'staticを外す
Browse files Browse the repository at this point in the history
  • Loading branch information
qryxip committed Sep 18, 2024
1 parent b01afb0 commit aed651b
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions crates/voicevox_core/src/__internal/interop/raii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,34 @@ pub enum MaybeClosed<T> {
// [`mapped_lock_guards`]のようなことをやるためのユーティリティ。
//
// [`mapped_lock_guards`]: https://github.com/rust-lang/rust/issues/117108
pub fn try_map_guard<'lock, 'target, G, F, T, E>(
guard: G,
f: F,
) -> Result<impl Deref<Target = T> + 'lock, E>
pub fn try_map_guard<'lock, G, F, T, E>(guard: G, f: F) -> Result<impl Deref<Target = T> + 'lock, E>
where
'target: 'lock,
G: 'lock,
F: FnOnce(&G) -> Result<&T, E>,
T: 'target,
T: 'lock,
{
return MappedLockTryBuilder {
guard,
content_builder: f,
target_builder: f,
marker: PhantomData,
}
.try_build();

#[self_referencing]
struct MappedLock<'lock, 'target, G: 'lock, T: 'target> {
struct MappedLock<'lock, G: 'lock, T> {
guard: G,

#[borrows(guard)]
content: &'this T,
target: &'this T,

marker: PhantomData<&'lock &'target ()>,
marker: PhantomData<&'lock T>,
}

impl<'lock, 'target, G: 'lock, T: 'target> Deref for MappedLock<'lock, 'target, G, T> {
impl<'lock, G: 'lock, T: 'lock> Deref for MappedLock<'lock, G, T> {
type Target = T;

fn deref(&self) -> &Self::Target {
self.borrow_content()
self.borrow_target()
}
}
}

0 comments on commit aed651b

Please sign in to comment.