typeIsRecursiveInner
Function parameters
Parameters
- T:type
- prev_visited:[]const type
Type definitions in this namespace
Types
- ContainerOptions
- Options for manual serialization of container types.
- ValueOptions
- Options for serialization of an individual value.
- EmitCodepointLiterals
- Determines when to emit Unicode code point literals as opposed to integer literals.
- MultilineStringOptions
- Options for formatting multiline strings.
- Tuple
- Writes ZON tuples field by field.
- Struct
- Writes ZON structs field by field.
Serialize a value, similar to `serialize`.
Functions
- value
- Serialize a value, similar to `serialize`.
- valueMaxDepth
- Serialize a value, similar to `serializeMaxDepth`.
- valueArbitraryDepth
- Serialize a value, similar to `serializeArbitraryDepth`.
- int
- Serialize an integer.
- float
- Serialize a float.
- ident
- Serialize `name` as an identifier prefixed with `.`.
- codePoint
- Serialize `val` as a Unicode codepoint.
- tuple
- Like `value`, but always serializes `val` as a tuple.
- tupleMaxDepth
- Like `tuple`, but recursive types are allowed.
- tupleArbitraryDepth
- Like `tuple`, but recursive types are allowed.
- string
- Like `value`, but always serializes `val` as a string.
- multilineString
- Like `value`, but always serializes to a multiline string literal.
- beginStruct
- Create a `Struct` for writing ZON structs field by field.
- beginTuple
- Creates a `Tuple` for writing ZON tuples field by field.
Error sets in this namespace
Error Sets
Source
Implementation
fn typeIsRecursiveInner(comptime T: type, comptime prev_visited: []const type) bool {
for (prev_visited) |V| {
if (V == T) return true;
}
const visited = prev_visited ++ .{T};
return switch (@typeInfo(T)) {
.pointer => |pointer| typeIsRecursiveInner(pointer.child, visited),
.optional => |optional| typeIsRecursiveInner(optional.child, visited),
.array => |array| typeIsRecursiveInner(array.child, visited),
.vector => |vector| typeIsRecursiveInner(vector.child, visited),
.@"struct" => |@"struct"| for (@"struct".fields) |field| {
if (typeIsRecursiveInner(field.type, visited)) break true;
} else false,
.@"union" => |@"union"| inline for (@"union".fields) |field| {
if (typeIsRecursiveInner(field.type, visited)) break true;
} else false,
else => false,
};
}