This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-02-25
Channels
- # announcements (9)
- # aws (50)
- # babashka (7)
- # beginners (95)
- # calva (10)
- # chlorine-clover (17)
- # cljdoc (11)
- # cljs-dev (4)
- # cljsrn (6)
- # clojars (25)
- # clojure (74)
- # clojure-belgium (4)
- # clojure-dev (17)
- # clojure-europe (3)
- # clojure-italy (23)
- # clojure-nl (3)
- # clojure-norway (5)
- # clojure-sanfrancisco (30)
- # clojure-spec (46)
- # clojure-uk (27)
- # clojured (3)
- # clojurescript (91)
- # core-async (61)
- # cursive (3)
- # data-science (4)
- # datascript (7)
- # datomic (67)
- # emacs (15)
- # events (1)
- # figwheel-main (13)
- # fulcro (31)
- # graalvm (1)
- # graphql (3)
- # hoplon (2)
- # jobs (3)
- # jobs-rus (1)
- # kaocha (4)
- # lambdaisland (34)
- # luminus (4)
- # off-topic (62)
- # om (4)
- # other-languages (9)
- # re-frame (14)
- # reitit (1)
- # ring-swagger (1)
- # shadow-cljs (51)
- # sql (5)
- # xtdb (8)
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 ...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
`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/
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.