Rust 程序设计语言 简体中文版 1.85.0
编程语言的设计经常要考虑包含哪些功能,但考虑排除哪些功能也很重要。Rust 并没有很多 其他语言中有的空值功能。空值(Null )是一个值,它代表没有值。在有空值的语言中,变量 总是这两种状态之一:空值和非空值。 Tony Hoare,null 的发明者,在他 2009 年的演讲 “Null References: The Billion Dollar Mistake” 中曾经说到: 118/562Rust checking performed automatically by the compiler. But I couldn’t resist the temptation to put in a null reference, simply because it was so easy to implement. This has led to innumerable errors, vulnerabilities 叫做 Nil 的 值且没有下一项。cons list 通过递归调用 cons 函数产生。代表递归的归基条件(base case) 的规范名称是 Nil,它宣布列表的终止。注意这不同于第六章中的 “null” 或 “nil” 的概念,它 们代表无效或缺失的值。 cons list 并不是一个 Rust 中常见的类型。大部分在 Rust 中需要列表的时候,Vec是一个 更好的选择。其他更为复杂的递归数据类型确实在 0 码力 | 562 页 | 3.23 MB | 8 天前3
共 1 条
- 1