From 43c137d187162b3cc28c51ca742bda736034dc8e Mon Sep 17 00:00:00 2001 From: saltukalakus Date: Wed, 23 Oct 2024 18:50:13 +0100 Subject: [PATCH] feature call --- src/SUMMARY.md | 3 ++- src/essentials/feature-attribute.md | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/essentials/feature-attribute.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index b33d0f1..fa47631 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -4,4 +4,5 @@ - [Sum Variables](./essentials/sum.md) - [Requiring modules](./essentials/modules.md) - [Package names](./essentials/package-names.md) - - [Tag your Crate](./essentials/crates-tag.md) \ No newline at end of file + - [Tag your Crate](./essentials/crates-tag.md) + - [Feature Attribute](./essentials/crates-tag.md) \ No newline at end of file diff --git a/src/essentials/feature-attribute.md b/src/essentials/feature-attribute.md new file mode 100644 index 0000000..aea1f7c --- /dev/null +++ b/src/essentials/feature-attribute.md @@ -0,0 +1,18 @@ +In Rust, the #! syntax is used for attributes that apply to the entire crate or module. These are known as "inner attributes." They are typically placed at the top of a file and are used to configure various aspects of the Rust compiler's behavior for that file or crate. + +#![feature(...)]: This attribute allows you to use unstable features in your Rust code from the nightly Rust compiler. It must be placed at the top of the file. + +As an example, the #![feature(test)] attribute in Rust is used to enable the test crate, which includes benchmarking and testing utilities that are not yet stabilized. + +```rust,noplaypen +#![feature(test)] +extern crate bcrypt; +extern crate test; + +use bcrypt::{hash, DEFAULT_COST}; + +#[bench] +fn bench_cost_4(b: &mut test::Bencher) { + b.iter(|| hash("hunter2", 4)); +} +``` \ No newline at end of file