摘要:
/** 208. Implement Trie (Prefix Tree) https://leetcode.com/problems/implement-trie-prefix-tree/description/ A trie (pronounced as "try") or prefix tre 阅读全文
摘要:
问题: 添加自定义pallet到Substrate框架中,编译时遇到如下错误: stderr Compiling pallet-simple-pallet v4.0.0-dev (/Users/johnny/Documents/work/BlockChain/Substrate/substrate- 阅读全文
摘要:
use std::borrow::Borrow; /** 21. Merge Two Sorted Lists https://leetcode.com/problems/merge-two-sorted-lists/ You are given the heads of two sorted li 阅读全文
摘要:
use std::collections::{HashMap, HashSet}; /** 997. Find the Town Judge https://leetcode.com/problems/find-the-town-judge/ In a town, there are n peopl 阅读全文
摘要:
use std::collections::HashSet; use std::collections::VecDeque; /** 841. Keys and Rooms https://leetcode.com/problems/keys-and-rooms/ There are n rooms 阅读全文
摘要:
Rust的所有权机制,要求一个资源同一时刻有且只能有一个拥有所有权的绑定或&mut引用,目的为保证内存的安全。在大多数情况下,都没有问题,但是考虑以下情况: 在图数据结构中,多个边可能会拥有同一个节点,该节点直到没有边指向它时,才应该被释放清理。 在多线程中,多个线程可能会持有同一个数据,但是你受限 阅读全文
摘要:
use std::borrow::Borrow; use std::cell::RefCell; use std::collections; use std::collections::HashMap; use std::rc::Rc; /** 652. Find Duplicate Subtree 阅读全文
摘要:
我们在学习Rust的借用,引用时,会遇到References(引用)、borrowing(借用)、&关键字、*关键字,他们之间的关系非常困惑。 所有权不仅可以转移(原变量会丢失数据的所有权),还可以通过引用的方式来借用数据的所有权(borrow ownership)。 我们整理下相关问题: 1. & 阅读全文
摘要:
简单工厂模式 trait Login { fn verify(&self, name: String, password: String) -> bool; } enum LoginType { Domain, Password, } struct DomainLogin {} impl Login 阅读全文