Static type checking with PhantomData#41
Conversation
I totally agree with this. It is great feature :) I think one may want to check the dimension of the array statistically like |
It's a difficult decision, but I feel it's too restrictive to give dimension parameter to let vec2 = vec![vec![1, 2, 3]; 2];
let pyarray = PyArray::from_vec2(gil.python(), &np, &vec2).unwrap();But, in Python -> Rust scenario, we still have to give type parameter and do dynamic type checking, like let pyarray: &PyArray<i32> = gil
.python()
.eval("np.array([1, 2, 3], dtype='int32')", Some(&dict), None)
.unwrap()
.extract()
.unwrap();(full example and where we do dynamic type cheking) |
Currently, this code
causes panic.
But, isn't it annoying to give a type annotation like
from_vec::<i64>, and isn't it really user-friendly to cause panic?So, this PR introduces
PyArray<T>instead ofPyArray.By this change, when we write
, we can get compile error.
@termoshtt
This is a breaking change so I want to hear your opnion 🙂