Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.starknet.io/llms.txt

Use this file to discover all available pages before exploring further.

A common trait for the ability to explicitly duplicate an object. Differs from Copy in that Copy is implicit and inexpensive, while Clone is always explicit and may or may not be expensive. Since Clone is more general than Copy, you can automatically make anything Copy be Clone as well.

Signature

pub trait Clone

Derivable

This trait can be used with #[derive] if all fields are Clone. The derived implementation of Clone calls clone on each field.

Trait functions

clone

Returns a copy of the value.

Signature

fn clone(self: @T) -> T

Examples

let arr = array![1, 2, 3];
assert!(arr == arr.clone());