Skip to content

Commit d42bc04

Browse files
committed
doc(port_std): add a crate-level documentation
1 parent 609a79f commit d42bc04

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/constance_port_std/src/lib.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Simulator for running [`::constance`] on a hosted environment
2+
3+
# Usage
4+
5+
```rust
6+
#![feature(const_loop)]
7+
#![feature(const_fn)]
8+
#![feature(const_if_match)]
9+
#![feature(const_mut_refs)]
10+
11+
// Require `unsafe` even in `unsafe fn` - highly recommended
12+
#![feature(unsafe_block_in_unsafe_fn)]
13+
#![deny(unsafe_op_in_unsafe_fn)]
14+
15+
use constance::kernel::Task;
16+
17+
// Use the simulator port
18+
constance_port_std::use_port!(unsafe struct System);
19+
20+
const COTTAGE: () = constance::build!(System, configure_app);
21+
22+
constance::configure! {
23+
const fn configure_app(_: &mut CfgBuilder<System>) -> () {
24+
new! { Task<_>, start = task_body, priority = 1, active = true };
25+
}
26+
}
27+
28+
fn task_body(_: usize) {
29+
// The simulator initializes `env_logger` automatically
30+
log::warn!("yay");
31+
}
32+
```

src/constance_port_std/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![feature(const_fn)]
2+
#![feature(external_doc)]
23
#![feature(unsafe_block_in_unsafe_fn)] // `unsafe fn` doesn't imply `unsafe {}`
4+
#![doc(include = "./lib.md")]
35
#![deny(unsafe_op_in_unsafe_fn)]
46
use atomic_ref::AtomicRef;
57
use constance::{prelude::*, utils::intrusive_list::StaticListHead};

0 commit comments

Comments
 (0)