github dtolnay/cxx 1.0.26

latest releases: 1.0.130, 1.0.129, 1.0.128...
3 years ago
  • Support lifetimes on extern types (#610, #611, #622, #624, #627, #628, #630, #634, #635, #652, #653)

    #[cxx::bridge]
    mod ffi {
        unsafe extern "C++" {
            type Resource;
            type Holder<'a>;  // contains a `const Resource &`
    
            fn makeHolder<'a>(resource: &'a Resource) -> SharedPtr<Holder<'a>>;
    
            // or with lifetime elision
            fn makeHolder(resource: &Resource) -> SharedPtr<Holder>;
        }
    }
  • Support lifetimes on shared structs (#650)

    #[cxx::bridge]
    mod ffi {
        struct Example<'a> {
            s: &'a str,
            x: &'a [UniquePtr<Thing<'a>>],
        }
    }
  • Support &str and &[T] as element type of slices and arrays (#636, #638, #644, #645, #647, #651)

    mod ffi {
        extern "Rust" {
            fn demo(flags: &[&str]);
        }
    }
  • Support #[rust_name = "..."] and #[cxx_name = "..."] attributes on fields of shared structs (#631, #632)

    #[cxx::bridge]
    mod ffi {
        struct Example {
            #[cxx_name = "type"]  // `type` is a keyword in Rust, but not C++
            ty: Type,
        }
    }
  • Provide swap() const member functions for the types in cxx.h (#642, #643, #646, thanks @capickett)

  • Clean up warnings in generated code on various platforms (#637, #639, #640, #648, #649)

Don't miss a new cxx release

NewReleases is sending notifications on new releases.