Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple repl example #57

Merged
merged 3 commits into from Jul 28, 2020
Merged

Add a simple repl example #57

merged 3 commits into from Jul 28, 2020

Conversation

bjorn3
Copy link
Contributor

@bjorn3 bjorn3 commented Jul 27, 2020

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

@nbaksalyar
Copy link
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
Copy link
Contributor Author

bjorn3 commented Jul 27, 2020

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

@nbaksalyar
Copy link
Member

nbaksalyar commented Jul 27, 2020

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
1 check passed
@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.

None yet

2 participants