-
Notifications
You must be signed in to change notification settings - Fork 23
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
Probe const_fn #17
Comments
I had a couple new methods in mind: /// Tests whether the given expression can be used. The type may be `_` to let it be inferred
/// by the compiler, or even partially inferred like `Result<Vec<_>, _>`.
///
/// The test code is subject to change, but currently looks like:
///
/// ```ignore
/// pub fn probe() { let _: TYPE = EXPR; }
/// ```
pub fn probe_expression(&self, type_: &str, expr: &str) -> bool {
self.probe(format_args!("pub fn probe() {{ let _: {} = {}; }}", type_, expr))
}
/// Tests whether the given constant can be used.
///
/// The test code is subject to change, but currently looks like:
///
/// ```ignore
/// pub const PROBE: TYPE = INIT;
/// ```
pub fn probe_constant(&self, type_: &str, init: &str) -> bool {
self.probe(format_args!("pub const PROBE: {} = {};", type_, init))
} What do you think? |
Seems fine to add! Not sure if type is really necessary though, you can use If the user really needs type, they can write the let in block themselves |
In part, I was thinking about avoiding the I think tuples work though, even back to Rust 1.0, something like |
It would be sweet if it was possible to check not only if a certain path exists, but if it points to a const function. This looks like a significantly more involved check that those currently implemented, so perhaps it should exist just a recipe in the docs? See for an example: /~https://github.com/seanmonstar/unicase/pull/40/files/889d4761a67f7f61f950e98ab7f8ad5a60001039..39542760d0340195e4c5f14ed914d6ef1a3ca0f6#diff-a7b0a2dee0126cddf994326e705a91eaR12
The text was updated successfully, but these errors were encountered: