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

Add Value::borrow_any_{ref,mut} to get a typed reference without ownership #672

Merged
merged 4 commits into from
Mar 1, 2024

Conversation

dstoza
Copy link
Contributor

@dstoza dstoza commented Feb 29, 2024

No description provided.

@dstoza dstoza marked this pull request as ready for review February 29, 2024 18:42
@@ -1335,6 +1335,23 @@ impl Value {
VmResult::Ok(vm_try!(Future::from_value(value)))
}

/// Get the value as a typed value.
#[inline]
pub fn as_any<T>(&self) -> Result<BorrowRef<'_, T>, RuntimeError>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Naming when there's this many methods is tricky, and something I'll definitely want to go over before the next release. The pattern with the macros currently is:

  • borrow_<type>_ref
  • borrow_<type>_mut
  • into_<type>_ref
  • into_<type>_mut

But this doesn't mesh well with any. But maybe this as a result should be borrow_any_ref?

@dstoza dstoza changed the title Add Value::as_any to get a typed reference without ownership Add Value::borrow_any_{ref,mut} to get a typed reference without ownership Mar 1, 2024
@udoprog
Copy link
Collaborator

udoprog commented Mar 1, 2024

Thanks!

@udoprog udoprog merged commit dfc9b8e into rune-rs:main Mar 1, 2024
19 checks passed
@dstoza dstoza deleted the stoza/value-as-any branch March 1, 2024 22:48
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