Skip to content

Commit

Permalink
cargo clippy -- -D clippy::all -D clippy::pedantic
Browse files Browse the repository at this point in the history
  • Loading branch information
hanepjiv committed Nov 30, 2024
1 parent cd12e86 commit eaf1528
Show file tree
Hide file tree
Showing 18 changed files with 1,213 additions and 1,406 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# =============================================================================
[package]
name = "elicit"
version = "0.12.3-alpha.0"
version = "0.12.3-alpha.1"
publish = false

keywords = ["utility"]
Expand Down
2 changes: 1 addition & 1 deletion elicit_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# =============================================================================
[package]
name = "elicit_macro"
version = "0.2.6"
version = "0.2.7"
publish = false

keywords = ["utility"]
Expand Down
48 changes: 26 additions & 22 deletions elicit_macro/src/aelicit_derive.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
// -*- mode:rust; coding:utf-8-unix; -*-

//! aelicit_derive.rs
//! `aelicit_derive.rs`
// Copyright 2024 hanepjiv
// @author hanepjiv <[email protected]>
// @copyright The MIT License (MIT) / Apache License Version 2.0
// @since 2024/04/14
// @date 2024/11/10
// @date 2024/11/30

// ////////////////////////////////////////////////////////////////////////////
// use =======================================================================
use crate::include::*;
use crate::include::{
quote, DeriveInput, Error, Ident, Result, Span, ToTokens, TokenStream2,
};
// ----------------------------------------------------------------------------
use crate::find_field_attr::find_field_attr;
// ////////////////////////////////////////////////////////////////////////////
Expand All @@ -36,7 +38,7 @@ pub(crate) fn expand(ast: DeriveInput) -> Result<TokenStream2> {
.require_list()?
.parse_args::<Ident>()?
.into_token_stream(),
)
);
}
_ => {}
}
Expand All @@ -51,40 +53,42 @@ pub(crate) fn expand(ast: DeriveInput) -> Result<TokenStream2> {
if aelicit_mod_author.is_none() {
return Err(Error::new(
Span::call_site(),
r###"#[derive(Debug, Aelicit)]
r"#[derive(Debug, Aelicit)]
#[aelicit_mod_author(AELICIT_MOD_AUTHOR)] // This attribute is necessary.
struct Derived {}
"###,
",
));
}

let ident = ast.ident;
let aelicit_impl = match aelicit_from_self_field {
Some(ref x) => quote! {self.#x.aelicit_from_self()},
None => quote! { None },
let aelicit_impl = if let Some(ref x) = aelicit_from_self_field {
quote! {self.#x.aelicit_from_self()}
} else {
quote! { None }
};
let _weak_assign_impl = match aelicit_from_self_field {
Some(ref x) => quote! {self.#x._weak_assign(_weak)},
None => quote! { Ok(()) },
let _weak_assign_impl = if let Some(ref x) = aelicit_from_self_field {
quote! {self.#x._weak_assign(_weak)}
} else {
quote! { Ok(()) }
};

Ok(quote! {
#[automatically_derived]
impl #aelicit_mod_author :: AelicitFromSelf for #ident {
fn aelicit_from_self(&self) ->
Option<#aelicit_mod_author :: Aelicit> {
#aelicit_impl
}
fn aelicit_from_self(&self) ->
Option<#aelicit_mod_author :: Aelicit> {
#aelicit_impl
}
}

#[automatically_derived]
impl #aelicit_mod_author :: WeakAssign for #ident {
fn _weak_assign(
&mut self,
_weak: #aelicit_mod_author :: WeakAelicitInner,
) -> elicit::Result<()> {
#_weak_assign_impl
}
fn _weak_assign(
&mut self,
_weak: #aelicit_mod_author :: WeakAelicitInner,
) -> elicit::Result<()> {
#_weak_assign_impl
}
}
})
}
Expand Down
Loading

0 comments on commit eaf1528

Please sign in to comment.