use std::marker::PhantomData;
use std::sync::Arc;
use super::record::ResolutionCertainty;
#[derive(Debug)]
pub(crate) struct BuilderBrand;
#[derive(Clone, Debug)]
pub struct Handle<K> {
brand: Arc<BuilderBrand>,
index: u32,
kind: PhantomData<fn() -> K>,
}
impl<K> Handle<K> {
pub(crate) fn new(brand: &Arc<BuilderBrand>, index: u32) -> Self {
Self {
brand: Arc::clone(brand),
index,
kind: PhantomData,
}
}
pub(crate) fn resolve(&self, brand: &Arc<BuilderBrand>) -> Option<u32> {
Arc::ptr_eq(&self.brand, brand).then_some(self.index)
}
}
#[derive(Clone, Debug)]
pub struct UnitHandleKind;
#[derive(Clone, Debug)]
pub struct DefinitionHandleKind;
#[derive(Clone, Debug)]
pub struct ReferenceHandleKind;
pub type ResolutionUnitHandle = Handle<UnitHandleKind>;
pub type DefinitionHandle = Handle<DefinitionHandleKind>;
pub type ReferenceHandle = Handle<ReferenceHandleKind>;
#[derive(Clone, Debug)]
pub struct CandidateInput {
definition: DefinitionHandle,
certainty: ResolutionCertainty,
}
impl CandidateInput {
pub fn new(definition: DefinitionHandle, certainty: ResolutionCertainty) -> Self {
Self {
definition,
certainty,
}
}
pub(crate) fn into_parts(self) -> (DefinitionHandle, ResolutionCertainty) {
(self.definition, self.certainty)
}
}