Skip to content
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

RFC: codify unstable api #429

Merged
merged 1 commit into from
Dec 18, 2023
Merged

RFC: codify unstable api #429

merged 1 commit into from
Dec 18, 2023

Conversation

ratmice
Copy link
Collaborator

@ratmice ratmice commented Dec 18, 2023

This is an RFC for something that I thought of in the #428 pull request, which codifies the notion of unstable traits and function calls.

Using methods similar to those described by the matrix at, using features to selectively lift the restrictions:
https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/

It migrates the couple of methods that are marked unstable in the documentation to take token values indicating their instability.

There are 2 variations of these,

  1. InternalPublicApi, that are internal, but public by default (used in generated code).
  2. UnstableApi, require a feature to enable their visibility so that functions requiring the unstable token can be called.

The UnstableTrait function/feature is currently unused, but could be useful for #428.

@ltratt
Copy link
Member

ltratt commented Dec 18, 2023

I think I like it, but I need to get my head around a couple of the implications -- I'll try and get back to you on this soon!

lrlex/Cargo.toml Outdated
@@ -17,6 +17,10 @@ name = "lrlex"
name = "lrlex"
path = "src/lib/mod.rs"

[features]
_unstable_api_key = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the "key" suffix have a meaning? Should it just be unstable_api?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No not really, I was mostly thinking of the value of UnstableApi as a key to unlocking unstable_api, and that this feature basically just makes that value public.

the _ prefix does have effect though, in that I believe it hides the feature from cargo/docs.rs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, yes, I meant _unstable_api (I assumed that _ was a Python-esque convention, but if it's actually noticed by cargo doc even better!).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed in 505f05c, and did some documentation refinement.

@ltratt
Copy link
Member

ltratt commented Dec 18, 2023

Please squash.

@ratmice
Copy link
Collaborator Author

ratmice commented Dec 18, 2023

Squashed.

@ltratt ltratt added this pull request to the merge queue Dec 18, 2023
Merged via the queue into softdevteam:master with commit 0f30331 Dec 18, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants