45
45
< span class ="keyword "> struct</ span > < span class ="struct declaration "> HasUnsafeFn</ span > < span class ="punctuation "> ;</ span >
46
46
47
47
< span class ="keyword "> impl</ span > < span class ="struct "> HasUnsafeFn</ span > < span class ="punctuation "> {</ span >
48
- < span class ="keyword unsafe "> unsafe</ span > < span class ="keyword "> fn</ span > < span class ="function declaration unsafe "> unsafe_method</ span > < span class ="punctuation "> (</ span > < span class ="operator "> &</ span > < span class ="self_keyword "> self</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> {</ span > < span class ="punctuation "> }</ span >
48
+ < span class ="keyword unsafe "> unsafe</ span > < span class ="keyword "> fn</ span > < span class ="method declaration unsafe "> unsafe_method</ span > < span class ="punctuation "> (</ span > < span class ="operator "> &</ span > < span class ="self_keyword "> self</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> {</ span > < span class ="punctuation "> }</ span >
49
49
< span class ="punctuation "> }</ span >
50
50
51
51
< span class ="keyword "> struct</ span > < span class ="struct declaration "> TypeForStaticMut</ span > < span class ="punctuation "> {</ span >
60
60
< span class ="punctuation "> }</ span >
61
61
62
62
< span class ="keyword "> trait</ span > < span class ="trait declaration "> DoTheAutoref</ span > < span class ="punctuation "> {</ span >
63
- < span class ="keyword "> fn</ span > < span class ="function declaration "> calls_autoref</ span > < span class ="punctuation "> (</ span > < span class ="operator "> &</ span > < span class ="self_keyword "> self</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> ;</ span >
63
+ < span class ="keyword "> fn</ span > < span class ="method declaration "> calls_autoref</ span > < span class ="punctuation "> (</ span > < span class ="operator "> &</ span > < span class ="self_keyword "> self</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> ;</ span >
64
64
< span class ="punctuation "> }</ span >
65
65
66
66
< span class ="keyword "> impl</ span > < span class ="trait "> DoTheAutoref</ span > < span class ="keyword "> for</ span > < span class ="builtin_type "> u16</ span > < span class ="punctuation "> {</ span >
67
- < span class ="keyword "> fn</ span > < span class ="function declaration "> calls_autoref</ span > < span class ="punctuation "> (</ span > < span class ="operator "> &</ span > < span class ="self_keyword "> self</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> {</ span > < span class ="punctuation "> }</ span >
67
+ < span class ="keyword "> fn</ span > < span class ="method declaration "> calls_autoref</ span > < span class ="punctuation "> (</ span > < span class ="operator "> &</ span > < span class ="self_keyword "> self</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> {</ span > < span class ="punctuation "> }</ span >
68
68
< span class ="punctuation "> }</ span >
69
69
70
70
< span class ="keyword "> fn</ span > < span class ="function declaration "> main</ span > < span class ="punctuation "> (</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> {</ span >
78
78
< span class ="union "> Union</ span > < span class ="punctuation "> {</ span > < span class ="field unsafe "> b</ span > < span class ="punctuation "> :</ span > < span class ="numeric_literal "> 0</ span > < span class ="punctuation "> }</ span > < span class ="operator "> =></ span > < span class ="punctuation "> (</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> ,</ span >
79
79
< span class ="union "> Union</ span > < span class ="punctuation "> {</ span > < span class ="field unsafe "> a</ span > < span class ="punctuation "> }</ span > < span class ="operator "> =></ span > < span class ="punctuation "> (</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> ,</ span >
80
80
< span class ="punctuation "> }</ span >
81
- < span class ="struct "> HasUnsafeFn</ span > < span class ="operator "> .</ span > < span class ="function unsafe "> unsafe_method</ span > < span class ="punctuation "> (</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> ;</ span >
81
+ < span class ="struct "> HasUnsafeFn</ span > < span class ="operator "> .</ span > < span class ="method unsafe "> unsafe_method</ span > < span class ="punctuation "> (</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> ;</ span >
82
82
83
83
< span class ="comment "> // unsafe deref</ span >
84
84
< span class ="keyword "> let</ span > < span class ="variable declaration "> y</ span > < span class ="operator "> =</ span > < span class ="operator unsafe "> *</ span > < span class ="variable "> x</ span > < span class ="punctuation "> ;</ span >
94
94
< span class ="keyword "> let</ span > < span class ="struct "> Packed</ span > < span class ="punctuation "> {</ span > < span class ="field "> a</ span > < span class ="punctuation "> :</ span > < span class ="keyword unsafe "> ref</ span > < span class ="variable declaration "> _a</ span > < span class ="punctuation "> }</ span > < span class ="operator "> =</ span > < span class ="variable "> packed</ span > < span class ="punctuation "> ;</ span >
95
95
96
96
< span class ="comment "> // unsafe auto ref of packed field</ span >
97
- < span class ="variable "> packed</ span > < span class ="operator "> .</ span > < span class ="field "> a</ span > < span class ="operator "> .</ span > < span class ="function unsafe "> calls_autoref</ span > < span class ="punctuation "> (</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> ;</ span >
97
+ < span class ="variable "> packed</ span > < span class ="operator "> .</ span > < span class ="field "> a</ span > < span class ="operator "> .</ span > < span class ="method unsafe "> calls_autoref</ span > < span class ="punctuation "> (</ span > < span class ="punctuation "> )</ span > < span class ="punctuation "> ;</ span >
98
98
< span class ="punctuation "> }</ span >
99
99
< span class ="punctuation "> }</ span > </ code > </ pre >
0 commit comments