You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+23-4Lines changed: 23 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,12 +45,23 @@ fn main() {
45
45
}
46
46
```
47
47
48
-
## Feature flags ##
48
+
## Usage in constants ##
49
+
`memoffset` has support for compile-time `offset_of!` on rust>=1.65, or on older nightly compilers.
49
50
50
-
### Usage in constants ###
51
-
`memoffset` has **experimental** support for compile-time `offset_of!` on a nightly compiler.
51
+
### Usage on stable Rust ###
52
+
Constant evaluation is automatically enabled and avilable on stable compilers starting with rustc 1.65.
52
53
53
-
In order to use it, you must enable the `unstable_const` crate feature and several compiler features.
54
+
This is an incomplete implementation with one caveat:
55
+
Due to dependence on [`#![feature(const_refs_to_cell)]`](https://github.com/rust-lang/rust/issues/80384), you cannot get the offset of a `Cell` field in a const-context.
56
+
57
+
This means that if need to get the offset of a cell, you'll have to remain on nightly for now.
58
+
59
+
### Usage on recent nightlies ###
60
+
61
+
If you're using a new-enough nightly and you require the ability to get the offset of a `Cell`,
62
+
you'll have to enable the `unstable_const` cargo feature, as well as enabling `const_refs_to_cell` in your crate root.
63
+
64
+
Do note that `unstable_const` is an unstable feature that is set to be removed in a future version of `memoffset`.
54
65
55
66
Cargo.toml:
56
67
```toml
@@ -59,6 +70,14 @@ version = "0.7"
59
70
features = ["unstable_const"]
60
71
```
61
72
73
+
Your crate root: (`lib.rs`/`main.rs`)
74
+
```rust,ignore
75
+
#![feature(const_refs_to_cell)]
76
+
```
77
+
78
+
### Usage on older nightlies ###
79
+
In order to use it on an older nightly compiler, you must enable the `unstable_const` crate feature and several compiler features.
0 commit comments