use core::fmt;
#[cfg(feature = "doc")]
use crate::alloc::Box;
use crate::compile::{ContextError, Docs};
pub struct ItemMut<'a> {
pub(super) docs: &'a mut Docs,
#[cfg(feature = "doc")]
pub(super) deprecated: &'a mut Option<Box<str>>,
}
impl ItemMut<'_> {
pub fn docs(self, docs: impl IntoIterator<Item: AsRef<str>>) -> Result<Self, ContextError> {
self.docs.set_docs(docs)?;
Ok(self)
}
pub fn static_docs(self, docs: &'static [&'static str]) -> Result<Self, ContextError> {
self.docs.set_docs(docs)?;
Ok(self)
}
pub fn deprecated<S>(
self,
#[cfg_attr(not(feature = "doc"), allow(unused))] deprecated: S,
) -> Result<Self, ContextError>
where
S: AsRef<str>,
{
#[cfg(feature = "doc")]
{
*self.deprecated = Some(deprecated.as_ref().try_into()?);
}
Ok(self)
}
}
impl fmt::Debug for ItemMut<'_> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ItemMut").finish_non_exhaustive()
}
}