Rust: Fix Copy and Clone impls for a few generic types (#5577)

* Rust: Fix Copy and Clone impls for a few generic types

* Add tests for Copy+Clone

* Wrap Copy+Clone checks in a #[test] function
This commit is contained in:
Mathias Svensson
2019-10-28 05:20:29 +01:00
committed by Robert Winslow
parent 26f238c248
commit b4774d2354
4 changed files with 57 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ path = "bin/alloc_check.rs"
quickcheck = "0.6"
# TODO(rw): look into moving to criterion.rs
bencher = "0.1.5"
static_assertions = "1.0.0"
[[bench]]
# setup for bencher

View File

@@ -2694,6 +2694,21 @@ mod byte_layouts {
}
}
#[cfg(test)]
mod copy_clone_traits {
#[test]
fn follow_types_implement_copy_and_clone() {
static_assertions::assert_impl_all!(flatbuffers::WIPOffset<u32>: Copy, Clone);
static_assertions::assert_impl_all!(flatbuffers::WIPOffset<Vec<u32>>: Copy, Clone);
static_assertions::assert_impl_all!(flatbuffers::ForwardsUOffset<u32>: Copy, Clone);
static_assertions::assert_impl_all!(flatbuffers::ForwardsUOffset<Vec<u32>>: Copy, Clone);
static_assertions::assert_impl_all!(flatbuffers::Vector<'static, u32>: Copy, Clone);
static_assertions::assert_impl_all!(flatbuffers::Vector<'static, Vec<u32>>: Copy, Clone);
}
}
// this is not technically a test, but we want to always keep this generated
// file up-to-date, and the simplest way to do that is to make sure that when
// tests are run, the file is generated.