Right, but it doesn't make sense to have code like that which can only compile with the feature enabled (because then why does the feature even exist? You can't disable it!). So I assume you must be trying to use #[cfg(feature)] where you should be using something else.
To be clear: The purpose of #[cfg(feature)] is to make parts of your code optional. Stuff tagged with cfg(feature) disappears from the code when somebody depends on your library and doesn't enable the feature.
To probe a bit further: What kind of feature is this? Is it a feature you provide to consumers of your crate? Is it an unstable feature (like euclidean_division)? Did the docs of one of your dependencies say that such-and-such feature is required to use some function?
Thanks it works. thought it would be enough to add the feature when building the workspace
Edit: Do you know if I can achieve this with my settings.json in vscode?
Well, I'll be! That wasn't supposed to be the solution!
So both of these can be compiled in their own right? In that case, you can achieve what you want in a manner by adding a feature to the workspace. If your workspace only has a virtual manifest (i.e. a [members] table), try turning it into a full package by adding a [package] table, and replacing the members with path dependencies:
If you go this route you'll need to add a dummy lib.rs for the root package (or alternatively you can try to turn either the lib or the bin into your workspace root. Probably the bin since I imagine it already depends on the lib?).