Class: Makit::Cli::Generators::Templates::Rust::MainRs

Inherits:
Object
  • Object
show all
Defined in:
lib/makit/cli/generators/templates/rust_templates.rb

Overview

Template for generating main.rs source file

This template creates the entry point for a Rust application with a simple “Hello, world!” program.

Instance Method Summary collapse

Constructor Details

#initialize(project_name) ⇒ MainRs

Initialize the main.rs template

Parameters:

  • project_name (String)

    Name of the Rust project



44
45
46
# File 'lib/makit/cli/generators/templates/rust_templates.rb', line 44

def initialize(project_name)
  @project_name = project_name
end

Instance Method Details

#renderString

Render the main.rs file content

Returns:

  • (String)

    Rust source code for the main function



51
52
53
54
55
56
57
# File 'lib/makit/cli/generators/templates/rust_templates.rb', line 51

def render
  <<~RUST
    fn main() {
        println!("Hello, world!");
    }
  RUST
end