当前位置: 首页 > news >正文

南通网站推广公司广州网站关键词推广

南通网站推广公司,广州网站关键词推广,公司网站修改方案,杭州定制网站建设use std::io::Write; fn main() {/*std::io::stdin() 返回标准输入流stdin的句柄。read_line() stdin的句柄的一个方法,从标准输入流中读取一行数据返回一个Result枚举。会自动删除行尾的换行符\n。unwrap() 是一个帮助的方法,简化恢复错误的处理。返回R…
use std::io::Write;
fn main() {/*std::io::stdin() 返回标准输入流stdin的句柄。read_line() stdin的句柄的一个方法,从标准输入流中读取一行数据返回一个Result枚举。会自动删除行尾的换行符\n。unwrap() 是一个帮助的方法,简化恢复错误的处理。返回Result中的存储实际值。*/let mut in_word = String::new();let result = std::io::stdin().read_line(&mut in_word).unwrap();println!("您输入的是:{}\n", in_word);       // 您输入的是:helloprintln!("读取的字节数为:{}\n", result);    // 读取的字节数为:7let result1 = std::io::stdout().write("Rust".as_bytes()).unwrap();println!("写入的字节数为:{}\n", result1);   // Rust写入的字节数为:4let result2 = std::io::stdout().write("Hello".as_bytes()).unwrap();println!("写入的字节数为:{}\n", result2);   // Hello写入的字节数为:5/*std::io::stdout()返回标准输出流的句柄。write()是标准输出流stdout的句柄上的一个方法,用于向标准输出流中写入字节流的内容。也放回一个Result枚举,不会输出结束时自动追加换行符\n*/let input_args = std::env::args();for arg in input_args {println!("命令行参数:{}", arg);}/*输出:命令行参数:D:\Rust\io_23\target\debug\io_23.exe命令行参数:Rust命令行参数:Programming命令行参数:Language*/
}

unwrap()

In Rust, the unwrap() method is a common way to handle error states represented by the Option and Result types.

Let’s break it down a bit:

  • Option<T> is a type in Rust that represents an optional value: every Option<T> is either Some(T) (contains a value) or None (does not contain a value).

  • Result<T, E> is a type in Rust that can represent either success (Ok(T)) or failure (Err(E)).

Both Option and Result types have the method unwrap(). For an Option, calling unwrap() returns the contained value if it’s Some(T), but if it’s None, it will cause the program to panic (crash).

For a Result, calling unwrap() returns the contained value if it’s Ok(T), but if it’s Err(E), it will also cause the program to panic.

So, the unwrap() method is a somewhat risky operation to use, because while it’s a quick and easy way to obtain the inner value, it can cause your program to crash if the Option is None or the Result is an Err. In production code, it’s often preferable to handle errors more gracefully rather than using unwrap().

http://www.ds6.com.cn/news/38548.html

相关文章:

  • 网站体系优势百度云登录
  • 老公做赌博网站推广软文推广营销
  • 阿里巴巴网站做方案网站seo推广哪家值得信赖
  • 网站建设 自动生成廊坊百度推广seo
  • 企业网站建设视频网络推广长沙网络推广
  • wordpress为用户添加积分昆明优化网站公司
  • 如何在外管局网站上做延期b站推广2024mmm已更新
  • 淄博那里有做网站的百度一下进入首页
  • jsp网站开发介绍优秀品牌策划方案
  • 旅游电子商务网站建设网站指数查询
  • 网站空间怎么登陆网站服务费一年多少钱
  • 战鼓的h5网站如何做推广产品的软文
  • 个人网站建设制作电商代运营公司排名
  • 装修公司网站源码php注册域名查询网站官网
  • 做系统 和网站前端百度关键词排行榜
  • 德宏北京网站建设常用的网络营销策略有哪些
  • 电脑网站怎么做的网站优化建议怎么写
  • 做网站的公司深优化优化
  • asp.net2.0网站开发全程解析 pdfseo顾问培训
  • 网页设计教程图片seo网站推广批发
  • 做铝锭的网站宁波seo快速优化
  • 东洲网站建设怎么让网站排名上去
  • 烟台做外贸网站建设semir
  • 校园网站规划与建设管理微信软件
  • 网站域名备案多长时间微信公众号怎么做文章推广
  • swf做网站头微商怎么引流被别人加
  • 做网站运作国珍如何添加百度指数
  • 汝城网站建设超级软文
  • 今日时事热点网络优化工程师有前途吗
  • 怀化建设局网站上海百度提升优化