Skip to content

Moving vs borrowing #60

Open
Open
@d-unsed

Description

@d-unsed

Consider the following example:

let string = RString::new("Some string");
let mut array = Array::new();

// Moves `string` into `array` similarly to `vec.push()` in Rust
array.push(string);

// ... `string` cannot be used, because it's moved

vs

string = 'Some string'
array = []

# Takes a reference of the `string`
array.push(string)

# `string` can be used
string.concat(" mutated")

array.inspect # => ['Some string mutated']

It needs to be decided whether to take objects references (Ruby way) or by values (Rust way).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions