pu369com

08 2021 档案

Rust从&[u8] bytes中读取任意类型的整数(如i32, u32等多种类型)
摘要:其实代码最后一行实现了同样功能,但可以用来学习trait和macro use std::convert::TryInto; pub trait ReadInteger<T> { fn from_le_bytes(data: &[u8]) -> T; fn from_be_bytes(data: &[ 阅读全文

posted @ 2021-08-25 16:04 pu369com 阅读(681) 评论(0) 推荐(0) 编辑

rust 裸指针
摘要:*const T和*mut T在Rust中被称为“裸指针” 可以绕过Rust的安全保障 有一些你需要记住的裸指针不同于其它指针的地方。它们是: 不能保证指向有效的内存,甚至不能保证是非空的(不像Box和&); 没有任何自动清除,不像Box,所以需要手动管理资源; 是普通旧式类型,也就是说,它不移动所 阅读全文

posted @ 2021-08-24 18:43 pu369com 阅读(647) 评论(0) 推荐(0) 编辑

rust 的奇葩点(.和..)语法小记
摘要:1 (.)点运算符 看到类似语句: let s = "12345".split_terminator("").0; 编译器提示:error[E0616]: field `0` of struct `SplitTerminator` is private 原来被最后那个0给迷惑了,这个点就是 成员访问 阅读全文

posted @ 2021-08-24 18:02 pu369com 阅读(601) 评论(1) 推荐(0) 编辑

rust 大神crypto2的例子AES加解密
摘要:我稍微改了一下,代码: extern crate crypto2; use crypto2::blockcipher::Aes128; fn main() { let key = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09 阅读全文

posted @ 2021-08-22 09:09 pu369com 阅读(883) 评论(0) 推荐(0) 编辑

rust试一试native-windows-gui
摘要: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 阅读全文

posted @ 2021-08-21 23:35 pu369com 阅读(558) 评论(0) 推荐(0) 编辑

Git使用出现git@github.com: Permission denied (publickey). 处理
摘要:以前处理过一次,时间长忘了,再记录一次 进入git bash界面然后:第一步,git config --global --list 验证邮箱与GitHub注册时输入的是否一致,没有没关系 第二步,通过git config --global user.name “yourname”,git confi 阅读全文

posted @ 2021-08-21 23:24 pu369com 阅读(323) 评论(0) 推荐(0) 编辑

rust 调用windows api
摘要:代码: #[cfg(windows)] extern crate winapi; use std::io::Error; #[cfg(windows)] fn print_message(msg: &str) -> Result<i32, Error> { use std::ffi::OsStr; 阅读全文

posted @ 2021-08-21 22:43 pu369com 阅读(1563) 评论(0) 推荐(0) 编辑

rust:win10执行shell命令及GB18030decode解码utf8存盘
摘要:费了点劲的知识点: 1 crate encoding处理汉字 2 Vec<u8>转&[u8] 代码(win10系统): extern crate encoding; use std::process::Command; use encoding::all::GB18030; use encoding 阅读全文

posted @ 2021-08-21 17:53 pu369com 阅读(484) 评论(0) 推荐(0) 编辑

正则表达式(Rust)
摘要:代码 use regex::{Regex, Captures}; use itertools::Itertools; use std::error::Error; fn main() -> Result<(), Box<dyn Error>> { let s = "123-4567-89,987-6 阅读全文

posted @ 2021-08-21 11:20 pu369com 阅读(332) 评论(0) 推荐(0) 编辑

Unicode 和 UTF-8 有何区别
摘要:比如 “我”这个字符。以二进制方式从文本文件中读,显示 :e6 88 91 也就是说, “我”的utf-8编码的Hex:'\xe6\x88\x91' 而用在线工具查,“我”的Unicode-Escape:'\u6211' 16进制的 6211 也就是 10进制的 25105 Unicode 和 UT 阅读全文

posted @ 2021-08-20 18:07 pu369com 阅读(2392) 评论(0) 推荐(0) 编辑

rust 读取文件
摘要: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 阅读全文

posted @ 2021-08-20 17:31 pu369com 阅读(811) 评论(0) 推荐(0) 编辑

如何在Rust中打印变量的类型及类型转换实践
摘要:#![feature(core_intrinsics)] fn print_type_of<T>(_: T) { println!("{}", std::intrinsics::type_name::<T>() ); } fn main() { print_type_of(3); // prints 阅读全文

posted @ 2021-08-19 18:57 pu369com 阅读(877) 评论(0) 推荐(0) 编辑

rust遇到了error[E0554]: `#![feature]` may not be used on the stable release channel(切换nightly版本)
摘要:参考:https://blog.51cto.com/u_14256460/2627326 从错误信息`#![feature]` may not be used on the stable release channel可以看出当前编译使用的channel还没有包含#![feature]功能,那咋办呢 阅读全文

posted @ 2021-08-19 12:48 pu369com 阅读(4655) 评论(0) 推荐(1) 编辑

利用github免费建立静态网站
摘要:安装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 阅读全文

posted @ 2021-08-18 16:52 pu369com 阅读(172) 评论(0) 推荐(0) 编辑

rust之#[derive(Debug)]
摘要:参考: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: 阅读全文

posted @ 2021-08-18 16:29 pu369com 阅读(2585) 评论(0) 推荐(0) 编辑

rust创建自己的库文件
摘要:参考 https://blog.csdn.net/quicmous/article/details/113829830 1 创建工程 选择合适的文件夹,执行下面的命令: cargo new hello cargo new hellolib --lib 2. 源代码 hellolib/src/lib. 阅读全文

posted @ 2021-08-18 15:28 pu369com 阅读(363) 评论(0) 推荐(0) 编辑

Rust 的宏
摘要:参考https://www.cnblogs.com/praying/p/14457360.html https://zhuanlan.zhihu.com/p/342408254 (Rust过程宏入门(一)及后续) https://dengjianping.github.io/2019/02/28/% 阅读全文

posted @ 2021-08-18 12:54 pu369com 阅读(86) 评论(0) 推荐(0) 编辑

Rust 学习之 Package、Crate、Module
摘要:Shesh's blog的那篇Clear explanation of Rust’s module system写的太好了。 详见http://www.sheshbabu.com/posts/rust-module-system/ 为加深理解,实际操作一下,直接做成最终版本项目结构: 1 执行 ca 阅读全文

posted @ 2021-08-17 18:10 pu369com 阅读(190) 评论(0) 推荐(0) 编辑

如何从Rust发出HTTP请求
摘要:参考 https://blog.csdn.net/weixin_34902131/article/details/112822347 1、在https://docs.rs/ 搜索 hyper , 例子中说 有一个 full client example. 2、github被q, 到https://h 阅读全文

posted @ 2021-08-16 18:48 pu369com 阅读(1261) 评论(0) 推荐(0) 编辑

rust hello world --引入第三方库或 crates
摘要: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 阅读全文

posted @ 2021-08-13 19:16 pu369com 阅读(1433) 评论(0) 推荐(0) 编辑

github连接超时
摘要:参考 https://blog.csdn.net/weixin_45942304/article/details/106655158 1 修改 C:\Windows\System32\drivers\etc\host 加入以下内容 #github192.30.255.112 github.com g 阅读全文

posted @ 2021-08-12 16:51 pu369com 阅读(76) 评论(0) 推荐(0) 编辑

win10下 Rust 环境搭建
摘要:参考 菜鸟教程 https://www.runoob.com/rust/cargo-tutorial.html 1、安装最新版的 Rust 编译工具和 Visual Studio Code。 Rust 编译工具:https://www.rust-lang.org/zh-CN/tools/instal 阅读全文

posted @ 2021-08-11 18:40 pu369com 阅读(438) 评论(0) 推荐(0) 编辑

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示