Skip to content

Add a simple repl example - #57

Merged
bjorn3 merged 3 commits into
headcrab-rs:masterfrom
bjorn3:repl_example
Jul 28, 2020
Merged

Add a simple repl example#57
bjorn3 merged 3 commits into
headcrab-rs:masterfrom
bjorn3:repl_example

Conversation

@bjorn3

@bjorn3 bjorn3 commented Jul 27, 2020

Copy link
Copy Markdown
Contributor

It only supports a subset of the functionality of headcrab, but it is a good example of how to use headcrab.

@nbaksalyar

Copy link
Copy Markdown
Member

This is very exciting, thanks! :)
If it's easier, the example can be disabled for macOS temporarily - we can create a separate issue to address it.

@bjorn3

bjorn3 commented Jul 27, 2020

Copy link
Copy Markdown
Contributor Author

I was already looking for a way to disable it on macOS. I can't find any.

@nbaksalyar

nbaksalyar commented Jul 27, 2020

Copy link
Copy Markdown
Member

I can't find any.

One hack is to use an empty fn main for all targets other than Linux and put all other code into an internal module.

E.g.:

#[cfg(target_os = "linux")]
fn main() {
  example::main();
}

#[cfg(not(target_os = "linux"))]
fn main() {
  println!("This example is not supported for OSes other than Linux");
}

and then the example implementation can be hidden in an internal module in a similar way:

#[cfg(target_os = "linux")]
mod example {
  struct Context { ... }

  fn main() {
    // the actual main function
  }
}

@bjorn3
bjorn3 merged commit c1312ca into headcrab-rs:master Jul 28, 2020
@bjorn3
bjorn3 deleted the repl_example branch July 28, 2020 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants