Skip to content

Commit

Permalink
More documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed May 16, 2024
1 parent 36e02e6 commit ebd90b4
Show file tree
Hide file tree
Showing 14 changed files with 363 additions and 28 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ jobs:
- run: cargo test --doc --features test
if: matrix.rust == 'stable'

unexpected_lints:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: sed -i '/#!\[allow(unexpected_cfgs)\]/d' crates/*/src/lib.rs tests/src/lib.rs
- run: cargo check --all-features --all-targets
env:
RUSTFLAGS: -D warnings --check-cfg=cfg(rune_nightly,doc_cfg) -F unexpected_cfgs

tests_clippy:
runs-on: ubuntu-latest
needs: features
Expand Down
1 change: 1 addition & 0 deletions crates/musli-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! [Müsli]: https://docs.rs/musli

#![deny(missing_docs)]
#![allow(unexpected_cfgs)]
#![no_std]
#![cfg_attr(doc_cfg, feature(doc_cfg))]

Expand Down
4 changes: 4 additions & 0 deletions crates/musli-zerocopy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
//! functions.
//! * [`swiss`] is a port of the [`hashbrown` crate] which is a Google
//! SwissTable implementation.
//! * [`trie`] is an implementation of a prefix-trie, which supports efficient
//! multi-value byte-prefixed lookups.
//!
//! Finally if you're interested in the performance of `musli-zerocopy` you
//! should go to [`benchmarks`]. I will be extending this suite with more
Expand Down Expand Up @@ -514,6 +516,7 @@
//! [`requested()`]: https://docs.rs/musli-zerocopy/latest/musli_zerocopy/struct.OwnedBuf.html#method.requested
//! [`Size`]: https://docs.rs/musli-zerocopy/latest/musli_zerocopy/pointer/trait.Size.html
//! [`swiss`]: https://docs.rs/musli-zerocopy/latest/musli_zerocopy/swiss/index.html
//! [`trie`]: https://docs.rs/musli-zerocopy/latest/musli_zerocopy/trie/index.html
//! [`with_byte_order::<E>()`]: https://docs.rs/musli-zerocopy/latest/musli_zerocopy/buf/struct.OwnedBuf.html#method.with_byte_order
//! [`ZeroCopy`]: https://docs.rs/musli-zerocopy/latest/musli_zerocopy/trait.ZeroCopy.html
//! [derive]: https://docs.rs/musli-zerocopy/latest/musli_zerocopy/derive.ZeroCopy.html
Expand All @@ -522,6 +525,7 @@
#![no_std]
#![allow(clippy::module_inception)]
#![allow(clippy::enum_variant_names)]
#![allow(unexpected_cfgs)]
#![deny(missing_docs)]
#![cfg_attr(all(rune_nightly), feature(repr128))]
#![cfg_attr(all(rune_nightly), allow(incomplete_features))]
Expand Down
12 changes: 4 additions & 8 deletions crates/musli-zerocopy/src/pointer/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ use crate::traits::ZeroCopy;
/// The default [`Size`] to use.
pub type DefaultSize = u32;

#[cfg(not(any(
target_pointer_width = "32",
target_pointer_width = "64",
target_pointer_width = "128"
)))]
compile_error!("musli-zerocopy is only supported on 32, 64, or 128-bit platforms");
#[cfg(not(any(target_pointer_width = "32", target_pointer_width = "64",)))]
compile_error!("musli-zerocopy is only supported on 32, 64-bit platforms");

mod sealed {
pub trait Sealed {}
impl Sealed for u8 {}
impl Sealed for u16 {}
impl Sealed for u32 {}
#[cfg(any(target_pointer_width = "64", target_pointer_width = "128"))]
#[cfg(target_pointer_width = "64")]
impl Sealed for u64 {}
impl Sealed for usize {}
}
Expand Down Expand Up @@ -149,6 +145,6 @@ macro_rules! impl_size {
impl_size!(u8, core::convert::identity);
impl_size!(u16, E::swap_u16);
impl_size!(u32, E::swap_u32);
#[cfg(any(target_pointer_width = "64", target_pointer_width = "128"))]
#[cfg(target_pointer_width = "64")]
impl_size!(u64, E::swap_u64);
impl_size!(usize, core::convert::identity);
16 changes: 0 additions & 16 deletions crates/musli-zerocopy/src/swiss/raw/bitmask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,6 @@ impl IntoIterator for BitMask {
#[derive(Copy, Clone)]
pub(crate) struct BitMaskIter(pub(crate) BitMask);

impl BitMaskIter {
/// Flip the bit in the mask for the entry at the given index.
///
/// Returns the bit's previous state.
#[inline]
#[allow(clippy::cast_ptr_alignment)]
#[cfg(feature = "raw")]
pub(crate) unsafe fn flip(&mut self, index: usize) -> bool {
// NOTE: The + BITMASK_STRIDE - 1 is to set the high bit.
let mask = 1 << (index * BITMASK_STRIDE + BITMASK_STRIDE - 1);
self.0 .0 ^= mask;
// The bit was set if the bit is now 0.
self.0 .0 & mask == 0
}
}

impl Iterator for BitMaskIter {
type Item = usize;

Expand Down
1 change: 1 addition & 0 deletions crates/musli/src/descriptive/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ impl<const OPT: Options, M> Encoding<OPT, M> {

crate::encoding_impls!(
M,
descriptive,
SelfEncoder::<_, OPT, _>::new,
SelfDecoder::<_, OPT, _>::new
);
Expand Down
2 changes: 1 addition & 1 deletion crates/musli/src/json/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl<M> Encoding<M> {
JsonDecoder::new(cx, SliceParser::new(bytes)).decode()
}

crate::encode_with_extensions!(M);
crate::encode_with_extensions!(M, json);
}

impl<M> Clone for Encoding<M> {
Expand Down
1 change: 1 addition & 0 deletions crates/musli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@

#![deny(missing_docs)]
#![allow(clippy::module_inception)]
#![allow(unexpected_cfgs)]
#![no_std]
#![cfg_attr(doc_cfg, feature(doc_cfg))]

Expand Down
Loading

0 comments on commit ebd90b4

Please sign in to comment.