From 479afb1463007fa0a157b3bb0c38afb1b82b5090 Mon Sep 17 00:00:00 2001 From: Vitaly Bogdanov Date: Tue, 24 Sep 2024 10:43:33 +0300 Subject: [PATCH] Fix SpaceMut::as_space signature to reflect lifetimes properly --- c/src/space.rs | 2 +- lib/src/space/grounding.rs | 2 +- lib/src/space/mod.rs | 4 ++-- lib/src/space/module.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/c/src/space.rs b/c/src/space.rs index 15194a611..8518aa808 100644 --- a/c/src/space.rs +++ b/c/src/space.rs @@ -827,7 +827,7 @@ impl SpaceMut for CSpace { let from: atom_ref_t = from.into(); (api.replace)(&self.params, &from, to.into()) } - fn as_space(&self) -> &dyn Space { + fn as_space<'a>(&self) -> &(dyn Space + 'a) { self } } diff --git a/lib/src/space/grounding.rs b/lib/src/space/grounding.rs index caa31b4e4..b3a7d3ea9 100644 --- a/lib/src/space/grounding.rs +++ b/lib/src/space/grounding.rs @@ -336,7 +336,7 @@ impl SpaceMut for GroundingSpace { fn replace(&mut self, from: &Atom, to: Atom) -> bool { GroundingSpace::replace(self, from, to) } - fn as_space(&self) -> &dyn Space { + fn as_space<'a>(&self) -> &(dyn Space + 'a) { self } } diff --git a/lib/src/space/mod.rs b/lib/src/space/mod.rs index 7a664d6b4..5930a6ef4 100644 --- a/lib/src/space/mod.rs +++ b/lib/src/space/mod.rs @@ -257,7 +257,7 @@ pub trait SpaceMut: Space { /// Turn a &dyn SpaceMut into an &dyn Space. Obsolete when Trait Upcasting is stabilized. /// [Rust issue #65991](https://github.com/rust-lang/rust/issues/65991) Any month now. - fn as_space(&self) -> &dyn Space; + fn as_space<'a>(&self) -> &(dyn Space + 'a); } #[derive(Clone)] @@ -305,7 +305,7 @@ impl SpaceMut for DynSpace { fn replace(&mut self, from: &Atom, to: Atom) -> bool { self.0.borrow_mut().replace(from, to) } - fn as_space(&self) -> &dyn Space { + fn as_space<'a>(&self) -> &(dyn Space + 'a) { self } } diff --git a/lib/src/space/module.rs b/lib/src/space/module.rs index de407b565..f01eb229c 100644 --- a/lib/src/space/module.rs +++ b/lib/src/space/module.rs @@ -84,7 +84,7 @@ impl SpaceMut for ModuleSpace { fn replace(&mut self, from: &Atom, to: Atom) -> bool { self.main.replace(from, to) } - fn as_space(&self) -> &dyn Space { + fn as_space<'a>(&self) -> &(dyn Space + 'a) { self } }