flense 0.1.0

Purpose-oriented lensing
Documentation
#![cfg_attr(doc, doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/README.md")))]
//!
//! # no-std
//! This crate is no-std and no-alloc.
//!
//! # unsafe
//! Several traits in this crate are unsafe, like [`Adapter`]. If they are
//! implemented incorrectly, you will cause memory unsafety.

#![no_std]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg(test)]
extern crate std;

#[doc(hidden)]
mod type_lists;

pub mod lens;
pub mod lenses;
pub mod prelude;

/// A field that can be lensed.
pub trait Field {
    /// The type that this field points to.
    type Type;
}

/// Defines the position at which a [`Field`] can be accessed in `self`.
///
/// # Safety
/// 1. `(self.as_ptr()).byte_add(Self::OFFSET).cast::<F::Type>()` must point to
///    a valid instance of `F::Type` inside `self`.
pub unsafe trait Adapter<F>: Sized
where
    F: Field,
{
    /// The byte offset of the <code>[F](Field)::Type</code> in `self`.
    const OFFSET: usize;
}