fn main() { // 1. 接收参数 for arg in std::env::args() { println!("{}", arg); } }
use std::process::Command; fn main() { println!("hello world~~"); // 命令提示符 pause let _ = Command::new("cmd.exe").arg("/c").arg("pause").status(); ...
use std::process::Command; fn main() { println!("hello world~~"); // 命令提示符 pause let _ = Command::new("cmd.exe").arg("/c").arg("ping www.baidu.com"...
use std::process::{exit, Command}; use std::time::Duration; fn main() { use std::time::Instant; let now = Instant::now(); //计算耗时 //====================================================...
fn main() { use std::time::Instant; let now = Instant::now(); //计算耗时 //===================================================== for i in 0..5000 { println!("{}", i)...
fn main() { use std::time::Instant; let now = Instant::now(); //计算耗时 //===================================================== let mut i = 0; while i < 10000 { // 循环体 ...
fn main() { use std::time::Instant; let now = Instant::now(); //计算耗时 //===================================================== //===================================================== ...
use urlencoding::decode; use urlencoding::encode; fn main() { let encoded = encode("https://docs.rs/urlencoding/2.1.0/urlencoding/"); println!("编码后:{}", encoded); ...
文章目录一、读取文件二、写入文件一、读取文件use std::fs::File; fn main() { let f = File::open("hello.txt").unwrap(); } 1、按字节读取use std::fs::File; use std::io::prelude::*; fn main() { let mut f = File...
use std::io::{BufRead, BufReader}; use std::fs::File; fn main() { let file = File::open("1.txt").expect("cannot open file"); let file = BufReader::new(file); for li...