-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chrono feature in built_time() example on docs.rs #57
Comments
I'm sorry: What? |
What part is unclear? |
I don't understand your intention. Are you trying to use |
I'm suggesting it's a either a doc bug that the attribute #[cfg(feature = "chrono")] should pair with the built_time() definition (most likely), or if it's intended maybe I'm not enabling chrono correctly. As it is in your example project and my own crate, I have to remove this attribute or built_time() isn't found at compile time. |
The attribute in the docs document that the function is only available if |
I think you've just confirmed example_project's toml has
Yet
You can try this for yourself by adding the |
Ah, now I see your point. There is a bit of confusion here: When
to The feature-flag in the docs is there because |
Ok, I think things are a bit more clear now. I was able to build with That section on doc.rs could still use an update, and here's why. The What we really want is a way for cfg to check for a feature of an upstream crate. Is there really no way to do this? Something like |
The correct way to write this feature in the upstream's crate is
|
I had already played around with that. All that does is enable chrono for built, removing the need to do it in dependencies. My point still applies about the check That was the main point of this issue, that the cfg check on |
An example function built_time() appears for the latest (0.6.1) version of built on docs.rs
What is the proper way to enable the chrono feature to enable conditional compilation of built_time()? Maybe this cfg is no longer needed, because commenting it out includes the function. Note that that adding this to Cargo.toml has no effect.
The fix can be tested by adding built_time() before main() in built/example_project/src/main.rs and adding this to main():
You should see that built_time() is not found when the cfg is present, and the build succeeds if it's commented out.
The text was updated successfully, but these errors were encountered: