<commit_before>// This file is part of Grust, GObject introspection bindings for Rust
//
// Copyright (C) 2015  <NAME> <<EMAIL>>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

use std::mem;

pub unsafe trait Wrapper {

    type Raw: Sized;

    #[inline]
    fn as_ptr(&self) -> *const <Self as Wrapper>::Raw {
        self as *const Self as *const <Self as Wrapper>::Raw
    }

    #[inline]
    fn as_mut_ptr(&self) -> *mut <Self as Wrapper>::Raw {
        self as *const Self as *mut <Self as Wrapper>::Raw
    }
}

#[inline]
pub unsafe fn from_raw<'a, T, U: ?Sized>(ptr: *const <T as Wrapper>::Raw,
                                         life_anchor: &'a U)
                                        -> &'a T
    where T: Wrapper
{
    mem::copy_lifetime(life_anchor, &*(ptr as *const T))
}

pub const STATIC: &'static () = &();<commit_msg>wrap: make the method .as_mut_ptr() unsafe<commit_after>// This file is part of Grust, GObject introspection bindings for Rust
//
// Copyright (C) 2015  <NAME> <<EMAIL>>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

use std::mem;

pub unsafe trait Wrapper {

    type Raw: Sized;

    #[inline]
    fn as_ptr(&self) -> *const <Self as Wrapper>::Raw {
        self as *const Self as *const <Self as Wrapper>::Raw
    }

    #[inline]
    unsafe fn as_mut_ptr(&self) -> *mut <Self as Wrapper>::Raw {
        self as *const Self as *mut <Self as Wrapper>::Raw
    }
}

#[inline]
pub unsafe fn from_raw<'a, T, U: ?Sized>(ptr: *const <T as Wrapper>::Raw,
                                         life_anchor: &'a U)
                                        -> &'a T
    where T: Wrapper
{
    mem::copy_lifetime(life_anchor, &*(ptr as *const T))
}

pub const STATIC: &'static () = &();
{'fraction_non_alphanumeric': 0.10705128205128205, 'fraction_numerical': 0.010897435897435897, 'mean_word_length': 2.6804245283018866, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1617074', 'n_tokens_mistral': 904, 'n_tokens_neox': 875, 'n_words': 412}