Trait koto_runtime::KotoCopy

source ·
pub trait KotoCopy {
    // Required method
    fn copy(&self) -> KObject;

    // Provided method
    fn deep_copy(&self) -> KObject { ... }
}
Expand description

A trait for defining how objects should behave when copied in the Koto runtime

Use #[derive(KotoCopy)] for simple objects that don’t need a custom implementation of KotoCopy::deep_copy.

Required Methods§

source

fn copy(&self) -> KObject

How the object should behave when called from koto.copy

A default implementation can’t be provided here, but a typical implementation will look similar to: Object::from(self.clone())

Provided Methods§

source

fn deep_copy(&self) -> KObject

How the object should behave when called from koto.deep_copy

Deep copies should ensure that deep copies are performed for any Koto values that are owned by the object (see KValue::deep_copy).

Implementors§