ref_resolve_bytes/resolve_bytes_map
All checks were successful
buildbot/cargo fmt (1.72) Build done.
buildbot/cargo doc (1.72) Build done.
buildbot/cargo clippy (1.72) Build done.
buildbot/cargo test (1.65) Build done.
buildbot/cargo clippy (1.65) Build done.

This commit is contained in:
AF 2023-09-03 17:35:53 +00:00
parent c32c83de4f
commit a43f1dbf27
4 changed files with 14 additions and 3 deletions

View File

@ -26,6 +26,10 @@ pub trait OriginMap<'a, Ctx: Context<'a>>: Origin<'a, Ctx> {
self.clone().resolve()
}
fn ref_resolve_bytes(self: &Arc<Self>) -> HashResolution<'a, Ctx> {
self.clone().resolve_bytes()
}
fn resolve_map<T: 'a + Send>(
self: &Arc<Self>,
f: impl 'a + Send + FnOnce(ResolutionResult<'a, Ctx, Self::Mtbl>) -> T,
@ -35,6 +39,13 @@ pub trait OriginMap<'a, Ctx: Context<'a>>: Origin<'a, Ctx> {
{
Ctx::fmap(self.ref_resolve(), f)
}
fn resolve_bytes_map<T: 'a + Send>(
self: &Arc<Self>,
f: impl 'a + Send + FnOnce(HashResolutionResult<'a, Ctx>) -> T,
) -> Wrapped<'a, Ctx, T> {
Ctx::fmap(self.ref_resolve_bytes(), f)
}
}
impl<'a, Ctx: Context<'a>, R: ?Sized + Origin<'a, Ctx>> OriginMap<'a, Ctx> for R {}

View File

@ -201,7 +201,7 @@ fn cast_origin<'a, Ctx: CastCtx<'a>, A: Mentionable<'a, Ctx>>(
wrapped_origin(
factory.clone(),
move || cast_resolve(typeless_origin.clone(), factory.clone()),
move || origin_rb.clone().resolve_bytes(),
move || origin_rb.ref_resolve_bytes(),
)
}

View File

@ -12,7 +12,7 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> SingularResolution<'a, Ctx>
for Point<'a, Ctx, A>
{
fn singular(self: Arc<Self>) -> HashResolution<'a, Ctx> {
self.origin.clone().resolve_bytes()
self.origin.ref_resolve_bytes()
}
fn s_hash(&self) -> Hash {

View File

@ -39,7 +39,7 @@ pub trait MappableOrigin<'a, Ctx: Context<'a>>: Origin<'a, Ctx> {
let map_err = map_err.clone();
map_resolve(move || origin.ref_resolve(), map_ok, map_err)
}),
w_resolve_bytes: Box::new(move || origin_rb.clone().resolve_bytes()),
w_resolve_bytes: Box::new(move || origin_rb.ref_resolve_bytes()),
};
Arc::new(origin)
}