[Help] Is there a way to detect all structs in the current crate that implement a certain trait?
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearVE
    VegOwOtenks
    Now 100%

    You could wrap the entirety of your file in a monster macro but you'd still have to assign the macro result to a variable you need to register, which doesn't sound viable to me at least.

    Maybe you can use a script that would extract all the trait implementations and create the boilerplate glue code for you, something like this:

    grep --recursive --only-matching "impl PluginFunction for \w*" functions/ | sed --quiet "s/functions\/\(.*\)\.rs:impl PluginFunction for \(\w*\)/crate::functions::\1::\2{}.register(\&mut functions_map)/p"
    

    I tried to recreate your situation locally but it may not match perfectly, maybe you'll have to adjust it a little. When I run it on my file tree which looks like this

    functions
    ├── attr.rs
    ├── export.rs
    └── render.rs
    
    1 directory, 3 files
    

    where every file has a content like this

    // comment
    
    pub struct MyAttrStructName {}
    
    impl PluginFunction for MyAttrStructName {
    
    }
    

    Then I receive the following output:

    crate::functions::attr::MyAttrStructName{}.register(&mut functions_map)
    crate::functions::export::MyExportStructName{}.register(&mut functions_map)
    crate::functions::render::MyRenderStructName{}.register(&mut functions_map)
    
    1
  • Regex flavors
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearVE
    VegOwOtenks
    Now 100%

    You can use backreferences \1 \2 etc. but you can also give them names explicitly.
    it looks like this: (?<name>inner-regex)
    Some flavors support it, kotlins doesn't apparently.

    25
  • ich_iel
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearVE
    VegOwOtenks
    Now 100%

    Ich bin leider jetzt furchtbar neugierig, wo die Vorlage herkommt, wonach kann ich bei knowyourmeme o.ä. suchen?

    2
  • Ah yes, organization.
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearVE
    VegOwOtenks
    Now 100%

    You can, another comment mentioned that. Only, I didn't mean to spread misinformation because I haven't used anything else in years.

    1
  • Ah yes, organization.
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearVE
    VegOwOtenks
    Now 100%

    Fair point. My browser (FF) supports 'search in tabs' as well and suggest it over a new search engine result when typed in the address bar. I don't know what about the style makes me think this, but it looks like FF on Windows in the Screenshot.

    6
  • [Gnome] Fedora greenery 🍁
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearVE
    VegOwOtenks
    Now 100%

    Love seeing a GNOME rice, I tried some GNOME ricing on a Fedora myself, however I was unable to get any further than installing Extensions 'Just Perfection' to hide some elements or using 'Burn my Windows', which I loved.

    What did you use to style your GNOME-Shell Components?

    4
  • "Initials" by "Florian Körner", licensed under "CC0 1.0". / Remix of the original. - Created with dicebear.comInitialsFlorian Körnerhttps://github.com/dicebear/dicebearVE
    Now
    6 9

    VegOwOtenks

    lemmy.world