-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
[docs] Attribute to indicate when a function became const
#76865
Comments
Right now, we don't even have an attribute to tell when a function was added at all, right? For the standard library, this is done via A related feature request would be for rustdoc to actually render the |
Having when an item was added would also be quite useful. What I've been doing with the time crate is just saying "this function is Has the docs team ever considered exposing something along the lines of |
I'm afraid I don't know. I am just saying, I think this issue should be phrased as a general "please expose the 'since' mechanism used in the standard library also to user crates" (aka "stabilize parts of I'll open a separate issue for showing "const-since" information in the standard library (EDIT: that would be #76998). |
My question is specifically relating to You could certainly make an argument that I shouldn't be modifying the signature at all, but I feel that progressive enhancement is best while maintaining MSRV. It's just that there's no clear way on how I should be documenting this. |
But the exact same thing applies to functions that only exist on sufficiently recent compilers (because older compilers lack some feature they require). I see nothing specific to const-fn here, so I don't see why the solution would be const-fn-specific. |
While true, I don't personally see a use-case where a function wouldn't exist on older compilers — the crate author is more likely to shim functionality or bump MSRV. But I see your view point. |
I think this is a duplicate of #79663. |
Coming back around to some issues that I created a long time ago. While not strictly a duplicate of #79663 (an attribute could be added without full stability capabilities), I think that issue is the best way forward on this issue. Closing for that reason. |
Having an attribute like
#[doc(const_since("Rust 1.45"))]
could be quite useful. It could be similar in appearance to#[doc(cfg(...))]
, and would likely be similar to implement.I believe the best design for an API like this would be accepting a string, such that the author could clarify whether it's Rust's version that matters or the crate's version (obviously for stdlib this doesn't matter).
The text was updated successfully, but these errors were encountered: