当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Rust FromUtf16Error用法及代码示例


本文简要介绍rust语言中 Struct std::string::FromUtf16Error 的用法。

用法

pub struct FromUtf16Error(_);

从 UTF-16 字节切片转换 String 时可能出现的错误值。

此类型是 String 上的 from_utf16 方法的错误类型。

例子

基本用法:

// 𝄞mu<invalid>ic
let v = &[0xD834, 0xDD1E, 0x006d, 0x0075,
          0xD800, 0x0069, 0x0063];

assert!(String::from_utf16(v).is_err());

相关用法


注:本文由纯净天空筛选整理自rust-lang.org大神的英文原创作品 Struct std::string::FromUtf16Error。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。