File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -679,6 +679,14 @@ impl AnyUserData {
679679 matches ! ( type_id, Some ( type_id) if type_id == TypeId :: of:: <T >( ) )
680680 }
681681
682+ /// Checks whether the type of this userdata is a [proxy object] for `T`.
683+ ///
684+ /// [proxy object]: crate::Lua::create_proxy
685+ #[ inline]
686+ pub fn is_proxy < T : ' static > ( & self ) -> bool {
687+ self . is :: < UserDataProxy < T > > ( )
688+ }
689+
682690 /// Borrow this userdata immutably if it is of type `T`.
683691 ///
684692 /// # Errors
Original file line number Diff line number Diff line change @@ -731,6 +731,9 @@ fn test_userdata_proxy() -> Result<()> {
731731 let globals = lua. globals ( ) ;
732732 globals. set ( "MyUserData" , lua. create_proxy :: < MyUserData > ( ) ?) ?;
733733
734+ assert ! ( !globals. get:: <AnyUserData >( "MyUserData" ) ?. is_proxy:: <( ) >( ) ) ;
735+ assert ! ( globals. get:: <AnyUserData >( "MyUserData" ) ?. is_proxy:: <MyUserData >( ) ) ;
736+
734737 lua. load (
735738 r#"
736739 assert(MyUserData.static_field == 123)
You can’t perform that action at this time.
0 commit comments