atomic/nullable docs
This commit is contained in:
parent
f0106d7f0b
commit
e408341b18
@ -23,7 +23,7 @@ pub trait WeakFunctor {
|
|||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// impl Functor for VecClass {
|
/// impl Functor for VecClass {
|
||||||
/// fn fmap<'a, A: 'a, B: 'a>(f: impl 'a + FnOnce(A) -> B, fa: Self::F<'a, A>) -> Self::F<'a, B>
|
/// fn fmap<'a, A: 'a, B: 'a>(f: impl 'a + FnOnce(A) -> B, fa: Self::F<'a, A>) -> Self::F<'a, B> {
|
||||||
/// fa.into_iter().map(f).collect()
|
/// fa.into_iter().map(f).collect()
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
@ -168,7 +168,7 @@ impl<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> AsRef<[u8]> for Point<'a, C
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Addresses {
|
pub struct Addresses {
|
||||||
current: usize,
|
current: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
|
//! This module allows to describe a primitive subset of [Mentionable] types, [Atomic]s,
|
||||||
|
//! simple static types, which are completely [Context]-independent.
|
||||||
|
|
||||||
use std::{error::Error, marker::PhantomData, rc::Rc};
|
use std::{error::Error, marker::PhantomData, rc::Rc};
|
||||||
|
|
||||||
use crate::core::*;
|
use crate::core::*;
|
||||||
|
|
||||||
|
/// This trait combines functionality of [Mentionable] and [Factory],
|
||||||
|
/// while limiting [Mentionable::points] (and corresponding [Mentionable::topology]) to an empty sequence.
|
||||||
pub trait Atomic: 'static + Sized + Clone + Serializable {
|
pub trait Atomic: 'static + Sized + Clone + Serializable {
|
||||||
|
/// Equivalent of [Factory::ParseError].
|
||||||
type ParseError: Error;
|
type ParseError: Error;
|
||||||
|
/// Static equivalent of [Factory::deserialize].
|
||||||
fn deserialize(deserializer: &mut dyn Deserializer) -> Result<Self, Self::ParseError>;
|
fn deserialize(deserializer: &mut dyn Deserializer) -> Result<Self, Self::ParseError>;
|
||||||
|
/// Static equivalent of [Factory::unexpected_tail].
|
||||||
fn unexpected_tail(tail: &[u8]) -> Self::ParseError;
|
fn unexpected_tail(tail: &[u8]) -> Self::ParseError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Generic implementation of a factory for [Atomic]s.
|
||||||
pub struct AtomicFactory<A: Atomic>(PhantomData<A>);
|
pub struct AtomicFactory<A: Atomic>(PhantomData<A>);
|
||||||
|
|
||||||
impl<A: Atomic> AtomicFactory<A> {
|
impl<A: Atomic> AtomicFactory<A> {
|
||||||
|
@ -60,11 +60,6 @@ impl<'a, Ctx: Context> TypelessMentionable<'a, Ctx>
|
|||||||
where
|
where
|
||||||
Ctx::LookupError: From<CastError<'a>>,
|
Ctx::LookupError: From<CastError<'a>>,
|
||||||
{
|
{
|
||||||
/// .
|
|
||||||
///
|
|
||||||
/// # Errors
|
|
||||||
///
|
|
||||||
/// This function will return an error if .
|
|
||||||
pub fn cast<A: Mentionable<'a, Ctx>>(&self, factory: A::Fctr) -> CastResult<'a, Ctx, A> {
|
pub fn cast<A: Mentionable<'a, Ctx>>(&self, factory: A::Fctr) -> CastResult<'a, Ctx, A> {
|
||||||
let mut vec = Vec::new();
|
let mut vec = Vec::new();
|
||||||
self.serialize(&mut vec);
|
self.serialize(&mut vec);
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
|
//! This module introduces [Option]-like concepts into RADN typesystem using [Nullable].
|
||||||
|
|
||||||
use crate::core::*;
|
use crate::core::*;
|
||||||
use crate::std::*;
|
use crate::std::*;
|
||||||
|
|
||||||
enum Nullable<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> {
|
/// Nullable reference type. Made for use as a linking element in data structures.
|
||||||
|
pub enum Nullable<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> {
|
||||||
Null(A::Fctr),
|
Null(A::Fctr),
|
||||||
NotNull(Point<'a, Ctx, A>),
|
NotNull(Point<'a, Ctx, A>),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NullableFactory<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> {
|
/// Nullable reference factory.
|
||||||
|
pub struct NullableFactory<'a, Ctx: 'a + Context, A: Mentionable<'a, Ctx>> {
|
||||||
factory: A::Fctr,
|
factory: A::Fctr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user