Skip to content

0.1.57

Latest
Compare
Choose a tag to compare
@chinedufn chinedufn released this 15 Aug 13:36
· 5 commits to master since this release
1b547a5
  • Support Failable initializers. #276 (thanks @NiwakaDev)

    // Rust
    
    #[swift_bridge::bridge]
    mod ffi {
        extern "Rust" {
            #[swift_bridge(Equatable)]
            type FailableInitType;
    
            #[swift_bridge(init)]
            fn new() -> Option<FailableInitType>;
        }
    }
    // Swift
    
    let failableInitType = FailableInitType()
    if failableInitType == nil {
        // ...
    } else {
       // ...
    }
  • Support Throwing initializers #287 (thanks @NiwakaDev)

    // Rust
    
    #[swift_bridge::bridge]
    mod ffi {
        enum ResultTransparentEnum {
            NamedField { data: i32 },
            UnnamedFields(u8, String),
            NoFields,
        }
        extern "Rust" {
            type ThrowingInitializer;
            #[swift_bridge(init)]
            fn new(succeed: bool) -> Result<ThrowingInitializer, ResultTransparentEnum>;
            fn val(&self) -> i32;
        }
    }
    // Swift
    
    do {
        let throwingInitializer = try ThrowingInitializer(false)
    } catch let error as ResultTransparentEnum {
        //...
    } catch {
        //...
    }