Merge pull request #1298 from adamchalmers/achalmers/document-how-to-implement-vectorelement

Document how to implement VectorElement
This commit is contained in:
David Tolnay 2024-01-02 17:38:21 -08:00 committed by GitHub
commit b2477123a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -314,7 +314,8 @@ where
/// `CxxVector<T>` in generic code.
///
/// This trait has no publicly callable or implementable methods. Implementing
/// it outside of the CXX codebase is not supported.
/// it outside of the CXX codebase requires using [explicit shim trait impls],
/// adding the line `impl CxxVector<MyType> {}` in the same `cxx::bridge` that defines `MyType`.
///
/// # Example
///
@ -338,6 +339,8 @@ where
///
/// Writing the same generic function without a `VectorElement` trait bound
/// would not compile.
///
/// [explicit shim trait impls]: https://cxx.rs/extern-c++.html#explicit-shim-trait-impls
pub unsafe trait VectorElement: Sized {
#[doc(hidden)]
fn __typename(f: &mut fmt::Formatter) -> fmt::Result;