logo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::collections::hash_map::RandomState;

use crate::core::Hash;
use crate::error::Error;
use crate::ffi::InterpreterExtractError;
use crate::Artichoke;

impl Hash for Artichoke {
    type Error = Error;
    type GlobalBuildHasher = RandomState;

    fn global_build_hasher(&mut self) -> Result<&Self::GlobalBuildHasher, Self::Error> {
        let state = self.state.as_deref_mut().ok_or_else(InterpreterExtractError::new)?;
        Ok(&state.hash_builder)
    }
}