#![doc = include_str!("../README.md")]
#![cfg_attr(not(feature = "std"), no_std)]
mod lich;
mod shroud;
mod soul;
pub use lich::Lich;
#[cfg(feature = "shroud")]
pub use phylactery_macro::shroud;
pub use shroud::Shroud;
pub use soul::Soul;
#[allow(dead_code)]
mod fails {
macro_rules! fail {
($function: ident, $block: block) => {
#[doc = concat!("```compile_fail\n", stringify!($block), "\n```")]
const fn $function() {}
};
}
fail!(can_not_drop_while_soul_lives, {
use core::{cell::RefCell, pin::pin};
use phylactery::Soul;
let cell = RefCell::new(String::new());
let function = move |letter| cell.borrow_mut().push(letter);
let soul = Soul::new(&function);
drop(function);
});
fail!(can_not_clone_soul, {
use core::{cell::RefCell, pin::pin};
use phylactery::Soul;
let cell = RefCell::new(String::new());
let soul = Soul::new(move |letter| cell.borrow_mut().push(letter));
<Soul<_> as Clone>::clone(&soul);
});
fail!(can_not_send_unsync_to_thread, {
use core::pin::pin;
use phylactery::Soul;
use std::thread::spawn;
let soul = pin!(Soul::new(|| {}));
let lich = soul.as_ref().bind::<dyn Fn() + Send>();
spawn(move || lich());
});
}