Gilad Naaman
726aae7d3a
Automatically enable const evaluation
...
When running on a compiler newer than 1.65,
automatically enable usage of the macro in const contexts.
Closes https://github.com/Gilnaa/memoffset/issues/4
2022-12-11 21:53:36 +02:00
Gilad Naaman
f1fcd46d16
Update docs WRT repr(Rust) ( #69 )
...
Issue:
- https://github.com/Gilnaa/memoffset/issues/59
2022-10-16 16:49:41 +02:00
Gilad Naaman
d5f5514c7d
Add some compile-fail tests. ( #68 )
...
Ticket:
- https://github.com/Gilnaa/memoffset/issues/23
2022-10-10 21:00:44 +02:00
Gilad Naaman
e28945c4ff
Update src/raw_field.rs
...
Co-authored-by: Ralf Jung <post@ralfj.de >
2022-10-10 20:46:09 +03:00
Gilad Naaman
e963055298
Update src/offset_of.rs
...
Co-authored-by: Ralf Jung <post@ralfj.de >
2022-10-10 20:45:55 +03:00
Gilad Naaman
9af1ea0b8e
Support unions in offset_of(_union)
2022-10-10 17:48:18 +03:00
yvt
757c7ece28
Suppress clippy::unneeded_wildcard_pattern ( #64 )
2022-02-23 22:19:16 -05:00
yvt
a0e5563c97
Remove #![feature(const_raw_ptr_deref)]
...
It's now stable in nightly.
2021-12-03 22:22:23 +09:00
yvt
e3bcb9ebf4
Remove #![feature(const_maybe_uninit_as_ptr)]
...
It's now stable in nightly.
2021-12-03 22:21:14 +09:00
Aleksey Kladov
db4bebb157
Modernize doc examples to use idiomatic Rust
2021-11-12 13:34:44 +03:00
Ralf Jung
3b62693126
update feature flags and docs for const offset_of
2021-03-28 18:59:07 +02:00
Ralf Jung
e7a50fcff7
fix build on old rustc
2021-03-27 15:30:05 +01:00
Ralf Jung
8c73417444
move mem and ptr into __priv
2021-03-27 15:26:49 +01:00
Ralf Jung
fb1961c64a
avoid use of size_of_val in span_of
2021-03-27 15:21:43 +01:00
Ralf Jung
c4263a9d94
rename _memoffset_offset_from macro to reflect that it is unsafe to call
2021-03-26 09:52:02 +01:00
Ralf Jung
78dbf5752f
avoid putting user code inside unsafe blocks
2021-03-26 00:01:10 +01:00
Boqun Feng
8c9b3eddcf
Use stablilized addr_of! macro ( #50 )
...
Since Rust 1.51.0, support for macro addr_of! has been stabilized[1],
and this provides a way to get a raw pointer without potential UB in
some cases.
Memoffset alreadly uses the feature at the pre-stablilized stage (the
macro was named as raw_const! then). Therefore, switch to use the
stablilized version (and name) if Rust 1.51.0 and above is used,
otherwise use the original fallback version, which works in a less
technically correct way.
[1]: https://github.com/rust-lang/rust/pull/72279
Signed-off-by: Boqun Feng <boqun.feng@gmail.com >
2021-03-08 19:56:59 +01:00
Andrew Gaspar
7dc779f328
Support tuples in offset_of ( #48 )
...
Support tuple types via new offset_of_tuple / raw_field_tuple macros
2020-10-23 09:16:25 +02:00
Ralf Jung
72768daee9
use MaybeUninit::as_ptr instead of transmute
2020-08-09 18:44:38 +02:00
Roland
608e11823e
Remove const_transmute feature dependency ( #45 )
...
Remove `const_transmute` feature flag
`const_transmute` has been stabilized on current nightly, see https://github.com/rust-lang/rust/pull/72920 .
Document `const_fn_transmute` requirement when using `offset_of!` inside a `const fn`.
Add test for `offset_of!` inside a `const fn`.
2020-07-31 00:21:18 +02:00
Ralf Jung
b1cb4ee2b8
fix allow_clippy
2020-06-22 10:43:53 +02:00
Ralf Jung
fcbad2f16e
share more code in raw_field
2020-06-22 10:07:50 +02:00
Ralf Jung
525c81e24f
factor difference between const and non-const into sub-macro
2020-06-22 10:06:53 +02:00
Ralf Jung
9db8a15115
make the const variant closer to the normal variant (just the offset part is different)
2020-06-21 12:12:34 +02:00
Ralf Jung
78014026d9
span_of: use raw_field macro for more safety
2020-06-21 12:00:25 +02:00
Ralf Jung
f4c1d18544
move raw_field macro to its own file
2020-06-21 11:53:48 +02:00
Ralf Jung
720e392281
fmt
2020-06-20 15:02:40 +02:00
Ralf Jung
3f21c8bba3
add support for using raw_ref macros
2020-06-20 14:23:50 +02:00
Ralf Jung
1280f5b8ac
rustfmt
2020-03-16 17:33:13 +01:00
Ralf Jung
3d2481a427
avoid accessing libcore for compat with old Rust versions
2020-03-16 17:33:08 +01:00
Ralf Jung
f1642af871
add raw_field macro to compute raw ptr to field
2020-03-16 17:02:11 +01:00
AnthonyMikh
981db233dc
Fix a typo in comment
2020-03-10 02:07:14 +03:00
Ralf Jung
13ea44fbad
Merge pull request #36 from RalfJung/miri
...
better way to ignore tests in Miri
2019-12-11 16:44:56 +01:00
Ralf Jung
0ad6b6bb87
Merge pull request #35 from RalfJung/allow-clippy
...
allow clippy lint
2019-12-07 13:21:12 +01:00
Ralf Jung
aa4738c356
better way to ignore tests in Miri
2019-12-07 12:17:22 +01:00
Ralf Jung
9f13984808
allow clippy lint only on recent enough compilers
2019-11-17 20:47:03 +01:00
Ralf Jung
f8fbd6d073
remove redundant namespacing from some features
2019-11-17 20:45:27 +01:00
Gilad Naaman
176b647ccd
Added impl for constant offset_of
2019-11-16 22:34:38 +02:00
Ralf Jung
3708978129
allow clippy lint
2019-11-16 21:30:32 +01:00
Gilad Naaman
b17540333a
Fixed build for old nightlies where doctests were not present.
2019-11-07 18:43:17 +02:00
Gilad Naaman
a2f09d9436
Merge pull request #28 from RalfJung/comment
...
remove confusing comment
2019-08-29 07:02:08 +03:00
Ralf Jung
4b32562a82
Merge pull request #27 from Amanieu/path
...
Change the struct parameter from a tt to a path.
2019-08-28 20:13:23 +02:00
Ralf Jung
9e8633bf4e
remove confusing comment
2019-08-28 20:11:08 +02:00
Amanieu d'Antras
6ebc57dc9b
Change the struct parameter from a tt to a path.
...
This allows name paths with :: to be passed in.
2019-08-28 17:07:38 +01:00
Maarten de Vries
31cac3881f
Update library documentation to reflect removal of const implementation.
2019-08-28 15:45:59 +02:00
Ralf Jung
b5f5428525
explain why we do not have deref coercion problems
2019-08-10 15:11:59 +02:00
Ralf Jung
207a08c623
fmt
2019-08-10 11:59:57 +02:00
Ralf Jung
f734f5bbad
no need to use NonNull
2019-08-10 11:59:47 +02:00
Ralf Jung
b7e2959e55
test README only on nightly, so that it can be a dev-dependency
2019-08-10 11:43:04 +02:00
Ralf Jung
5151f6b2c1
fix testing README and fix README tests
2019-08-10 11:12:48 +02:00