I know about str::from_utr8 and also string.parse::<T>()
Question:
I have a Vec<u8> where a prefix of it may or may not be a i32/f32. Besides (1) rolling my own parser or (2) brute forcing the length of the vec, is there a way to extract the longest prefix of the Vec that is a i32/f32 ?
Or, if you know which bytes are allowed to appear immediately after the end of the number, you can use position to find the index of the first such byte, and then parse everything before it using bytes[..position].parse::<i32>().