I'm trying to ignore rocket::get route macros when used as a library so the route functions can be used by another crate.
Now I have a feature library that is enabled in the [lib] table in Cargo.toml and not in [[bin]] then every route has #[cfg_attr(feature = "library", rocket::get(...))] is there a more straight forward way to do this?
Why not make them entirely separate functions? Then they can have whatever attributes you like, and they can be located in whichever artifact you like. That would probably be the standard solution.
Generally, you don't ever want the same code to be directly part of both a bin and lib crate. For example, a typical binary crate structure has src/main.rs and src/lib.rs, where lib.rs is always compiled as a library, and main.rs is compiled as a binary which depends on lib.rs. In this typical scenario, anything you want to run only when the crate is used as a binary would just be inside main.rs, rather than lib.rs.
Could you clarify your crate structure, and/or why this solution doesn't work for you?