Creates an entity with one record component and returns its opaque identity.
Signature
func spawn(component: C) -> EntityThe C placeholder means one concrete type value, never a trait or primitive. Entity creation is bounded and rejected when the machine has no remaining entity capacity.
Parameters
component: C- A constructed type value; traits and primitive values are rejected.
Returns
EntityThe new Entity identity.
Examples
Create an entity
A spawned component receives the first entity identity.
main.kj
Loading…Drag to orbit · select to inspect
0 entities
Scene controls
Results
Loading the language runtime…
Output 0
No output.
State
Compile source to inspect its values.
TraceNo execution yet
- Executed source spans appear here.
Expected output
entity(1)
Rust definition
Rust interpreter builtin dispatch; Type is specialized from a concrete type argument.
View Rust documentation →Support: runtime