This file contains hidden or 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::collections::HashMap; | |
| fn main() { | |
| // Arrays - fixed size known at compile time | |
| let rust_array = [1, 2, 3]; | |
| // Simple iteration with for-in | |
| for item in rust_array { | |
| println!("{}", item); | |
| } | |
| // Iterate like Go's for-range with enumerate() |
This file contains hidden or 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
| #![allow(dead_code)] | |
| use customers; // brings module customers to scope, from file ./customers.rs | |
| use rand::Rng; | |
| pub fn waiter_jobs() { | |
| // crate::front::serving::take_order(); // crate points to this crate root | |
| front::serving::take_order(); | |
| front::serving::deliver_to_kitchen(); | |
| crate::front::serving::bring_order(); |
This file contains hidden or 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
| #![allow(dead_code)] | |
| use std::fmt; | |
| enum OrderStatus { | |
| Null, | |
| Created, | |
| Cancelled, | |
| Successful, | |
| } |
This file contains hidden or 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
| #![allow(dead_code)] | |
| use std::fmt; | |
| // Tuple struct | |
| struct RGBColor(u8, u8, u8); | |
| // Manually implementing std::fmt::Debug | |
| impl fmt::Debug for RGBColor { | |
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
| f.debug_struct("RGBColor") // Must be exactly "RGBColor" in this case |
This file contains hidden or 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 main | |
| import ( | |
| "context" | |
| "errors" | |
| "fmt" | |
| "os" | |
| "os/signal" | |
| "sync" | |
| "syscall" |
This file contains hidden or 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 main | |
| import ( | |
| "container/heap" | |
| "fmt" | |
| "github.com/holiman/uint256" | |
| ) | |
| // An Item is something we manage in a priority queue. |
This file contains hidden or 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 main | |
| import ( | |
| "encoding/json" | |
| "fmt" | |
| "io/ioutil" | |
| "net/http" | |
| "os" | |
| "time" |
This file contains hidden or 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 main | |
| import ( | |
| "bytes" | |
| "encoding/json" | |
| "log" | |
| "net/http" | |
| "github.com/google/uuid" | |
| "github.com/gorilla/mux" |
This file contains hidden or 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
| const express = require('express'); | |
| const axios = require('axios'); | |
| const redis = require('redis'); | |
| const cors = require('cors'); | |
| const PORT = 8000; | |
| const DEFAULT_EXPIRATION = 3600; | |
| const API_URL = "https://jsonplaceholder.typicode.com/photos" | |
| const app = express(); |
This file contains hidden or 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
| const express = require('express'); | |
| const app = express(); | |
| const router = express.Router(); | |
| app.use(express.json()); | |
| app.use(express.urlencoded({ extended: false })); | |
| const sendHi = async (req, res) => { | |
| res.status(200).send("Hi").end(); | |
| }; |