mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-30 15:27:24 +00:00
b686bfefba
_This PR is being continued from https://github.com/paritytech/polkadot-sdk/pull/2206, which was closed when the developer_hub was merged._ closes https://github.com/paritytech/polkadot-sdk-docs/issues/44 --- # Description This PR adds a reference document to the `developer-hub` crate (see https://github.com/paritytech/polkadot-sdk/pull/2102). This specific reference document covers defensive programming practices common within the context of developing a runtime with Substrate. In particular, this covers the following areas: - Default behavior of how Rust deals with numbers in general - How to deal with floating point numbers in runtime / fixed point arithmetic - How to deal with Integer overflows - General "safe math" / defensive programming practices for common pallet development scenarios - Defensive traits that exist within Substrate, i.e., `defensive_saturating_add `, `defensive_unwrap_or` - More general defensive programming examples (keep it concise) - Link to relevant examples where these practices are actually in production / being used - Unwrapping (or rather lack thereof) 101 todo -- - [x] Apply feedback from previous PR - [x] This may warrant a PR to append some of these docs to `sp_arithmetic` --------- Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Gonçalo Pestana <g6pestana@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-authored-by: Francisco Aguirre <franciscoaguirreperez@gmail.com> Co-authored-by: Radha <86818441+DrW3RK@users.noreply.github.com>
54 lines
1.3 KiB
TOML
54 lines
1.3 KiB
TOML
[package]
|
|
name = "sp-arithmetic"
|
|
version = "23.0.0"
|
|
authors.workspace = true
|
|
edition.workspace = true
|
|
license = "Apache-2.0"
|
|
homepage = "https://substrate.io"
|
|
repository.workspace = true
|
|
description = "Minimal fixed point arithmetic primitives and types for runtime."
|
|
documentation = "https://docs.rs/sp-arithmetic"
|
|
readme = "README.md"
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[package.metadata.docs.rs]
|
|
targets = ["x86_64-unknown-linux-gnu"]
|
|
|
|
[dependencies]
|
|
codec = { package = "parity-scale-codec", version = "3.6.1", default-features = false, features = [
|
|
"derive",
|
|
"max-encoded-len",
|
|
] }
|
|
integer-sqrt = "0.1.2"
|
|
num-traits = { version = "0.2.17", default-features = false }
|
|
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
|
|
serde = { features = ["alloc", "derive"], optional = true, workspace = true }
|
|
static_assertions = "1.1.0"
|
|
sp-std = { path = "../std", default-features = false }
|
|
docify = "0.2.7"
|
|
|
|
[dev-dependencies]
|
|
criterion = "0.4.0"
|
|
primitive-types = "0.12.0"
|
|
sp-crypto-hashing = { path = "../crypto/hashing" }
|
|
rand = "0.8.5"
|
|
|
|
[features]
|
|
default = ["std"]
|
|
std = [
|
|
"codec/std",
|
|
"num-traits/std",
|
|
"scale-info/std",
|
|
"serde/std",
|
|
"sp-crypto-hashing/std",
|
|
"sp-std/std",
|
|
]
|
|
# Serde support without relying on std features.
|
|
serde = ["dep:serde", "scale-info/serde"]
|
|
|
|
[[bench]]
|
|
name = "bench"
|
|
harness = false
|