如何安全地转换整数? [英] How to safely cast integers?

查看:41
本文介绍了如何安全地转换整数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

曾经有一个 fn std::num::cast 会在整数类型之间进行转换并返回一个 Option(返回 None如果演员表无效).那个功能去哪儿了?

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?

推荐答案

类似于之前的问题,该功能移至 num crate.更准确地说,它在 num::traits::cast.

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

这篇关于如何安全地转换整数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆