Closed
Description
I'm not sure how reasonable this is, but since &[!]
can only ever be the empty slice, I was hoping it would be represented the same way as &[!; 0]
and ()
, with zero size and knowledge that it must be empty.
e.g. I was hoping this would become a function taking a parameter of zero size and executing xor eax, eax
:
pub fn length_never_slice(x: &[!]) -> usize { x.len() }
I have no real use case except showing off cool tricks with !
. Maybe this would be useful in generic code, although at least for simple cases where the actual value can get threaded through, it already optimizes fine. (e.g. a call of length_never_slice(&vec![])
will become a hardcoded constant as one expects.)
Metadata
Metadata
Assignees
Labels
No labels