assert!(props.len() == 1);
let mut props = props;
let t = props.pop().unwrap();
Here props: Vec<T>. I find this whole dance a bit inelegant. I can't get props[0] since that appears to return a ref. I'd prefer to just do props.singleton().unwrap() but that doesn't exist.
If you have a Vec, is there an idiomatic way to: convert it to T is there is only one element, and panic otherwise ?
let v = vec![1];
let value = match &v[..] {
[unique] => unique,
[_, _, ..] => panic!("error more than one value"),
[] => panic!("error empty vector"),
};
That's because it's desugared to a deferenced reference. Thus, you can't use it to move the value out, which is what the OP will seems to want per their solution.
Though even if that were fixed it's possible that the .try_into().unwrap() would still need annotations -- I forget if you can get a &[T] from that, which would then be ambiguous.