Fork me on GitHub

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();<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 ...


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/
9 | async fn main() -> Result<()> {
  |                    ^^^^^^^^^^ expected 2 type arguments

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


heim = "0.0.10"


I think the main itself should not be async, but I still have to read up on async,


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.


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