diff --git a/crates/cross/src/compound/list/flat.rs b/crates/cross/src/compound/list/flat.rs index d64ebe6..694d445 100644 --- a/crates/cross/src/compound/list/flat.rs +++ b/crates/cross/src/compound/list/flat.rs @@ -269,6 +269,28 @@ impl Prependable for Node { } } +pub type Appended = >::Result; +pub trait Appendable { + // XXX can't move the E parameter inside without Generic Associated Types + type Result; + fn append(self, e: E) -> Self::Result; +} + +impl Appendable for Null { + type Result = Node; + fn append(self, e: E) -> Self::Result { + Node::new(e, Null) + } +} +impl Appendable for Node + where T: Appendable +{ + type Result = Node; + fn append(self, e: E) -> Self::Result { + Node::new(self.head, self.tail.append(e)) + } +} + impl MaybeMeta for Null { type Length = P0; } diff --git a/crates/cross/src/compound/list/mod.rs b/crates/cross/src/compound/list/mod.rs index 9524607..e389804 100644 --- a/crates/cross/src/compound/list/mod.rs +++ b/crates/cross/src/compound/list/mod.rs @@ -5,7 +5,7 @@ mod flat; // mod tuple_consumer; // pub use tuple_consumer::*; // pub use linked::*; -pub use flat::{IntoList, Prependable, Prepended}; +pub use flat::{IntoList, Appendable, Appended, Prependable, Prepended}; pub use flat::exports::*; pub type Empty = flat::Null;