Skip to content

Commit c4da9ba

Browse files
committed
add no_std content in README
1 parent 8bdedba commit c4da9ba

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

README.md

+32-1
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ let mut allocator = Allocator::new(&AllocatorCreateDesc {
142142
```
143143

144144
## Simple Metal allocation example
145+
145146
```rust
146147
use gpu_allocator::metal::*;
147148
use gpu_allocator::MemoryLocation;
@@ -167,9 +168,39 @@ drop(resource);
167168
allocator.free(&allocation).unwrap();
168169
```
169170

171+
## `no_std` Support
172+
173+
`no_std` support can be enabled by compiling with `--no-default-features` to
174+
disable `std` support and `--features hashbrown` for `Hash` collections that are only
175+
defined in `std` for internal usages in crate. For example:
176+
177+
```toml
178+
[dependencies]
179+
gpu-allocator = { version = "0.27", default-features = false, features = ["hashbrown", "other features"] }
180+
```
181+
182+
To support both `std` and `no_std` builds in project, you can use the following
183+
in your `Cargo.toml`:
184+
185+
```toml
186+
[features]
187+
default = ["std", "other features"]
188+
189+
std = ["gpu-allocator/std"]
190+
hashbrown = ["gpu-allocator/hashbrown"]
191+
other_features = []
192+
193+
[dependencies]
194+
gpu-allocator = { version = "0.27", default-features = false }
195+
```
196+
170197
## Minimum Supported Rust Version
171198

172-
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust 1.71. Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
199+
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust **1.71**.
200+
201+
The `no_std` support requires version above **1.81** beacuase `no_std` support of dependency `thiserror` requires `core::error::Error` which is stabalized in **1.81**.
202+
203+
Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
173204

174205
## License
175206

README.tpl

+31-1
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,39 @@ gpu-allocator = "0.27.0"
1919

2020
{{readme}}
2121

22+
## `no_std` Support
23+
24+
`no_std` support can be enabled by compiling with `--no-default-features` to
25+
disable `std` support and `--features hashbrown` for `Hash` collections that are only
26+
defined in `std` for internal usages in crate. For example:
27+
28+
```toml
29+
[dependencies]
30+
gpu-allocator = { version = "0.27", default-features = false, features = ["hashbrown", "other features"] }
31+
```
32+
33+
To support both `std` and `no_std` builds in project, you can use the following
34+
in your `Cargo.toml`:
35+
36+
```toml
37+
[features]
38+
default = ["std", "other features"]
39+
40+
std = ["gpu-allocator/std"]
41+
hashbrown = ["gpu-allocator/hashbrown"]
42+
other_features = []
43+
44+
[dependencies]
45+
gpu-allocator = { version = "0.27", default-features = false }
46+
```
47+
2248
## Minimum Supported Rust Version
2349

24-
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust 1.71. Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
50+
The MSRV for this crate and the `vulkan`, `d3d12` and `metal` features is Rust **1.71**.
51+
52+
The `no_std` support requires version above **1.81** beacuase `no_std` support of dependency `thiserror` requires `core::error::Error` which is stabalized in **1.81**.
53+
54+
Any other features such as the `visualizer` (with all the `egui` dependencies) may have a higher requirement and are not tested in our CI.
2555

2656
## License
2757

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@
174174
//! ```
175175
//!
176176
//! # Simple Metal allocation example
177+
//!
177178
//! ```no_run
178179
//! # #[cfg(feature = "metal")]
179180
//! # fn main() {

0 commit comments

Comments
 (0)