enter image description here

#![cfg_attr(not(feature = "std"), no_std)]

2 Answers 2


Those are conditional attributes, a feature of rust. In a nutshell you say if not(feature = "std") is true i.e. feature std is disabled, then turn on attribute called no_std module wide as indicated by the ! after pound #. Enabling no_std prevents you from importing the rust std lib and making use of it. This is necessary for pallets as they run inside a wasm interpreter and do not have access to machine resources which is in turn required by rust std lib.


In short, it means: If "std" is not enabled, flag/mark this crate/module as no_std while compiling.

All you need is this: https://doc.rust-lang.org/reference/conditional-compilation.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.