摘要:其实代码最后一行实现了同样功能,但可以用来学习trait和macro use std::convert::TryInto; pub trait ReadInteger<T> { fn from_le_bytes(data: &[u8]) -> T; fn from_be_bytes(data: &[
阅读全文
摘要:*const T和*mut T在Rust中被称为“裸指针” 可以绕过Rust的安全保障 有一些你需要记住的裸指针不同于其它指针的地方。它们是: 不能保证指向有效的内存,甚至不能保证是非空的(不像Box和&); 没有任何自动清除,不像Box,所以需要手动管理资源; 是普通旧式类型,也就是说,它不移动所
阅读全文
摘要:1 (.)点运算符 看到类似语句: let s = "12345".split_terminator("").0; 编译器提示:error[E0616]: field `0` of struct `SplitTerminator` is private 原来被最后那个0给迷惑了,这个点就是 成员访问
阅读全文
摘要:我稍微改了一下,代码: extern crate crypto2; use crypto2::blockcipher::Aes128; fn main() { let key = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09
阅读全文
摘要:git clone git@github.com:gabdube/native-windows-gui.git cd native-windows-gui/native-windows-gui # Running the tests from the workspace screws up the
阅读全文
摘要:以前处理过一次,时间长忘了,再记录一次 进入git bash界面然后:第一步,git config --global --list 验证邮箱与GitHub注册时输入的是否一致,没有没关系 第二步,通过git config --global user.name “yourname”,git confi
阅读全文
摘要:代码: #[cfg(windows)] extern crate winapi; use std::io::Error; #[cfg(windows)] fn print_message(msg: &str) -> Result<i32, Error> { use std::ffi::OsStr;
阅读全文
摘要:费了点劲的知识点: 1 crate encoding处理汉字 2 Vec<u8>转&[u8] 代码(win10系统): extern crate encoding; use std::process::Command; use encoding::all::GB18030; use encoding
阅读全文
摘要:代码 use regex::{Regex, Captures}; use itertools::Itertools; use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { let s = "123-4567-89,987-6
阅读全文
摘要:比如 “我”这个字符。以二进制方式从文本文件中读,显示 :e6 88 91 也就是说, “我”的utf-8编码的Hex:'\xe6\x88\x91' 而用在线工具查,“我”的Unicode-Escape:'\u6211' 16进制的 6211 也就是 10进制的 25105 Unicode 和 UT
阅读全文
摘要:1、逐行读文本 use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() { // File hosts must exist in current path before this produce
阅读全文
摘要:#![feature(core_intrinsics)] fn print_type_of<T>(_: T) { println!("{}", std::intrinsics::type_name::<T>() ); } fn main() { print_type_of(3); // prints
阅读全文
摘要:参考:https://blog.51cto.com/u_14256460/2627326 从错误信息`#![feature]` may not be used on the stable release channel可以看出当前编译使用的channel还没有包含#![feature]功能,那咋办呢
阅读全文
摘要:安装git并在cmd中执行: set https_proxy=127.0.0.1:1080 set http_proxy=127.0.0.1:1080 set GIT_SSL_NO_VERIFY=true 1 在github注册用户名、密码。 2 比如用户名是XX就在github上建立名为XX.gi
阅读全文
摘要:参考:https://rust-by-example.budshome.com/hello/print/print_debug.html cargo new hello main.rs #[derive(Debug)] struct Person<'a> { name: &'a str, age:
阅读全文
摘要:参考 https://blog.csdn.net/quicmous/article/details/113829830 1 创建工程 选择合适的文件夹,执行下面的命令: cargo new hello cargo new hellolib --lib 2. 源代码 hellolib/src/lib.
阅读全文
摘要:参考https://www.cnblogs.com/praying/p/14457360.html https://zhuanlan.zhihu.com/p/342408254 (Rust过程宏入门(一)及后续) https://dengjianping.github.io/2019/02/28/%
阅读全文
摘要:Shesh's blog的那篇Clear explanation of Rust’s module system写的太好了。 详见http://www.sheshbabu.com/posts/rust-module-system/ 为加深理解,实际操作一下,直接做成最终版本项目结构: 1 执行 ca
阅读全文
摘要:参考 https://blog.csdn.net/weixin_34902131/article/details/112822347 1、在https://docs.rs/ 搜索 hyper , 例子中说 有一个 full client example. 2、github被q, 到https://h
阅读全文
摘要:1 hello world 的例子可参考 https://kaisery.github.io/trpl-zh-cn/ 及 https://rust-by-example.budshome.com/index.html 2、下面参考 https://www.twle.cn/c/yufei/rust/r
阅读全文
摘要:参考 https://blog.csdn.net/weixin_45942304/article/details/106655158 1 修改 C:\Windows\System32\drivers\etc\host 加入以下内容 #github192.30.255.112 github.com g
阅读全文
摘要:参考 菜鸟教程 https://www.runoob.com/rust/cargo-tutorial.html 1、安装最新版的 Rust 编译工具和 Visual Studio Code。 Rust 编译工具:https://www.rust-lang.org/zh-CN/tools/instal
阅读全文