@@ -6,9 +6,10 @@ pub trait LuaObj {
6
6
fn clone_box ( & self ) -> Box < LuaObj > ;
7
7
/// Checks whther the underlying type is a float or an int.
8
8
fn is_number ( & self ) -> bool ;
9
- /// Checks whether the underlying type is converted to a float when processed in
10
- /// arithmetic expressions.
11
- fn is_float ( & self ) -> bool ;
9
+ /// Returns true if the underlying type is either a float or a string.
10
+ /// In Lua, if either of these two types are used in an arithmetic
11
+ /// expression, then both arguments are converted to floats.
12
+ fn is_aop_float ( & self ) -> bool ;
12
13
/// Checks whether the underlying type is a string or not.
13
14
fn is_string ( & self ) -> bool ;
14
15
/// Converts the underlying type to an int.
@@ -17,6 +18,10 @@ pub trait LuaObj {
17
18
fn to_float ( & self ) -> Result < f64 , LuaError > ;
18
19
/// Converts the underlying type to a string.
19
20
fn to_string ( & self ) -> Result < String , LuaError > ;
21
+ /// Gets a reference to the underlying string.
22
+ fn get_string_ref ( & self ) -> Option < & str > {
23
+ None
24
+ }
20
25
}
21
26
22
27
/// Boxes the given `LuaObj`, and returns the address of the box.
@@ -43,7 +48,7 @@ impl LuaObj for LuaInt {
43
48
true
44
49
}
45
50
46
- fn is_float ( & self ) -> bool {
51
+ fn is_aop_float ( & self ) -> bool {
47
52
false
48
53
}
49
54
@@ -73,7 +78,7 @@ impl LuaObj for LuaFloat {
73
78
true
74
79
}
75
80
76
- fn is_float ( & self ) -> bool {
81
+ fn is_aop_float ( & self ) -> bool {
77
82
true
78
83
}
79
84
@@ -107,7 +112,7 @@ impl LuaObj for LuaString {
107
112
false
108
113
}
109
114
110
- fn is_float ( & self ) -> bool {
115
+ fn is_aop_float ( & self ) -> bool {
111
116
true
112
117
}
113
118
@@ -126,4 +131,8 @@ impl LuaObj for LuaString {
126
131
fn to_string ( & self ) -> Result < String , LuaError > {
127
132
Ok ( self . v . clone ( ) )
128
133
}
134
+
135
+ fn get_string_ref ( & self ) -> Option < & str > {
136
+ Some ( & self . v )
137
+ }
129
138
}
0 commit comments