获得徽章 0
Rust borrow 不可变借用 示例
苦酒100于2025-09-12 22:08发布的图片
苦酒100于2025-09-12 22:08发布的图片
评论
Rust 打印字符串地址
苦酒100于2025-09-11 22:30发布的图片
评论
Emacs company-mode,简单也可以很好用
苦酒100于2025-09-11 15:37发布的图片
评论
Rust 代码片段 Box<dyn Any>:
use std::any::Any;

fn print_if_string(s: Box<dyn Any>) {
if s.is::<String>() {
println!("It's a string...");
} else {
println!("Not a string...");
}
}

fn main() {
let new_string = "hello".to_string();
print_if_string(Box::new(new_string));
}
展开
评论
Rust 代码片段 -- dyn Any:
use std::any::Any;

fn print_if_string(s: &dyn Any) {
if s.is::<String>() {
println!("It's a string!");
} else {
println!("Not a string!");
}
}

fn main() {
print_if_string(&"hello".to_string());
}
展开
评论
Rust 代码片段 -- 之 dyn Any(with TypeId):
use std::any::{Any, TypeId};

fn main() {
fn is_string(s: &dyn Any) {
if TypeId::of::<String>() == s.type_id() {
println!("It's a string!");
} else {
println!("Not a string!");
}
}

is_string(&"hello".to_string());
}
展开
评论
在Emacs中写Rust代码...
苦酒100于2025-09-08 16:49发布的图片
评论
Rust 为 newtype 实现 Display
struct Meters(u32);

impl fmt::Display for Meters {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.0)
}
}
展开
评论
我不愿让这个世界改变自己
因为我知道那是你喜欢的那个人...
评论
代码编辑器的本质是什么?
不是代码提示!
不是AI代码生成!
评论
万分之一的人放眼于未来,就有了今天的成就;
如果有万分之一百的人放眼于未来,科技又何止于先进100年...
评论
使用create-react-app创建项目,别忘记支持typescript,状态管理mobx已经使用了n+1年了,请问还有比react-router更好用的路由管理么,sass也已经使用了n+1年了--没办法改变了,material-ui开始使用的时候大概还只是1.x。再配合bun+rsbuild,这应该是一个"值得纪念的时刻",因为未来的技术并非可以更好...
10
use std::sync::mpsc;
use std::thread;

fn main() {
let (tx, rx) = mpsc::channel();

thread::spawn(move || {
let val = String::from("hi");
tx.send(val).unwrap();
});

let received = rx.recv().unwrap();
println!("Got: {received}");
}
展开
评论
栈按照顺序存储值并以相反顺序取出值,这也被称作后进先出
增加数据叫做进栈,移出数据则叫做出栈
栈中的所有数据都必须占用已知且固定大小的内存空间
评论
css 背景图片自适应居中:
background-image: url("__url__");
background-repeat: no-repeat;
background-size: cover;
background-position: center;
评论
windows下的Emacs配置 .emacs.d 有两个位置,一个适用于命令行emacs启动,另一个适用于直接打开emacs app,这两种不同方式的启动,加载的 .emacs.d的文件路径不同。命令行emacs启动加载的配置文件路径为:c:/Users/[your_computer_name]/.emacs.d,直接打开emacs app加载配置文件路径为:c:/User/[your_computer_name]/AppData/Roaming/.emacs.d。
展开
评论
下一页
个人成就
文章被阅读 702
掘力值 62
收藏集
1
关注标签
6
加入于