Second block does work, but it changes the function, since len and N are not necessarily the same. The question (this is the overlap with the original post) is why does adding multiplying C0
This is a general limitation of all global items in Rust (static, global const, functions, and type definitions). You can't use type parameter from the enclosing scope.
Would you mind explaining what is happening with F::f? This does seem to work in some way, but SliceVec returns () so assignment V = SliceVec and methods like max_len do not work. Is there a way to use this same sort of ::f call while preserving assignment, methods of SliceVec?
I just verified my last answer, and it doesn't work. Sorry, my bad. For now, it looks like you can only directly name const-generic parameters, and have expressions that don't depend on const-generic parameters.
Operations on const-generic parameters haven't been implemented just yet. It looks like any way of trying to do this results in an error. (operations include the arithmetic operators, functions, anything beyond just naming they const generic parameter).
(As seen your the linked issue).
I've never seen that error before, but it looks like this is because operations not being allowed on const generic parameters. (looks like you don't need floating point to see the error playground).
Yes, but various comments are able to get this sort of thing to work in ways the are not yet displayed in here or in original post. As an example,
fn split_first<T, const N: usize>(arr: [T; N]) -> (T, [T; N - 1]) {
let arr = mem::ManuallyDrop::new(arr);
unsafe {
let head = ptr::read(&arr[0]);
let tail = ptr::read(&arr[1..] as *const [T] as *const [T; N - 1]);
(head, tail)
}
}
though the test() example unconstrained generic constant and asking for where clauses?
yet
So back to above, what is the best way to follow this? Searching by Github issue labels not particularly helpful and though some of the recent links are somewhat helpful (operations on const generic parameters are permitted in certain examples), but still not clear about how to use upstream const generic parameters operations. Is this the type of feature where needing knowledge of rustc to follow discussions?
Thankful for all your attentive responses, but if there is a place that may be better to ask this question, open to go there.
edit: To clarity, still unclear if using the approach from the linked issue is appropriate in the the original example. This is where relevant unconstrained generic constantThis may work.
Thanks again for your help @RustyYato. New thread for cycle detected when building an abstract representation.