v8/name.rs
1// Copyright 2019-2021 the Deno authors. All rights reserved. MIT license.
2
3use std::num::NonZeroI32;
4
5use crate::support::int;
6use crate::Name;
7
8extern "C" {
9 fn v8__Name__GetIdentityHash(this: *const Name) -> int;
10}
11
12impl Name {
13 /// Returns the V8 hash value for this value. The current implementation
14 /// uses a hidden property to store the identity hash.
15 ///
16 /// The return value will never be 0. Also, it is not guaranteed to be
17 /// unique.
18 #[inline(always)]
19 pub fn get_identity_hash(&self) -> NonZeroI32 {
20 unsafe { NonZeroI32::new_unchecked(v8__Name__GetIdentityHash(self)) }
21 }
22}