Rust for C++

Private implementation (PIMPL)

Rust
mod api {
    pub trait Printer {
        fn new() -> Self;

        fn print(&self);
    }
}

mod library {
    pub struct MyPrinter;

    impl super::api::Printer for MyPrinter {
        fn new() -> MyPrinter {
            MyPrinter
        }

        fn print(&self) {
        }
    }
}

Run

C++
// library.h
class Interface {
  private:
    class Impl;
    Impl* m_impl;
};

// library.cpp
class Interface::Impl {
};

Run