Skip to content

Commit

Permalink
derive: Fixes #18
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Apr 18, 2021
1 parent e3b520c commit 47f251a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
18 changes: 10 additions & 8 deletions reign_derive/src/framework/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ pub fn config(input: DeriveInput) -> TokenStream {
let scream = Ident::new(&to_screaming_snake_case(&ident.to_string()), ident.span());

quote! {
static #scream: ::reign::once_cell::sync::OnceCell<#ident> = ::reign::once_cell::sync::OnceCell::new();
const _: () = {
static #scream: ::reign::once_cell::sync::OnceCell<#ident> = ::reign::once_cell::sync::OnceCell::new();

impl ::reign::Config for #ident {
fn get() -> &'static Self {
#scream.get().expect("Config must be loaded before using it")
}
impl ::reign::Config for #ident {
fn get() -> &'static Self {
#scream.get().expect("Config must be loaded before using it")
}

fn cell() -> &'static ::reign::once_cell::sync::OnceCell<Self> {
&#scream
fn cell() -> &'static ::reign::once_cell::sync::OnceCell<Self> {
&#scream
}
}
}
};
}
}
8 changes: 4 additions & 4 deletions reign_derive/src/model/deleteable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ impl Model {
}

pub fn gen_tag_deleteable(&self, ident: &Ident, fields: &[ModelField]) -> TokenStream {
let gen_deleteable_methods = self.gen_deleteable_methods(ident, fields);
let gen_deleteable_actions = self.gen_deleteable_actions(ident, fields);
let gen_tag_deleteable_methods = self.gen_deleteable_methods(ident, fields);
let gen_tag_deleteable_actions = self.gen_deleteable_actions(ident, fields);

quote! {
#gen_deleteable_methods
#gen_deleteable_actions
#gen_tag_deleteable_methods
#gen_tag_deleteable_actions
}
}

Expand Down
1 change: 0 additions & 1 deletion src/cli/new/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub struct New {

impl New {
pub fn run(&self) -> Result<(), Error> {
// TODO: cli: Allow option to merge
let project = PathBuf::from(&self.name);

Template::new(&project)
Expand Down

0 comments on commit 47f251a

Please sign in to comment.