Class: Rust::Types::F32
- Inherits:
-
Type
- Object
- Type
- Rust::Types::F32
show all
- Defined in:
- lib/rust_require/types/primitives.rb
Instance Attribute Summary
Attributes inherited from Type
#rust_type
Instance Method Summary
collapse
Methods inherited from Type
#c_input_type, #c_output_type, #ffi_input_type, #ffi_output_type, #initialize, #ruby_output_conversion, rust_type, #rust_type_regex
Instance Method Details
93
|
# File 'lib/rust_require/types/primitives.rb', line 93
def c_input_conversion(name); "#{name} as f32"; end
|
#c_output_conversion(name) ⇒ Object
94
|
# File 'lib/rust_require/types/primitives.rb', line 94
def c_output_conversion(name); "#{name} as f64"; end
|
#c_type ⇒ Object
Ruby Floats are always f64
92
|
# File 'lib/rust_require/types/primitives.rb', line 92
def c_type; 'f64'; end
|
#ffi_type ⇒ Object
96
|
# File 'lib/rust_require/types/primitives.rb', line 96
def ffi_type; :double; end
|
98
99
100
101
102
103
|
# File 'lib/rust_require/types/primitives.rb', line 98
def ruby_input_conversion(float)
bounds = -3.4028234663852886e+38 .. 3.4028234663852886e+38
raise ArgumentError, "#{float.inspect} is no Float." unless float.is_a? Float
raise ArgumentError, "#{float} is not in the expected input range #{bounds}" unless bounds.include? float
float
end
|