From 180a389832ea505df5a05620a35fcfc4ba311936 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 27 Apr 2011 18:10:02 -0700 Subject: stdlib/rt: Add an unsafe function to cast immutable vectors to mutable ones --- src/rt/rust_builtin.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/rt/rust_builtin.cpp') diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 5566835d..a2323898 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -178,6 +178,15 @@ vec_from_vbuf(rust_task *task, type_desc *ty, void *vbuf, size_t n_elts) vbuf); } +extern "C" CDECL rust_vec* +unsafe_vec_to_mut(rust_task *task, type_desc *ty, rust_vec *v) +{ + if (v->ref_count != CONST_REFCOUNT) { + v->ref(); + } + return v; +} + extern "C" CDECL rust_str* str_alloc(rust_task *task, size_t n_bytes) { -- cgit v1.2.3