FromDsl -> Namespace

This commit is contained in:
🪞👃🪞 2025-05-21 00:06:36 +03:00
parent 455d6d00d5
commit f714302f21
8 changed files with 33 additions and 32 deletions

View file

@ -14,11 +14,11 @@ pub struct Either<A, B>(pub bool, pub A, pub B);
impl<A, B> Either<A, B> {
/// Create a ternary condition.
pub const fn new (c: bool, a: A, b: B) -> Self {
Self(c, a, b)
Self(c, a, b)
}
}
#[cfg(feature = "dsl")]
impl<'source, A, T: Dsl<bool> + Dsl<A>> FromDsl<'source, T> for When<A> {
impl<'source, A, T: Dsl<bool> + Dsl<A>> Namespace<'source, T> for When<A> {
fn take_from <'state> (
state: &'state T,
token: &mut TokenIter<'source>
@ -56,7 +56,7 @@ impl<E: Output, A: Render<E>> Content<E> for When<A> {
}
}
#[cfg(feature = "dsl")]
impl<'source, A, B, T: Dsl<bool> + Dsl<A> + Dsl<B>> FromDsl<'source, T> for Either<A, B> {
impl<'source, A, B, T: Dsl<bool> + Dsl<A> + Dsl<B>> Namespace<'source, T> for Either<A, B> {
fn take_from <'state> (
state: &'state T,
token: &mut TokenIter<'source>

View file

@ -33,7 +33,7 @@ macro_rules! transform_xy {
#[inline] pub const fn xy (item: A) -> Self { Self::XY(item) }
}
#[cfg(feature = "dsl")]
impl<'source, A, T: Dsl<A>> FromDsl<'source, T> for $Enum<A> {
impl<'source, A, T: Dsl<A>> Namespace<'source, T> for $Enum<A> {
fn take_from <'state> (state: &'state T, iter: &mut TokenIter<'source>) -> Perhaps<Self> {
if let Some(Token { value: Value::Key(k), .. }) = iter.peek() {
let mut base = iter.clone();
@ -77,7 +77,7 @@ macro_rules! transform_xy_unit {
#[inline] pub const fn xy (x: U, y: U, item: A) -> Self { Self::XY(x, y, item) }
}
#[cfg(feature = "dsl")]
impl<'source, A, U: Coordinate, T: Dsl<A> + Dsl<U>> FromDsl<'source, T> for $Enum<U, A> {
impl<'source, A, U: Coordinate, T: Dsl<A> + Dsl<U>> Namespace<'source, T> for $Enum<U, A> {
fn take_from <'state> (state: &'state T, iter: &mut TokenIter<'source>) -> Perhaps<Self> {
Ok(if let Some(Token { value: Value::Key($x|$y|$xy), .. }) = iter.peek() {
let mut base = iter.clone();

View file

@ -13,7 +13,7 @@ use crate::*;
//// Provides components to the view.
//#[cfg(feature = "dsl")]
//pub trait ViewContext<'state, E: Output + 'state>:
//FromDsl<bool> + FromDsl<usize> + FromDsl<E::Unit> + Send + Sync
//Namespace<bool> + Namespace<usize> + Namespace<E::Unit> + Send + Sync
//{
//fn get_content_sym <'source: 'state> (&'state self, iter: &mut TokenIter<'source>)
//-> Perhaps<RenderBox<'state, E>>;
@ -39,7 +39,7 @@ use crate::*;
//}
//#[cfg(feature = "dsl")]
//impl<'context, O: Output + 'context, T: ViewContext<'context, O>> FromDsl<T> for RenderBox<'context, O> {
//impl<'context, O: Output + 'context, T: ViewContext<'context, O>> Namespace<T> for RenderBox<'context, O> {
//fn take_from <'state, 'source: 'state> (state: &'state T, token: &mut TokenIter<'source>)
//-> Perhaps<RenderBox<'context, O>>
//{