What can be done with Rust's generic FromStr object?

前端 未结 2 601
执笔经年
执笔经年 2021-01-24 08:52

Rust\'s str class has a parse method that returns a FromStr object. parse is templated, and so the type that\'s being parsed

2条回答
  •  日久生厌
    2021-01-24 09:41

    It's just not clear what m is here, as there isn't enough information to say. Is it an i32? A u64? Nobody, including Rust, can know.

    You need to do something to help figure out what type it is. Either pass it to a function expecting a specific type, or annotate it such that it can be determined what type it should be.

提交回复
热议问题