Crate rkyv_impl

source ·
Expand description

Implement methods for Foo and ArchivedFoo in a single impl block.

use rkyv::Archive;
use rkyv_impl::*;
use std::iter::Sum;

struct Foo<T> {
    elements: Vec<T>

impl<T> Foo<T> {
    // Notice that the where clause is transformed so that
    // `T` is replaced with `T::Archived` in the generated `impl`.
    fn sum<S>(&self) -> S
        T: Clone,
        S: Sum<T>

fn use_generated_method(foo: &ArchivedFoo<u32>) {
    // Call the generated method!
    let _ = foo.sum::<u32>();

Attribute Macros

  • Decorates an impl T (or impl FooTrait for T) block and generates an equivalent impl T::Archived.
  • Supports the same arguments as archive_impl, but applies to methods on an impl block.