monty 0.0.21

A sandboxed, snapshotable Python interpreter written in Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
//! Implementation of the id() builtin function.

use crate::{args::ArgValues, bytecode::VM, defer_drop, exception_private::RunResult, value::Value};

/// Implementation of the id() builtin function.
///
/// Returns the identity of an object (unique integer for the object's lifetime).
pub fn builtin_id(vm: &mut VM<'_>, args: ArgValues) -> RunResult<Value> {
    let value = args.get_one_arg("id", vm.heap)?;
    defer_drop!(value, vm);

    Ok(value.id().into_value(vm.heap))
}