Rust书中提到"使用结构而不是元组结构几乎总是更好".除了newtype模式之外,还有其他任何有未命名字段的优点吗?在我看来,newtype模式是具有元组结构的唯一有用的情况.
我的问题是为什么以下模式返回,'match即使(make-tree 0 null null)显然不是null?
#lang racket
(define-struct tree (val left right))
(match (make-tree 1 (make-tree 0 null null) null)
[(tree 1 null _) 'match]
[_ 'no-match])
Run Code Online (Sandbox Code Playgroud)
我注意到在第一个模式中更改nullto会'()产生正确的(?)值.为什么会这样?是不是null和'()等同?提前致谢.