Add Value::function_name() for def/lambda/native callables#183
Closed
connyay wants to merge 3 commits into
Closed
Conversation
Exposes callable names to embedders. The underlying fields (Def::def_info.name, NativeFunction::name) are pub(crate), so this isn't reachable from outside the starlark crate today.
|
@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D102210564. (Because this pull request was imported automatically, there will not be any future comments.) |
meta-codesync Bot
pushed a commit
that referenced
this pull request
May 19, 2026
Summary:
Adds `Value::function_name(self) -> Option<&'v str>`. Returns the name for `Def`, `FrozenDef`, and `NativeFunction`; `None` for everything else.
Motivation: embedders often build host-side constructors like `handler("name", run=my_fn)` and then want the name of the callable that got passed in so they can stash it and call it later through Evaluator or the module registry. The underlying fields (`Def::def_info.name`, `NativeFunction::name`) are `pub(crate)`, so today you can't do this from outside the starlark crate without reaching into crate-private state.
Pull Request resolved: #183
Reviewed By: JakobDegen
Differential Revision: D102210564
fbshipit-source-id: 5e71480ef51ee3758ed6cfc799803bb112604ed9
meta-codesync Bot
pushed a commit
to facebook/buck2
that referenced
this pull request
May 19, 2026
Summary:
Adds `Value::function_name(self) -> Option<&'v str>`. Returns the name for `Def`, `FrozenDef`, and `NativeFunction`; `None` for everything else.
Motivation: embedders often build host-side constructors like `handler("name", run=my_fn)` and then want the name of the callable that got passed in so they can stash it and call it later through Evaluator or the module registry. The underlying fields (`Def::def_info.name`, `NativeFunction::name`) are `pub(crate)`, so today you can't do this from outside the starlark crate without reaching into crate-private state.
X-link: facebook/starlark-rust#183
Reviewed By: JakobDegen
Differential Revision: D102210564
fbshipit-source-id: 5e71480ef51ee3758ed6cfc799803bb112604ed9
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
Value::function_name(self) -> Option<&'v str>. Returns the name forDef,FrozenDef, andNativeFunction;Nonefor everything else.Motivation: embedders often build host-side constructors like
handler("name", run=my_fn)and then want the name of the callable that got passed in so they can stash it and call it later through Evaluator or the module registry. The underlying fields (Def::def_info.name,NativeFunction::name) arepub(crate), so today you can't do this from outside the starlark crate without reaching into crate-private state.