paritytech / parity-common

Collection of crates used in Parity projects
https://www.paritytech.io/
Apache License 2.0
282 stars 213 forks source link

Is it possible to use unit in no_std projects? #792

Closed wojciech-cichocki closed 11 months ago

wojciech-cichocki commented 11 months ago

hello! I want to use uint for math operations in my contract written in Ink! The problem is that I cannot compile it to WASM due to std usage. This is how I import uint:

[dependencies]
uint = "0.9.5"

I am trying to build a basic flipper example contract using this command: cargo contract build. Unfortunately, I got a lot of these kinds of errors

error[E0152]: duplicate lang item in crate `core` (which `hex` depends on): `Range`.
  |
  = note: the lang item is first defined in crate `core` (which `std` depends on)
  = note: first definition in `core` loaded from /home/wojciech/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libcore-4e48b611ead810f8.rlib
  = note: second definition in `core` loaded from /home/wojciech/a0/no_std-ink/target/ink/wasm32-unknown-unknown/release/deps/libcore-5a37b600ddc3bb47.rmeta

Here are a couple of things about using std in Ink!

ordian commented 11 months ago

hey, you need to disable default features for uint in your Cargo.toml:

[dependencies]
uint = { version = "0.9.5", default-features = false }