-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
More like:
#[derive(Debug)]
enum FSharpList<T> {
Cons(T, Box<FSharpList<T>>),
Nil,
}
impl<T> FSharpList<T> {
fn new<I: IntoIterator<Item = T>>(input: I) -> Self {
let mut iter = input.into_iter();
match iter.next() {
Some(item) => Self::Cons(item, Box::new(Self::new(iter))),
None => Self::Nil,
}
}
}
fn main() {
let fsharp_list = FSharpList::new(0..=10);
println!("{:#?}", fsharp_list);
}Printing:
Cons(
0,
Cons(
1,
Cons(
2,
Cons(
3,
Cons(
4,
Cons(
5,
Cons(
6,
Cons(
7,
Cons(
8,
Cons(
9,
Cons(
10,
Nil,
),
),
),
),
),
),
),
),
),
),
)
({:#?} pretty-print Debug representation, in case you didn't know.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels