docs

您正在閱讀 v0.1.0 的文件。Nabi 0.1.0 已停止支援。 最新版本:v0.1.3 →

本頁尚未翻譯,以下為英文原文。

#E0080: definition depends on itself

A const, static or type alias is defined in terms of itself, directly or through others, or a type contains itself by value. Break the cycle; a type that contains itself holds it through a reference type such as List.

nabi
struct Node { value: i32; next: Node; }
error[E0080]: recursive type `Node` has infinite size (a struct can't contain itself by value; hold it through a reference type such as `List`)
  --> main.nabi:1:1
   |
 1 | struct Node { value: i32; next: Node; }
   | ^^^^^^

Hold the inner value through a reference type such as List:

nabi
struct Node { value: i32; next: List<Node>; }
let n = Node { value: 1, next: [] };
println(f"{n.value}");
1

Related: E0079 cannot evaluate at compile time, E0095 type too large

Found a mistake? Edit this page on GitHub. Last updated