Class: Codify::Rust::TypeAlias
- Inherits:
-
Definition
- Object
- Definition
- Codify::Rust::TypeAlias
- Defined in:
- lib/codify/rust/type_alias.rb
Instance Attribute Summary
Attributes inherited from Definition
#cfg_derives, #comment, #derives, #name
Instance Method Summary collapse
- #defaultible? ⇒ Boolean
-
#initialize(name, type, **kwargs, &block) ⇒ TypeAlias
constructor
A new instance of TypeAlias.
- #types ⇒ Array<Type>
- #write(out) ⇒ void
Methods inherited from Definition
#comment?, #primitive?, #to_rust_code, #to_s
Methods included from Type
#definition?, #each_subtype, #primitive?, #to_rust
Constructor Details
#initialize(name, type, **kwargs, &block) ⇒ TypeAlias
Returns a new instance of TypeAlias.
11 12 13 14 15 16 |
# File 'lib/codify/rust/type_alias.rb', line 11 def initialize(name, type, **kwargs, &block) super(name, **kwargs, derives: [], cfg_derives: []) raise ArgumentError, "#{type.inspect}" unless type.is_a?(Type) @type = type block.call(self) if block_given? end |
Instance Method Details
#defaultible? ⇒ Boolean
20 21 22 |
# File 'lib/codify/rust/type_alias.rb', line 20 def defaultible? @type.defaultible? end |
#write(out) ⇒ void
This method returns an undefined value.
31 32 33 34 |
# File 'lib/codify/rust/type_alias.rb', line 31 def write(out) super(out) out.puts "pub type #{@name} = #{@type};" end |