atomic/nullable docs

This commit is contained in:
AF 2023-04-21 17:54:15 +00:00
parent f0106d7f0b
commit e408341b18
5 changed files with 17 additions and 9 deletions

View File

@ -23,7 +23,7 @@ pub trait WeakFunctor {
/// }
///
/// 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()
/// }
/// }

View File

@ -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,
}

View File

@ -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 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 {
/// Equivalent of [Factory::ParseError].
type ParseError: Error;
/// Static equivalent of [Factory::deserialize].
fn deserialize(deserializer: &mut dyn Deserializer) -> Result<Self, Self::ParseError>;
/// Static equivalent of [Factory::unexpected_tail].
fn unexpected_tail(tail: &[u8]) -> Self::ParseError;
}
/// Generic implementation of a factory for [Atomic]s.
pub struct AtomicFactory<A: Atomic>(PhantomData<A>);
impl<A: Atomic> AtomicFactory<A> {

View File

@ -60,11 +60,6 @@ impl<'a, Ctx: Context> TypelessMentionable<'a, Ctx>
where
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> {
let mut vec = Vec::new();
self.serialize(&mut vec);

View File

@ -1,12 +1,16 @@
//! This module introduces [Option]-like concepts into RADN typesystem using [Nullable].
use crate::core::*;
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),
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,
}