This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM rust:1.53-alpine as builder | |
WORKDIR /build | |
RUN apk add alpine-sdk | |
COPY . . | |
RUN cargo build --release | |
FROM alpine:3 | |
WORKDIR /fn | |
COPY --from=builder /build/target/release/simple-calc . | |
CMD ["./simple-calc"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use fdk::{Function, RuntimeContext, Result}; | |
use serde::{Deserialize, Serialize}; | |
use std::error::Error; | |
#[derive(serde::Deserialize)] | |
enum Operation { | |
Add, | |
Sub, | |
Mul, | |
Div, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "simple-calc" | |
version = "0.1.0" | |
authors = ["metamemelord"] | |
edition = "2018" | |
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | |
[dependencies] | |
tokio = { version = "1.6", features = ["macros", "rt-multi-thread"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::stdin; | |
macro_rules! read { | |
($v: ident : $t: ty) => { | |
let mut buf = String::new(); | |
let _ = stdin().read_line(&mut buf).expect("Failed to read input"); | |
let $v = buf.trim().trim_end().parse::<$t>().unwrap(); | |
}; | |
($v: ident : vec $t: ty) => { | |
let mut buf = String::new(); | |
let _ = stdin().read_line(&mut buf).expect("Failed to read input"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(prelude_import)] | |
#![no_std] | |
#[prelude_import] | |
use ::std::prelude::v1::*; | |
#[macro_use] | |
extern crate std; | |
use std::io::stdin; | |
macro_rules! read { | |
($ v : ident : $ t : ty) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::stdin; | |
macro_rules! read { | |
($v: ident : $t: ty) => { | |
let mut buf = String::new(); | |
let _ = stdin().read_line(&mut buf).unwrap(); | |
let mut $v = buf.trim().trim_end().parse::<$t>().unwrap(); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::stdin; | |
macro_rules! read { | |
($v: ident : $t: ty) => { | |
let mut buf = String::new(); | |
let _ = stdin().read_line(&mut buf).unwrap(); | |
let mut $v = buf.trim().trim_end().parse::<$t>().unwrap(); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! name_of_the_macro { | |
( /* Patterns that the macro can match on */) => { | |
// Body of the macro, i.e. how should this macro expand? | |
println!("I am a plain macro! (:"); | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::stdin; | |
use std::str::FromStr | |
fn read<T: FromStr>(t: &mut T) { | |
let mut buf = String::new(); | |
if let Ok(_) = stdin().read_line(&mut buf) { | |
if let Ok(val) = buf.trim().trim_end().parse::<T>() { | |
*t = val; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io::stdin; | |
fn read_i32(i: &mut i32) { | |
let mut buf = String::new(); | |
let _ = stdin() | |
.read_line(&mut buf) | |
.expect("Could not read from stdin"); | |
*i = buf | |
.trim() | |
.trim_end() |
NewerOlder