method List.clone
A copy of the list (elements are cloned too).
Example:
fn main() io {
let a = [1, 2]
var b = a.clone()
b.push(3)
print("{a} {b}")
}Вывод
[1, 2] [1, 2, 3]
A copy of the list; the original stays usable.
Example:
fn main() io {
let a = [1, 2]
var b = a.clone()
b.push(3)
print("{a} {b}")
}Вывод
[1, 2] [1, 2, 3]
pub(api) fn clone() -> List<T>Сложность. O(n).
С версии. 1.0.0-beta
Возвращает
List<T>
Эффекты
не объявлены (чистая, пока тело не говорит иное)
Определено в: std/core/collections.oxl:394