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

Add attribute for Identifiable protocol #21

Merged
merged 1 commit into from
Jan 27, 2022
Merged

Add attribute for Identifiable protocol #21

merged 1 commit into from
Jan 27, 2022

Conversation

chinedufn
Copy link
Owner

@chinedufn chinedufn commented Jan 27, 2022

This commit introduces the #[swift_bridge(Identifiable)] attribute
which is used to generate an Identifiable protocol implementation
for a type.

For example:

// Rust

#[swift_bridge::bridge]
mod ffi {
    extern "Rust" {
        type SomeType;

        #[swift_bridge(Identifiable, swift_name = "someFunction")]
        fn some_function(&self) -> i16;
    }
}
// Generated Swift
// (rough example, the real generated code looks a little different)

class SomeType {
    // ...
}
extension SomeType: Identifiable {
    var id: UInt16 {
        return self.someFunction()
    }
}

This commit introduces the `#[swift_bridge(Identifiable)]` attribute
which is used to generate an `Identifiable` protocol implementation
for a type.

For example:

```rust
// Rust

\#[swift_bridge::bridge]
mod ffi {
    extern "Rust" {
        type SomeType;

        #[swift_bridge(Identifiable, swift_name = "someFunction")]
        fn some_function(&self) -> i16;
    }
}
```

```swift
// Generated Swift
// (rough example, the real generated code looks a little different)

class SomeType {
    // ...
}
extension SomeType: Identifiable {
    var id: UInt16 {
        return self.someFunction()
    }
}
```
@chinedufn chinedufn changed the title identifiable Add attribute for Identifiable protocol Jan 27, 2022
@chinedufn chinedufn merged commit 6e33007 into master Jan 27, 2022
@chinedufn chinedufn deleted the identifiable branch January 28, 2022 07:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant