🧀 通过deref间接调用方法
昨天看 RefCell<T> 文档的时候, #[derive(Debug)] enum List { Cons(Rc<RefCell<i32>>, Rc<List>), Nil, } use crate::List::{Cons, Nil}; use std::cell::RefCell; use std::rc::Rc; ...
昨天看 RefCell<T> 文档的时候, #[derive(Debug)] enum List { Cons(Rc<RefCell<i32>>, Rc<List>), Nil, } use crate::List::{Cons, Nil}; use std::cell::RefCell; use std::rc::Rc; ...
reference cycle rustlings到了 Rc<T> 这块, 就看了一下官方资料 看到 This function is named strong_count rather than count because the Rc type also has a weak_count; we’ll see what weak_count is used for ...
Table of Contents 所有权是解决什么问题的? 内存安全问题 answer 之前的解决方式 Rust是怎么解决这个问题的? 什么是所有权呢? 所有者是什么意思? 释放值什么意思?它们本来在哪? ...
&String==&str??? fn test(v: &str)->{ println!("{}",v); } fn main(){ let a = String::from("hello"); assert_eq!("hello",a); test(&a); } 因为在Rust中,我们知道 hello 是 str 类型 那这里 ...
I’m doing the exercise, rustingls iterators5 fn count_iterator(map: &HashMap<String, Progress>, value: Progress) -> usize { // map is a hashmap with String keys and Progress value...
mut in Rust let v = 1 We know that if we want to change the value v later, we have to declare v as mutable let mut v = 1; v = 2; Some articles says that mut v means v can point to other, which...
原文: https://okmij.org/ftp/papers/DreamOSPaper.html A dream of an ultimate OS Oleg Kiselyov oleg-at-okmij.org, http://okmij.org/ftp/ This is a dream, and as such, it is made of shreds of reality sh...
Table of Contents Benjamin Keep的 How Learning Works 系列(1) What no one tells you about learning faster Forgetting doesn’t work like you think What happens when you become ...
Rustlings HashMap 3 这道题来自 rustling hashmap3 A list of scores (one per line) of a soccer match is given. Each line is of the form : “,,," Example: England,France,4,2 (England scored 4 goals, Fra...
quiz2 题目 rustlings的题目好像会变。现在做的这个quiz2的题目是 // quiz2.rs // // This is a quiz for the following sections: // - Strings // - Vecs // - Move semantics // - Modules // - Enums // // Let's build a little...