cross: list: add an Appendable
trait.
this isn't tested... hope it works!
This commit is contained in:
@@ -269,6 +269,28 @@ impl<H, T> Prependable for Node<H, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub type Appended<Head, Next> = <Head as Appendable<Next>>::Result;
|
||||||
|
pub trait Appendable<E> {
|
||||||
|
// XXX can't move the E parameter inside without Generic Associated Types
|
||||||
|
type Result;
|
||||||
|
fn append(self, e: E) -> Self::Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E> Appendable<E> for Null {
|
||||||
|
type Result = Node<E, Null>;
|
||||||
|
fn append(self, e: E) -> Self::Result {
|
||||||
|
Node::new(e, Null)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<H, T, E> Appendable<E> for Node<H, T>
|
||||||
|
where T: Appendable<E>
|
||||||
|
{
|
||||||
|
type Result = Node<H, T::Result>;
|
||||||
|
fn append(self, e: E) -> Self::Result {
|
||||||
|
Node::new(self.head, self.tail.append(e))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl MaybeMeta for Null {
|
impl MaybeMeta for Null {
|
||||||
type Length = P0;
|
type Length = P0;
|
||||||
}
|
}
|
||||||
|
@@ -5,7 +5,7 @@ mod flat;
|
|||||||
// mod tuple_consumer;
|
// mod tuple_consumer;
|
||||||
// pub use tuple_consumer::*;
|
// pub use tuple_consumer::*;
|
||||||
// pub use linked::*;
|
// pub use linked::*;
|
||||||
pub use flat::{IntoList, Prependable, Prepended};
|
pub use flat::{IntoList, Appendable, Appended, Prependable, Prepended};
|
||||||
pub use flat::exports::*;
|
pub use flat::exports::*;
|
||||||
|
|
||||||
pub type Empty = flat::Null;
|
pub type Empty = flat::Null;
|
||||||
|
Reference in New Issue
Block a user