Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
NightEule5 committed Jun 10, 2024
1 parent 5919070 commit 82edc16
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
10 changes: 7 additions & 3 deletions src/generate/gen_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ impl<'a, P: Parent> GenEnum<'a, P> {
/// }
/// ```
pub fn append_generics(&mut self, generics: impl IntoIterator<Item = Generic>) -> &mut Self {
self.generics.get_or_insert_with(|| Generics(Vec::new())).extend(generics);
self.generics
.get_or_insert_with(|| Generics(Vec::new()))
.extend(generics);
self
}

Expand Down Expand Up @@ -147,7 +149,9 @@ impl<'a, P: Parent> GenEnum<'a, P> {
/// }
/// ```
pub fn add_generic(&mut self, generic: Generic) -> &mut Self {
self.generics.get_or_insert_with(|| Generics(Vec::new())).push(generic);
self.generics
.get_or_insert_with(|| Generics(Vec::new()))
.push(generic);
self
}

Expand Down Expand Up @@ -209,7 +213,7 @@ impl<'a, P: Parent> Drop for GenEnum<'a, P> {
.append(
self.generics()
.map(Generics::impl_generics)
.unwrap_or_default()
.unwrap_or_default(),
)
.group(Delimiter::Brace, |b| {
for value in &self.values {
Expand Down
31 changes: 16 additions & 15 deletions src/generate/gen_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ impl<'a, P: Parent> GenStruct<'a, P> {
self.visibility = Visibility::Pub;
self
}

/// Inherit the generic parameters of the parent type.
///
///
/// ```
/// # use virtue::prelude::Generator;
/// # let mut generator = Generator::with_name("Bar").with_lifetime("a");
Expand All @@ -96,7 +96,7 @@ impl<'a, P: Parent> GenStruct<'a, P> {
/// # generator.assert_eq("struct Foo < 'a > { bar : &'a str , }");
/// # Ok::<_, virtue::Error>(())
/// ```
///
///
/// Generates:
/// ```ignore
/// // given a derive on struct Bar<'a>
Expand All @@ -108,7 +108,7 @@ impl<'a, P: Parent> GenStruct<'a, P> {
self.generics = self.parent.generics().cloned();
self
}

/// Append generic parameters to the type.
///
/// ```
Expand All @@ -131,10 +131,12 @@ impl<'a, P: Parent> GenStruct<'a, P> {
/// }
/// ```
pub fn append_generics(&mut self, generics: impl IntoIterator<Item = Generic>) -> &mut Self {
self.generics.get_or_insert_with(|| Generics(Vec::new())).extend(generics);
self.generics
.get_or_insert_with(|| Generics(Vec::new()))
.extend(generics);
self
}

/// Add a generic parameter to the type.
///
/// ```
Expand All @@ -157,7 +159,9 @@ impl<'a, P: Parent> GenStruct<'a, P> {
/// }
/// ```
pub fn add_generic(&mut self, generic: Generic) -> &mut Self {
self.generics.get_or_insert_with(|| Generics(Vec::new())).push(generic);
self.generics
.get_or_insert_with(|| Generics(Vec::new()))
.push(generic);
self
}

Expand Down Expand Up @@ -248,14 +252,11 @@ impl<'a, P: Parent> Drop for GenStruct<'a, P> {
if self.visibility == Visibility::Pub {
builder.ident_str("pub");
}
builder
.ident_str("struct")
.ident(self.name.clone())
.append(
self.generics()
.map(Generics::impl_generics)
.unwrap_or_default()
);
builder.ident_str("struct").ident(self.name.clone()).append(
self.generics()
.map(Generics::impl_generics)
.unwrap_or_default(),
);

match self.struct_type {
StructType::Named => builder
Expand Down

0 comments on commit 82edc16

Please sign in to comment.