Skip to content

Commit

Permalink
[feature] #2004: Forbid isize and usize from becoming IntoSchema.
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr Petrosyan <[email protected]>
  • Loading branch information
appetrosyan committed May 5, 2022
1 parent 322afe8 commit 7bc1682
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ fixnum = { version = "0.6.1", default-features = false, features = ["i64"] }

[dev-dependencies]
parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive", "full"] }
impls = { version = "=1.0.0" }

iroha_schema_gen = { version = "=2.0.0-pre-rc.3", path = "gen" }
26 changes: 26 additions & 0 deletions schema/tests/architecture-dependent.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use impls::impls;
use iroha_schema::IntoSchema;
use parity_scale_codec::{Encode, Decode};

#[test]
fn usize_isize_not_into_schema() {
// The architecture-dependent
assert!(!impls!(usize: IntoSchema));
assert!(!impls!(isize: IntoSchema));

// use serde::Serialize;
//
// assert!(!impls!(usize: Serialize));
// `usize` should be `Serialize`.


// But not `Encode`/`Decode`.
assert!(!impls!(usize: Encode | Decode));
assert!(!impls!(isize: Encode | Decode));

// There are no other primitive architecture-dependent types, so
// as long as `IntoSchema` requires all variants and all fields to
// also be `IntoSchema`, we are guaranteed that all schema types
// are safe to exchange.
}

0 comments on commit 7bc1682

Please sign in to comment.