Skip to main content

Command Palette

Search for a command to run...

ExprKind::Tup(_elems) => { None }

Published
•1 min read•View as Markdown

ExprKind in rustc_hir


Call(&'hir Expr<'hir>, &'hir [Expr<'hir>])
A function call.

The first field resolves to the function itself (usually an ExprKind::Path), and the second field is the list of arguments. This also represents calling the constructor of tuple-like ADTs such as tuple structs and enum variants.

看起来你的匹配表达式需要返回一个 Option 类型,但是你的当前实现返回的是 () 类型(Rust的空类型)。你需要返回一个合适的 Option 类型,例如 None 或者 Some(T),其中 T 是一个适合你程序的类型。

如果你没有合适的值要返回,你可以简单地返回 None,例如:

            ExprKind::Tup(_elems) => {
                // Do nothing for tuples, return None
                None
            }

More from this blog

c_void到u8 - laertes-2023

为什么把c_void重命名为u8? 类型大小: u8通常代表一个单字节(8位)的无符号整数。c_void作为一个“空”类型,通常也被当作一个单字节进行处理(尽管这取决于具体的实现)。因此,这两者在大小上是匹配的。 类型转换简便: u8是一个非常基础的类型,与之进行类型转换通常比较方便。 操作简单: u8类型上可用的操作相对简单,可能更容易进行后续的代码分析或转换。 为什么不把其他东西重命名为u8? 类型语义: 其他类型可能具有其自己的语义和操作,这些可能不适用或不等价于u8。 数据...

Sep 5, 20231 min read

Retriever's blog

48 posts