swift-bridge icon indicating copy to clipboard operation
swift-bridge copied to clipboard

Unable to return Option<String>

Open lockieluke opened this issue 2 years ago • 2 comments

This is my struct:

pub struct DiscordRPCAgent {
    client: DiscordIpcClient,
    state: Option<String>,
    details: Option<String>,
    start_timestamp: Option<i64>,
    end_timestamp: Option<i64>,
    large_image: Option<&'static str>,
    large_text: Option<&'static str>,
    small_image: Option<&'static str>,
    small_text: Option<&'static str>,
}

I would like to have properties that state and details as Option<String>

#[swift_bridge(get(&state))]
fn state(&self) -> Option<String>;
#[swift_bridge(get(&details))]
fn details(&self) -> Option<String>;

But then the compiler throws an error: image

lockieluke avatar Feb 20 '23 17:02 lockieluke

Removing the & does not help image

lockieluke avatar Feb 20 '23 17:02 lockieluke

Hey.

I don't see Option in your error message at all. That's peculiar. It makes me uncertain about whether or not your error message came from that example?


At any rate.

Can you please provide a minimal bridge module and minimal struct that illustrate your issue, along with the error message that you see for that minimal bridge module and struct?

This will make it easier to understand the exact problem that you're facing.

Thanks!

chinedufn avatar Feb 20 '23 17:02 chinedufn