other-languages

here be heresies and things we have to use for work
borkdude 2020-02-25T14:41:40.000900Z

I'm trying to write a very simple Rust program that gets me the amount of free memory on my system. I'm using the heim create. How do I get this to compile?

use heim::memory as memory;
use heim::units::information;

async fn get_mem() -> u64 {
    let mem = memory::memory().await.unwrap();
    mem.free().get::<information::megabyte>()
}

async fn main() -> Result<()> {
    let free = get_mem().await;
    println!("Free memory: {}", free);
}
I know it's pretty bad to call .unwrap() like this, but I'm just trying ...

borkdude 2020-02-25T14:42:34.001200Z

This is the current output:

$ cargo run
   Compiling heimtry v0.1.0 (/Users/borkdude/Dropbox/dev/rust/heimtry)
error[E0107]: wrong number of type arguments: expected 2, found 1
 --> src/main.rs:9:20
  |
9 | async fn main() -> Result<()> {
  |                    ^^^^^^^^^^ expected 2 type arguments

error[E0277]: `main` has invalid return type `impl std::future::Future`
 --> src/main.rs:9:20
  |
9 | async fn main() -> Result<()> {
  |                    ^^^^^^^^^^ `main` can only return types that implement `std::process::Termination`
  |
  = help: consider using `()`, or a `Result
`

borkdude 2020-02-25T14:43:44.001500Z

cc @gklijs 🙂

borkdude 2020-02-25T14:52:54.002500Z

[dependencies]
heim = "0.0.10"

gklijs 2020-02-25T14:53:35.002700Z

I think the main itself should not be async, but I still have to read up on async, https://rust-lang.github.io/async-book/

borkdude 2020-02-25T14:53:53.002900Z

ah ok

gklijs 2020-02-25T15:20:19.004900Z

I just briefly used async because the kafka client started using them a lot, till I found out it wasn't supported in tests, so did it some other way. It's not that long in stable, so could be error messages could be improved.

borkdude 2020-02-25T15:23:32.005400Z

I guess I need to block on something, but don't know how. I'll keep reading the book 😉