Module: Rust::Types
- Defined in:
- lib/rust_require/types.rb,
lib/rust_require/types/string.rb,
lib/rust_require/types/primitives.rb
Overview
Implement primitive types:
Defined Under Namespace
Classes: Bool, F32, F64, Isize, Nil, PrimitiveInteger, StrSlice, String, Type, Usize
Class Method Summary collapse
-
.find_type(rust_type) ⇒ Object
returns type instance for rust_type.
Class Method Details
.find_type(rust_type) ⇒ Object
returns type instance for rust_type
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rust_require/types.rb', line 23 def self.find_type(rust_type) # find types in module constants type = constants .map { |c| const_get(c) } .keep_if { |c| c.is_a?(Class) && c.ancestors.include?(Type) && c != Type} #just Type subclass objects, excluding Type itself .map { |c| c.new } # instances of the Type classes .find { |c| c.rust_type_regex =~ rust_type } if type type.rust_type = rust_type type else raise NotImplementedError, "type #{rust_type} is not implemented!" end end |