尧图网络科技YAOTU DIGITAL 获取报价
获取报价
首页 / 资讯中心 / 文章详情

rust `?` couldn‘t convert the error to `std::string::String`the question mark operation (`?`)

发布时间:2026/9/17 13:55:49

资讯中心
01
ARTICLE

rust `?` couldn‘t convert the error to `std::string::String`the question mark operation (`?`)

rust `?` couldn‘t convert the error to `std::string::String`the question mark operation (`?`)
rust 带?写法报错const CONFIG: Config Config { width: 80.0, height: 30.0, scale: 1.0, }; let json_str serde_json::to_string(size)?; println!(size: {}, json_str);? couldnt convert the error to std::string::Stringthe question mark operation (?) implicitly performs a conversion on the error value using the From traitthe following other types implement trait FromT:std::string::String implements Frommut strstd::string::String implements Fromstd::string::Stringstd::string::String implements Fromstrstd::string::String implements FromAssetKeystd::string::String implements FromBoxstr因为返回值类型带 Error 需要处理。改为下面写法通过。let json_str serde_json::to_string(size) .map_err(|err| err.to_string())?; println!(size: {}, json_str);
02
RELATED NEWS

相关资讯

更多网站建设与数字化升级内容

03
WHY YAOTU

想打造同款高转化官网?

懂行业、懂生意,从建站到增长一站式陪跑

场景化定制

不做模板站,围绕你的业务场景量身设计,小众不撞款。

营销型架构

以转化目标组织内容与路径,让官网真正带来询盘。

全周期服务

设计、开发、运营、运维一体,上线只是开始。

免费获取你的建站方案

留下需求,专属顾问 24 小时内为你输出方案建议。