Skip to content

Latest commit

 

History

History
26 lines (18 loc) · 987 Bytes

File metadata and controls

26 lines (18 loc) · 987 Bytes

rust_link

项目概述

链表数据结构的多种实现,从简单到复杂逐步演进,包含 6 个版本:

  1. first.rs: 最基础的栈式单链表

    • 只有 pushpop 操作
    • 使用 Box<Node>Option 的组合
  2. second.rs - fifth.rs: 中间版本,逐步改进

  3. sixth.rs: 完整的生产级双向链表实现

    • 支持双向遍历 (Iter, IterMut, IntoIter)
    • 游标操作 (CursorMut)
    • 支持列表分割和合并 (split_before, split_after, splice_before, splice_after)
    • 实现了所有标准 trait (Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Send, Sync)
    • 使用 NonNull<T> 进行 unsafe 优化

开发规范

代码风格

  • 遵循 Rust 标准命名规范:结构体和枚举使用 CamelCase,函数和变量使用 snake_case
  • 测试代码写在同文件的 #[cfg(test)] mod tests 块中
  • unsafe 代码块需要有 SAFETY 注释说明安全性保证