赞
踩
什么 ! ! ! 用 rust 还一路 unsafe ?
柠檬树上柠檬果, 柠檬树下你和我. 酸了, 这编辑器居然不支持 rust. 果断放弃使用 ! ! !
#[derive(Debug)] // 链表节点(结点??)
struct Node {
data: i32,
next: Option<Box<Node>>,
}
#[derive(Debug)]
struct Link {
// 链表
len: u32,
node: Option<Box<Node>>,
}
impl Node { fn new(data: i32) -> Self { // . .. . 构造器? Node { data, next: None } } fn append_node(&mut self, node: Node) { // ... 追加节点 match &mut self.next { Some(ref mut t) => { t.append_node(node); } None => { self.next = Some(Box::new(node)); } } } fn to_string(&self) -> String { // 什么? 你要让我实现 fmt:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。