Add #[must_use]
This commit is contained in:
@@ -30,6 +30,7 @@ pub struct Mut<T>(T);
|
||||
|
||||
/// Dereference into DynamicWriteLock
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn by_ref<T: Variant + Clone>(data: &mut Dynamic) -> DynamicWriteLock<T> {
|
||||
// Directly cast the &mut Dynamic into DynamicWriteLock to access the underlying data.
|
||||
data.write_lock::<T>()
|
||||
@@ -38,6 +39,7 @@ pub fn by_ref<T: Variant + Clone>(data: &mut Dynamic) -> DynamicWriteLock<T> {
|
||||
|
||||
/// Dereference into value.
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn by_value<T: Variant + Clone>(data: &mut Dynamic) -> T {
|
||||
if TypeId::of::<T>() == TypeId::of::<&str>() {
|
||||
// If T is `&str`, data must be `ImmutableString`, so map directly to it
|
||||
@@ -63,24 +65,30 @@ pub fn by_value<T: Variant + Clone>(data: &mut Dynamic) -> T {
|
||||
/// Trait to register custom Rust functions.
|
||||
pub trait RegisterNativeFunction<Args, Result> {
|
||||
/// Convert this function into a [`CallableFunction`].
|
||||
#[must_use]
|
||||
fn into_callable_function(self) -> CallableFunction;
|
||||
/// Get the type ID's of this function's parameters.
|
||||
#[must_use]
|
||||
fn param_types() -> Box<[TypeId]>;
|
||||
/// _(METADATA)_ Get the type names of this function's parameters.
|
||||
/// Exported under the `metadata` feature only.
|
||||
#[cfg(feature = "metadata")]
|
||||
#[must_use]
|
||||
fn param_names() -> Box<[&'static str]>;
|
||||
/// _(METADATA)_ Get the type ID of this function's return value.
|
||||
/// Exported under the `metadata` feature only.
|
||||
#[cfg(feature = "metadata")]
|
||||
#[must_use]
|
||||
fn return_type() -> TypeId;
|
||||
/// _(METADATA)_ Get the type name of this function's return value.
|
||||
/// Exported under the `metadata` feature only.
|
||||
#[cfg(feature = "metadata")]
|
||||
#[must_use]
|
||||
fn return_type_name() -> &'static str;
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn is_setter(_fn_name: &str) -> bool {
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
if _fn_name.starts_with(crate::engine::FN_SET) {
|
||||
|
Reference in New Issue
Block a user