Skip to content

Support cfg in rquickjs::methods #334

@Sytten

Description

@Sytten

Hi!
Right now there is really no easy way in stable rust (without rust-lang/rust#82679), to make methods conditional on the OS.

You cant do:

 #[cfg(unix)]
 #[qjs(get, enumerable)]
 pub fn atime_ms(&self) -> i64 {
     self.metadata.atime_nsec() / 1e6 as i64
 }

Since the cfg is evaluated after the methods macro.

I see two ways to get around that. One is allowing multiple methods macros (though I know this is hard). The other would be to support the cfg inside the macro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind:featureA request, idea or new functionalitytopic:macroRelated to macros

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions