Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RustVec methods public #131

Merged
merged 1 commit into from
Jan 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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