Skip to content

Commit

Permalink
Make RustVec methods public (#131)
Browse files Browse the repository at this point in the history
Co-authored-by: Stephen Williams <stephenwilliams@Stephens-Personal.local>
  • Loading branch information
onato and Stephen Williams authored Jan 5, 2023
1 parent 2783798 commit 1f1ae99
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions crates/swift-bridge-build/src/generate_core/rust_vec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@ public class RustVec<T: Vectorizable> {
var ptr: UnsafeMutableRawPointer
var isOwned: Bool = true

init(ptr: UnsafeMutableRawPointer) {
public init(ptr: UnsafeMutableRawPointer) {
self.ptr = ptr
}

init() {
public init() {
ptr = T.vecOfSelfNew()
isOwned = true
}

func push (value: T) {
public func push (value: T) {
T.vecOfSelfPush(vecPtr: ptr, value: value)
}

func pop () -> Optional<T> {
public func pop () -> Optional<T> {
T.vecOfSelfPop(vecPtr: ptr)
}

func get(index: UInt) -> Optional<T.SelfRef> {
public func get(index: UInt) -> Optional<T.SelfRef> {
T.vecOfSelfGet(vecPtr: ptr, index: index)
}

/// Rust returns a UInt, but we cast to an Int because many Swift APIs such as
/// `ForEach(0..rustVec.len())` expect Int.
func len() -> Int {
public func len() -> Int {
Int(T.vecOfSelfLen(vecPtr: ptr))
}

Expand Down

0 comments on commit 1f1ae99

Please sign in to comment.