Skip to content

Commit

Permalink
feature call
Browse files Browse the repository at this point in the history
  • Loading branch information
saltukalakus committed Oct 23, 2024
1 parent d1877b6 commit 43c137d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- [Tag your Crate](./essentials/crates-tag.md)
- [Feature Attribute](./essentials/crates-tag.md)
18 changes: 18 additions & 0 deletions src/essentials/feature-attribute.md
Original file line number Diff line number Diff line change
@@ -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));
}
```

0 comments on commit 43c137d

Please sign in to comment.