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&...
本文代码 https://github.com/tothis/rust-record/tree/main/test/ssh2Cargo.toml[package] name = "ssh2-record" version = "0.1.0" edition = "2018" [dependencies] ssh2 = "...
增加依赖:easy="*"use curl::easy::Easy; use std::fs::File; use std::io::Write; fn main() { let source_url = "https://pic.3gbizhi.com/2019/0927/20190927085959737.jpeg"; let collect:Vec...
rust base64 例子base64 = "0.12.1"use base64::{encode, decode}; fn main() { let a = b"hello world"; let b = "aGVsbG8gd29ybGQ="; assert_eq!(encode(a), b); assert...
rust md5 加密库Cargo.toml 增加依赖rust-crypto = "^0.2" use crypto::digest::Digest; use crypto::md5::Md5; pub fn md5<S:Into<String>>(input: S) -> String { let mut md5 = Md5...
rust zip库使用Cargo.toml增加依赖zip = "0.5.5"压缩目录使用walkdir = "2"use std::fs; use std::fs::File; use std::io::{copy, Read, Seek, Write}; use std::path::Path; use std::str; use walkdir::{DirEntry, WalkDir...
use std::{env, process}; fn main() { let a = vec![ String::from("hello"), String::from("world"), ]; println!("size of vector is :{}"...
//Cargo.toml [dependencies] mysql = "*" chrono = "0.4" //filename:mysql_helper.rs //filename:mysql_helper.rs use mysql::*; use mysql::prelude::*; pub struct User { pub id:...
//filename:Cargo.toml [dependencies] rodio="0.13.0" //filename:main.rs use rodio::Sink; fn main () { let file = std::fs::File::open(r"F:\1775.白雪-千古绝唱.mp3").unwrap(); le...
将字符串打散为字符数组 chars()如果要将一个字符串打散为所有字符组成的数组,可以使用 chars() 方法。从某些方面说,如果我们要迭代字符串中的每一个字符,则必须首先将它打散为字符数组,然后才能遍历。fn main(){ let n1 = "编程教程".to_string(); for n in n1.chars(){ println!(...