Skip to content

Instantly share code, notes, and snippets.

View metamemelord's full-sized avatar
🔥
We can't be who we want to be by remaining who we are.

Gaurav Saini metamemelord

🔥
We can't be who we want to be by remaining who we are.
View GitHub Profile
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"]
use fdk::{Function, RuntimeContext, Result};
use serde::{Deserialize, Serialize};
use std::error::Error;
#[derive(serde::Deserialize)]
enum Operation {
Add,
Sub,
Mul,
Div,
[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"] }
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");
#![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) =>
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();
};
}
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();
};
}
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! (:");
};
}
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;
}
}
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()