No matching definitions.

tur/rcvec

stdlib/rcvec.tur

a flat vector of rc<A> the cycle collector can trace through.

Since: collections-cannot-hold-rc-values item 3

defstruct

RcVec

(defstruct RcVec :move [managed-by-c : int])

opaque marker type for the container.

Since: collections-cannot-hold-rc-values item 3

defn

rcvec-new

(rcvec-new :)

allocate a fresh, empty rc vector.

A new empty vector, owned by the caller.

(let [v (rcvec-new)]
    (println (rcvec-len v)))   ; => 0

Since: collections-cannot-hold-rc-values item 3

defn

rcvec-len

(rcvec-len [^borrow v : rc<RcVec>] :)

the number of elements in the vector.

vthe vector (borrowed)

The element count.

(rcvec-len (rcvec-new))  ; => 0

Since: collections-cannot-hold-rc-values item 3

defn

rcvec-push!

(rcvec-push! [A])

append an element to the vector.

vthe vector (borrowed)
itemthe element to append (borrowed; the vector retains its own)

Nothing.

(rcvec-push! v a)
  (println (rc/strong-count a))   ; caller's 1 + the vector's 1 = 2

Since: collections-cannot-hold-rc-values item 3

defn

rcvec-get

(rcvec-get [A])

the element at index i, as the caller's own reference.

vthe vector (borrowed)
izero-based index

A new strong reference to the element, or a null handle out of range.

(let [e (rcvec-get v 0)]
    (println (rc/strong-count e)))   ; slot's + caller's counts

Since: collections-cannot-hold-rc-values item 3