You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm still interested in the ideas behind this project. Had a play to see how const generics might make the API more expressive, and I think it has a lot of potential. The idea is that const-generics would allows you to insert and retrieve columns into the dataframe by name, and it would be a compile error to ask for a column that didn't exist. Take this toy code (using frunk which is great):
#![feature(const_generics)]use frunk::hlist::{HList,HCons,HNil,Selector};structColumn<T,constS:&'staticstr>{// S is the 'name' of the columninner:Vec<T>}impl<T,constS:&'staticstr>Column<T,S>{fnnew(inner:Vec<T>) -> Self{Self{
inner
}}}structFrame<H:HList>{inner:H}implFrame<HNil>{fnnew() -> Self{Self{inner:HNil}}}impl<H:HList>Frame<H>{fnadd<T,constS:&'staticstr>(self,col:Vec<T>) -> Frame<HCons<Column<T,S>,H>>{let column = Column::new(col);Frame{inner:HCons{head: column,tail:self.inner}}}pubfnget<T,Index,constS:&'staticstr>(&self) -> &Column<T,S>whereH:Selector<Column<T,S>,Index>,{Selector::get(&self.inner)}}fnmain(){let frame = Frame::new().add::<u32,"col1">(vec![1,2,3]).add::<u32,"col2">(vec![1,2,3]);let col = frame.get::<_,_,"col1">();// OK// let col = frame.get::<_, _, "missing">(); // compile error!}
This is pretty neat! Problem: it crashes with an ICE at the moment. But it will work soon!
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
I'm still interested in the ideas behind this project. Had a play to see how const generics might make the API more expressive, and I think it has a lot of potential. The idea is that const-generics would allows you to insert and retrieve columns into the dataframe by name, and it would be a compile error to ask for a column that didn't exist. Take this toy code (using
frunk
which is great):This is pretty neat! Problem: it crashes with an ICE at the moment. But it will work soon!
The text was updated successfully, but these errors were encountered: