How to safely cast integers?

2019-06-17 07:32发布

问题:

There used to be a fn std::num::cast that would cast between integer types and return an Option (returning None if the cast was invalid). Where did that functionality go?

回答1:

Similarily to previous question, that functionality moved to num crate. More precisely, It's in num::traits::cast.



标签: rust