Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v2.3.0 #170

Merged
merged 10 commits into from
Oct 31, 2022
Merged
34 changes: 32 additions & 2 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ impl<F: Form, S> TypeBuilder<F, S> {
self.type_params = type_params.into_iter().collect();
self
}

#[cfg(feature = "docs")]
/// Set the type documentation (for types in portable form).
pub fn docs_portable<I>(mut self, docs: I) -> Self
where
I: IntoIterator<Item = F::String>,
{
self.docs = docs.into_iter().collect();
self
}
}

impl<S> TypeBuilder<MetaForm, S> {
Expand Down Expand Up @@ -496,12 +506,22 @@ impl<F: Form, N, T> FieldBuilder<F, N, T> {
marker: PhantomData,
}
}

#[cfg(feature = "docs")]
/// Initialize the documentation of a field (for types in portable form, optional).
pub fn docs_portable<I>(mut self, docs: I) -> Self
ascjones marked this conversation as resolved.
Show resolved Hide resolved
where
I: IntoIterator<Item = F::String>,
{
self.docs = docs.into_iter().collect();
self
}
}

impl<N, T> FieldBuilder<MetaForm, N, T> {
#[cfg(feature = "docs")]
/// Initialize the documentation of a field (optional).
pub fn docs(self, docs: &'static [&'static str]) -> FieldBuilder<MetaForm, N, T> {
pub fn docs(self, docs: &'static [&'static str]) -> Self {
FieldBuilder {
name: self.name,
ty: self.ty,
Expand All @@ -514,7 +534,7 @@ impl<N, T> FieldBuilder<MetaForm, N, T> {
#[cfg(not(feature = "docs"))]
#[inline]
/// Doc capture is not enabled via the "docs" feature so this is a no-op.
pub fn docs(self, _docs: &'static [&'static str]) -> FieldBuilder<MetaForm, N, T> {
pub fn docs(self, _docs: &'static [&'static str]) -> Self {
self
}

Expand Down Expand Up @@ -638,6 +658,16 @@ impl<F: Form, S> VariantBuilder<F, S> {
self.fields = fields_builder.finalize();
self
}

#[cfg(feature = "docs")]
/// Initialize the variant's documentation (for types in portable form).
pub fn docs_portable<I>(mut self, docs: I) -> Self
where
I: IntoIterator<Item = F::String>,
{
self.docs = docs.into_iter().collect();
self
}
}

impl<S> VariantBuilder<MetaForm, S> {
Expand Down