Debian Codegraph @

src/init.rs

raw symbols SCIP
1 use proc_macro2rust-analyzer cargo proc-macro2 1.0.66 crate/::{Identrust-analyzer cargo proc-macro2 1.0.66 Ident#, Spanrust-analyzer cargo proc-macro2 1.0.66 Span#, TokenStreamrust-analyzer cargo proc-macro2 1.0.66 TokenStream#};
2 use quoterust-analyzer cargo quote 1.0.32 crate/::quoterust-analyzer cargo quote 1.0.32 quote!;
3 use synrust-analyzer cargo syn 2.0.28 crate/::{Errorrust-analyzer cargo syn 2.0.28 error/Error#, ItemFnrust-analyzer cargo syn 2.0.28 item/ItemFn#};
4
5 pub fn expandrust-analyzer cargo magnus-macros 0.8.0 init/expand().(name: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>, input: ItemFnrust-analyzer cargo syn 2.0.28 item/ItemFn#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<TokenStreamrust-analyzer cargo proc-macro2 1.0.66 TokenStream#, Errorrust-analyzer cargo syn 2.0.28 error/Error#> {
6 let crate_name = match name {
7 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) => v,
8 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => match stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::envrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/::varrust-analyzer cargo std https://github.com/rust-lang/rust/library/std env/var().("CARGO_PKG_NAME") {
9 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(v) => v,
10 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => {
11 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo syn 2.0.28 error/Error#::newrust-analyzer cargo syn 2.0.28 error/impl#[Error]new().(
12 Spanrust-analyzer cargo proc-macro2 1.0.66 Span#::call_siterust-analyzer cargo proc-macro2 1.0.66 impl#[Span]call_site().(),
13 r#"missing (name = "...") attribute"#,
14 ))
15 }
16 },
17 };
18
19 let extern_init_name = Identrust-analyzer cargo proc-macro2 1.0.66 Ident#::newrust-analyzer cargo proc-macro2 1.0.66 impl#[Ident]new().(
20 &formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Init_{}", crate_name.replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('-', "_")),
21 Spanrust-analyzer cargo proc-macro2 1.0.66 Span#::call_siterust-analyzer cargo proc-macro2 1.0.66 impl#[Span]call_site().(),
22 );
23 let init_name = input.sigrust-analyzer cargo syn 2.0.28 item/ItemFn#sig..identrust-analyzer cargo syn 2.0.28 item/Signature#ident..clonerust-analyzer cargo proc-macro2 1.0.66 impl#[Ident][Clone]clone().();
24
25 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(quoterust-analyzer cargo quote 1.0.32 quote!! {
26 #input
27
28 #[allow(non_snake_case)]
29 #[no_mangle]
30 pub unsafe extern "C" fn #extern_init_name() {
31 use magnus::method::{Init, RubyInit};
32 #init_name.call_handle_error()
33 }
34 })
35 }