Use nested trusted function to wrap an unsafe cast