Skip to content

Commit

Permalink
Add compile tests
Browse files Browse the repository at this point in the history
  • Loading branch information
evnu committed Sep 1, 2022
1 parent 452dda1 commit ed1dff9
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ members = [
"rustler_tests/native/rustler_test",
"rustler_tests/native/rustler_bigint_test",
"rustler_tests/native/deprecated_macros",
"rustler_tests/native/rustler_compile_tests",
]
14 changes: 14 additions & 0 deletions rustler_tests/native/rustler_compile_tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "rustler_compile_tests"
version = "0.1.0"
authors = []
edition = "2018"

[lib]
name = "rustler_test"
path = "src/lib.rs"
crate-type = ["cdylib"]

[dependencies]
lazy_static = "1.4"
rustler = { path = "../../../rustler" }
41 changes: 41 additions & 0 deletions rustler_tests/native/rustler_compile_tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
pub mod lifetimes {
use rustler::{Binary, NifMap, NifRecord, NifStruct, NifTuple};

#[derive(NifMap)]
pub struct GenericMap<'a, 'b> {
pub i: Binary<'a>,
pub j: Binary<'b>,
}

#[derive(NifStruct)]
#[module = "GenericStruct"]
pub struct GenericStruct<'a, 'b> {
pub i: Binary<'a>,
pub j: Binary<'b>,
}

#[derive(NifRecord)]
#[tag = "generic_record"]
pub struct GenericRecord<'a, 'b> {
pub i: Binary<'a>,
pub j: Binary<'b>,
}

#[derive(NifTuple)]
pub struct GenericTuple<'a, 'b>(Binary<'a>, Binary<'b>);

#[derive(NifMap)]
pub struct WhereClause<'a, 'b>
where
'a: 'b,
{
pub i: Binary<'a>,
pub j: Binary<'b>,
}

#[derive(NifMap)]
pub struct LifetimeBounded<'a, 'b: 'a> {
pub i: Binary<'a>,
pub j: Binary<'b>,
}
}

0 comments on commit ed1dff9

Please sign in to comment.