// Convert a foreign pointer to a `SyntaTree` reference, the tree is borrowed
// from forgein caller, therefore Rust shouldn't drop the content.
Convert a foreign pointer to a `SyntaTree` reference, the tree is borrowed
from forgein caller, therefore Rust shouldn't drop the content.
Convert a foreign pointer to a ` SyntaTree ` reference the tree is borrowed from forgein caller therefore Rust shouldn ' t drop the content .
pub unsafe fn ffi_pointer_as_ref(
        ptr: usize,
        text: &'a SourceText<'a>,
    ) -> Result<&'a Self, String> {
        let raw_tree = ptr as *mut SyntaxTree<'_, Syntax, State>;
        let tree = match raw_tree.as_mut() {
            Some(t) => t,
            None => return Err("null raw tree pointer".into()),
        };
        // The tree already contains source text, but this source text contains a pointer
        // into OCaml heap, which might have been invalidated by GC in the meantime.
        // Replacing the source text with a current one prevents it. This will still end
        // horribly if the tree starts storing some other pointers into source text,
        // but it's not the case at the moment.
        tree.replace_text_unsafe(text);
        Ok(tree)
    }
pub unsafe fn ffi_pointer_as_ref ( ptr : usize , text : & ' a SourceText < ' a > , ) -> Result < & ' a Self , String > { let raw_tree = ptr as * mut SyntaxTree < ' _ , Syntax , State > ; let tree = match raw_tree . as_mut ( ) { Some ( t ) => t , None => return Err ( " " . into ( ) ) , } ; // The tree already contains source text, but this source text contains a pointer // into OCaml heap, which might have been invalidated by GC in the meantime. // Replacing the source text with a current one prevents it. This will still end // horribly if the tree starts storing some other pointers into source text, // but it's not the case at the moment. tree . replace_text_unsafe ( text ) ; Ok ( tree ) }
Convert a foreign pointer to a `SyntaTree` reference, the tree is borrowed
from forgein caller, therefore Rust shouldn't drop the content.
Convert a foreign pointer to a ` SyntaTree ` reference the tree is borrowed from forgein caller therefore Rust shouldn ' t drop the content .
ptr
usize
text
&'a SourceText<'a>