<div class="pc div1"> 您的内容包含: 数字:<span class="js-spn">0</span>个 英文:<span class="js-spn">0</span>个 汉字:<span class="js-spn">0&l...
use std::net::UdpSocket; use std::str; fn main() -> std::io::Result<()> { let remote_addr = "localhost:8888"; let socket = UdpSocket::bind("localhost:0")?; println!("Sending to the server"); socket.send_to("Hello from client".as_b...
use std::env; use std::fs::File; use std::io; fn main() -> io::Result<()> { let args: Vec<_> = env::args().collect(); let src = &args[1]; let dest = &args[2]; let mut file = File::open(src)?; let mut new_file = File::create(dest)?; io::copy(&...
use std::fs::File; use std::io; use std::io::Write; fn main() -> io::Result<()> { let file = File::create("file.zip")?; let mut zip = zip::ZipWriter::new(file); zip.start_file("file.txt", zip::write::FileOptions::default())?; zip.write_all(b"zip...
Cargo.toml 配置[dependencies] scraper = "0.12.0" reqwest = { version = "0.11.10", features = ["blocking", "json"] } surf = "2.3.2" tokio = { version = "1.17.0", features = ["full"] } futures = "0.3.21" main.rs代码use fu...
use std::io::prelude::*; use std::fs::File; use std::io::BufWriter; use std::io::BufReader; fn main() { let file = File::open("./ico.txt").unwrap(); let mut fin = BufReader::new(file); for line in fin.lines() { println!("{}", line.unwrap()); } }
参考https://huangjj27.gitlab.io/posts/rust-mirrorhttps://doc.rust-lang.org/cargo/reference/source-replacement.htmlhttps://lug.ustc.edu.cn/wiki/mirrors/help/rust-crateshttps://github.com/rustcc/lernaean-deploy如当前用户目录为/root 项目目录为/root/rust-test 则在 /root/.cargo 目录或 /root/rust-test/.cargo 目录 创建文件config...
本文代码 https://github.com/tothis/rust-record/tree/main/cli/file-append-newlineCargo.toml[package] name = "file-append-newline" version = "0.1.0" authors = ["Li Lei <this.lilei@gmail.com>"] edition = "2021" [dependencies] toml = "0.5" serde = ...
Rust 日期时间命令行工具本文代码 https://github.com/tothis/rust-record/tree/main/cli/time当前日期和时间戳cargo run解析时间cargo run "2020-02-20 02:04:08.000"解析时间戳cargo run 1582135448000Cargo.toml[package] name = "time" version = "0.1.0" authors = ["Li Lei <this.lilei@gmail.com>"] editio...
本文代码 https://github.com/tothis/rust-record/tree/main/test/ssh2Cargo.toml[package] name = "ssh2-record" version = "0.1.0" edition = "2018" [dependencies] ssh2 = "0.9" src/main.rsuse std::fs; use std::io::{Read, Write}; use std::net::TcpStream; use std::path...