SingularError
to rcore
This commit is contained in:
parent
e317ce37c1
commit
ae95e99767
@ -43,7 +43,7 @@ pub use self::resolution::{
|
||||
Address, HashResolution, HashResolutionResult, LookupError, Resolution, ResolutionError,
|
||||
ResolutionFailure, ResolutionResult, Resolver, ResolverMap,
|
||||
};
|
||||
pub use self::singular::SingularResolution;
|
||||
pub use self::singular::{SingularError, SingularResolution};
|
||||
pub use self::to_hex::hex;
|
||||
pub use self::topology::MentionableTop;
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub trait SingularResolution<'a, Ctx: Context<'a>>: 'a + Send + Sync {
|
||||
@ -17,3 +19,38 @@ impl<'a, Ctx: Context<'a>, A: Mentionable<'a, Ctx>> SingularResolution<'a, Ctx>
|
||||
self.point
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum SingularError {
|
||||
OutOfBounds {
|
||||
index: usize,
|
||||
len: usize,
|
||||
},
|
||||
Mismatch {
|
||||
index: usize,
|
||||
expected: Hash,
|
||||
point: Hash,
|
||||
},
|
||||
}
|
||||
|
||||
impl Display for SingularError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::OutOfBounds { index, len } => {
|
||||
write!(f, "singularity out-of-bounds: {index}/{len}")
|
||||
}
|
||||
Self::Mismatch {
|
||||
index,
|
||||
expected,
|
||||
point,
|
||||
} => write!(
|
||||
f,
|
||||
"address mismatch at index {index}: {}!={}",
|
||||
hex(expected),
|
||||
hex(point),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for SingularError {}
|
||||
|
@ -25,41 +25,6 @@ struct SingularRobust<'a, Ctx: Context<'a>> {
|
||||
resolver: Arc<SingularResolver<'a, Ctx>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum SingularError {
|
||||
OutOfBounds {
|
||||
index: usize,
|
||||
len: usize,
|
||||
},
|
||||
Mismatch {
|
||||
index: usize,
|
||||
expected: Hash,
|
||||
point: Hash,
|
||||
},
|
||||
}
|
||||
|
||||
impl Display for SingularError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::OutOfBounds { index, len } => {
|
||||
write!(f, "singularity out-of-bounds: {index}/{len}")
|
||||
}
|
||||
Self::Mismatch {
|
||||
index,
|
||||
expected,
|
||||
point,
|
||||
} => write!(
|
||||
f,
|
||||
"address mismatch at index {index}: {}!={}",
|
||||
hex(expected),
|
||||
hex(point),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Error for SingularError {}
|
||||
|
||||
impl<'a, Ctx: Context<'a>> SingularResolver<'a, Ctx> {
|
||||
pub fn from_mentionable<A: Mentionable<'a, Ctx>>(a: &A) -> Self {
|
||||
let mut points = Vec::new();
|
||||
|
@ -7,7 +7,6 @@ use sha2::{Digest, Sha256};
|
||||
|
||||
use crate::func::{context::*, *};
|
||||
use crate::rcore::*;
|
||||
use crate::rstd::singular::*;
|
||||
use crate::rstd::{inject::*, typeless::*};
|
||||
|
||||
pub struct NoDiagnostic;
|
||||
|
Loading…
Reference in New Issue
Block a user