text
stringlengths
8
4.13M
/// An enum to represent all characters in the HangulJamo block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum HangulJamo { /// \u{1100}: 'แ„€' HangulChoseongKiyeok, /// \u{1101}: 'แ„' HangulChoseongSsangkiyeok, /// \u{1102}: 'แ„‚' HangulChoseongNieun, /// \u{1103}: 'แ„ƒ' HangulC...
use std::io; fn main() { // ํŒจํ„ด ๋งค์นญ์„ ใ…… ใ…์šฉํ•˜๊ธฐ let mut buffer = String::new(); match io::stdin().read_line(& mut buffer) { Ok(count) => { println!("#################"); println!("{}", buffer); println!(" {} bytes read using pattern maching", count); pri...
#[doc = "Register `PWR_WKUPCR` reader"] pub type R = crate::R<PWR_WKUPCR_SPEC>; #[doc = "Register `PWR_WKUPCR` writer"] pub type W = crate::W<PWR_WKUPCR_SPEC>; #[doc = "Field `WKUPC1` reader - WKUPC1"] pub type WKUPC1_R = crate::BitReader; #[doc = "Field `WKUPC1` writer - WKUPC1"] pub type WKUPC1_W<'a, REG, const O: u8...
use crate::RrtRay::Ray; use crate::RrtVec3; use crate::RrtVec3::Vec3; #[derive(Copy, Clone)] pub struct hit_record { pub p : Vec3, pub normal : Vec3, pub t : f64, pub front_face : bool, } impl hit_record { pub fn new() -> hit_record { hit_record{ p : Vec3::new([0.0, 0.0, 0.0]),...
mod benmark; extern crate chashmap; extern crate itertools; extern crate rayon; extern crate reqwest; use std::io::Read; use std::path::PathBuf; use error_chain::error_chain; use itertools::Itertools; use rayon::iter::*; use std::fs::File; use std::io::copy; error_chain! { foreign_links { Io(std::io::Err...
use crate::model::{company::CompanyResponse, intraday_prices::PricesResponse}; use anyhow::Result; use log::debug; use reqwest::{header::HeaderMap, Client, Method}; use serde::{de::DeserializeOwned, Serialize}; const BASE_URL: &'static str = "https://cloud.iexapis.com/stable"; pub struct ApiClient { base_url: Str...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// TagToHosts : In this object, the key is the tag, the value is a list of host names that are reportin...
const INPUT: usize = 990941; const INPUT_SLICED: [u8; 6] = [9, 9, 0, 9, 4, 1]; pub fn solve() { let mut recipes = Vec::with_capacity(INPUT + 12); recipes.extend_from_slice(&[3_u8, 7]); let mut elves = (0, 1); loop { let score = recipes[elves.0] + recipes[elves.1]; if score >= 10 { ...
use std::str; use header::{RequestHeader, ResponseHeader, parse_value, serialize_value, parse_list0, serialize_list}; use header::item::Url; use Method; header!{ /// `From` header, [RFC7231 Section 5.5.1] pub struct From(String); (RequestHeader); NAME = "From"; SENSITIVE = false; ...
use pretty_assertions::assert_eq; use sudo_test::{Command, Env, TextFile}; use crate::{Result, SUDOERS_USER_ALL_NOPASSWD, USERNAME}; #[test] fn user_can_read_file_owned_by_root() -> Result<()> { let expected = "hello"; let path = "/root/file"; let env = Env(SUDOERS_USER_ALL_NOPASSWD) .user(USERNAM...
extern crate nell; use nell::ffi::route::rtmsg; use nell::sys::{Message, Cursor}; use std::net::{IpAddr, Ipv4Addr}; pub struct Route { pub sock_fd: i32, pub msg_cur: Cursor, pub bytes: Vec<u8>, } impl Route { pub fn new() -> Route { let sock_fd = unsafe { libc::socket(libc::AF_N...
use rendy::{ factory::{Config, Factory}, }; use winit::{ EventsLoop, WindowBuilder, }; #[cfg(feature = "dx12")] type Backend = rendy::dx12::Backend; #[cfg(feature = "metal")] type Backend = rendy::metal::Backend; #[cfg(feature = "vulkan")] type Backend = rendy::vulkan::Backend; #[cfg(any(feature = "dx1...
use std::ops; use crate::{Outcome, Player}; #[derive(PartialEq, Clone, Copy, Debug)] pub struct Direction(i8, i8); const HORIZONTAL: Direction = Direction(1, 0); const VERTICAL: Direction = Direction(0, 1); const FORWARD_DIAGONAL: Direction = Direction(1, 1); const BACKWARD_DIAGONAL: Direction = Direction(-1, 1); p...
use super::*; #[derive(Clone, Debug, Default, PartialEq)] /// Container for [`Peptide`] sequences and their quantified ratios /// /// Allows constant-time lookup by amino-acid sequence pub struct Protein { pub accession: String, pub description: String, pub peptides: Vec<Peptide>, /// Constant-time in...
use gtk::prelude::*; use gio::prelude::*; use gtk::{ ScrolledWindow, TextView, Adjustment, MenuItem, MenuBar, Menu }; use std::env; fn main() { if gtk::init().is_err() { println!("Failed to initialize GTK"); return; } let uiapp = gtk::Application::new(Some("org.gtkrsnotes.demo"), gio::Appl...
use crate::CXFederatedPlan; use connectorx::fed_rewriter::Plan; use libc::c_char; use std::convert::Into; use std::ffi::CString; impl Into<CXFederatedPlan> for Plan { fn into(self) -> CXFederatedPlan { CXFederatedPlan { db_name: CString::new(self.db_name.as_str()) .expect("new C...
pub mod forest; pub mod handle;
//! Low-level reading of the Header foudn in PAC files. use crate::error::PacError; use crate::Result; use ez_io::{ReadE, WriteE}; use std::io::{Read, Write}; /// Direct representation of the data found in the header #[derive(Clone)] pub struct PacHeader { pub magic_number: [u8; 8], // 'DW_PACK\0' pub file_po...
pub fn run(){ greeting("Hello", "Ali Hamza"); // In Rust we can bind the funtion value to variable let add_number = add(12, 12); println!("The sum is {}", add_number); // Closure let get_nums = |n1: i32, n2: i32| n1 + n2; println!("Get sum {}", get_nums(5, 5)); } fn greeting(greet: &str, name: &str){...
use crate::{ codegen::{ builder::{branch, core}, AatbeModule, CompileError, ValueTypePair, }, fmt::AatbeFmt, ty::LLVMTyInCtx, }; use parser::ast::{Expression, LoopType, PrimitiveType}; use llvm_sys_wrapper::Phi; impl AatbeModule { pub fn codegen_if(&mut self, if_expr: &Expression)...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// LogsListRequest : Object to send with the request to retrieve a list of logs from your Organization....
//! # Gps distance //! Calculate the distance between two points given the longitude, latitude and altitude. //! //! ## Vincenty formula //! This implimentation of this problem will use Vincenty's formula. While more complex and slower //! than other methods, it is more accurate. For details see //! //! Work out the di...
use js_ffi::*; pub const KEYDOWN: JSValue = 1.0; pub const KEYUP: JSValue = 2.0;
#[macro_use] extern crate lazy_static; extern crate encoding; mod html_heuristics; mod dynamic_string; mod html_chunk; mod tag_parser; mod html_entities; pub mod html_parser;
// Copyright 2015 The Gfx-rs Developers. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
use sp_ipld::Ipld; use std::num::TryFromIntError; #[derive(PartialEq, Debug, Clone)] pub enum IpldError { Utf8(Vec<u8>, std::string::FromUtf8Error), ByteCount(Vec<u8>, u64), UnicodeChar(u32), U64(TryFromIntError), Uses(Ipld), Bool(Ipld), Position(Ipld), Literal(Ipld), LitType(Ipld), PrimOp(Ipld), ...
//! GoodReads interaction record schemas and processing. use hashbrown::HashSet; use serde::Deserialize; use crate::arrow::*; use crate::ids::index::IdIndex; use crate::parsing::dates::*; use crate::parsing::*; use crate::prelude::*; pub const OUT_FILE: &'static str = "gr-interactions.parquet"; pub const USER_FILE: &...
#[doc = "Reader of register FDCAN_RXF0S"] pub type R = crate::R<u32, super::FDCAN_RXF0S>; #[doc = "Writer for register FDCAN_RXF0S"] pub type W = crate::W<u32, super::FDCAN_RXF0S>; #[doc = "Register FDCAN_RXF0S `reset()`'s with value 0"] impl crate::ResetValue for super::FDCAN_RXF0S { type Type = u32; #[inline(...
use super::*; use rtp::packetizer::Marshaller; use bytes::Bytes; impl Context { pub fn decrypt_rtp_with_header( &mut self, encrypted: &Bytes, header: &rtp::header::Header, ) -> Result<Bytes, Error> { let roc; { if let Some(state) = self.get_srtp_ssrc_state(...
use std::convert::From; #[derive(Debug, Serialize, Deserialize)] pub struct Author { pub id: i32, pub name: String, pub country: String, } impl From<postgres::Row> for Author { fn from(row: postgres::Row) -> Self { Author { id: row.get(0), name: row.get(1), ...
use super::state::State; use super::databus::Databus; pub type AddressingModeFn = fn(state: &State, bus: &dyn Databus, operand: u16) -> u16; pub const DO_NOTHING: AddressingModeFn = |_state: &State, _bus: &dyn Databus, _operand: u16| -> u16 { 0 }; pub const IMMEDIATE: AddressingModeFn = |_state: &State, _bus: &dyn Da...
use connectorx::{ prelude::*, sources::{ mysql::BinaryProtocol as MYSQLBinaryProtocol, postgres::{rewrite_tls_args, BinaryProtocol, PostgresSource}, }, sql::CXQuery, transports::PostgresArrowTransport, }; use datafusion::datasource::MemTable; use datafusion::prelude::*; use j4rs::{Cl...
mod common; #[test] #[cfg(feature = "devkit-arm-tests")] pub fn test_ldr_preinc_imm() { let (cpu, _mem) = common::execute_arm( "ldr-preinc-imm", " ldr r0, =var sub r2, r0, #3 mov r3, r2 ldr r0, [r0, #0] ldr r1, [r2, #3] var: .word...
/// A static slice of characters. pub type StaticCharVec = &'static [char]; pub static HTML_SPACE_CHARACTERS: StaticCharVec = &['\u{0020}', '\u{0009}', '\u{000a}', '\u{000c}', '\u{000d}']; pub fn char_is_whitespace(c: char) -> bool { HTML_SPACE_CHARACTERS.contains(&c) }
use proc_macro2::TokenStream; use quote::{format_ident, quote}; mod field_copy; mod field_ty; mod r#impl; use super::generics; use field_ty::CudaReprFieldTy; fn get_cuda_repr_ident(rust_repr_ident: &proc_macro2::Ident) -> proc_macro2::Ident { format_ident!("{}CudaRepresentation", rust_repr_ident) } #[allow(cli...
use rand::{thread_rng, Rng}; pub fn random_bytes(length: usize) -> Vec<u8> { (0..length).map(|_| thread_rng().gen::<u8>()).collect() } pub fn random_in_range(lower: usize, upper: usize) -> usize { thread_rng().gen_range(lower..upper) } pub fn coin_flip() -> bool { thread_rng().gen() }
use crate::images; use rider_config::directories::*; use std::fs; use std::path::PathBuf; pub fn create(directories: &Directories) -> std::io::Result<()> { if !directories.themes_dir.exists() { fs::create_dir_all(&directories.themes_dir)?; images::create(directories)?; } if !directories.fo...
pub mod tap;
pub fn sort<T: PartialOrd> (array: &mut Vec<T>, comparator: fn(&T,&T) -> bool) { loop{ let mut swap = false; for i in 1..array.len() { if comparator(&array[i], &array[i - 1]) { array.swap(i - 1, i); swap = true; } } ...
#[doc = "Reader of register TEST_CTL"] pub type R = crate::R<u32, super::TEST_CTL>; #[doc = "Writer for register TEST_CTL"] pub type W = crate::W<u32, super::TEST_CTL>; #[doc = "Register TEST_CTL `reset()`'s with value 0"] impl crate::ResetValue for super::TEST_CTL { type Type = u32; #[inline(always)] fn re...
// Problem 25 - 1000-digit Fibonacci number // // The Fibonacci sequence is defined by the recurrence relation: // // F(n) = F(nโˆ’1) + F(nโˆ’2), where F(1) = 1 and F(2) = 1. // // Hence the first 12 terms will be: // // F(1) = 1 // F(2) = 1 // F(3) = 2 // F(4) = 3 // F(5) = 5 // F(6) = 8 // ...
/// Used to express the search filters applied to GUI inspect page #[derive(Clone, Debug, Default, Hash)] pub struct SearchParameters { /// Application protocol pub app: String, /// Domain pub domain: String, /// Country pub country: String, /// Autonomous System name pub as_name: String...
//! Engine function alias. use crate::{Input, Output, Tracer}; use rand::rngs::ThreadRng; /// Rendering sampling engine function type. pub type Engine = fn(input: &Input, &mut ThreadRng, trace: Tracer, data: &mut Output, pixel: [usize; 2]);
use std::collections::HashMap; pub fn all_permutations(n: i32, k: i32) { let mut current_sequence: Vec<i32> = Vec::new(); let mut map: HashMap<i32, bool> = HashMap::new(); for i in 1..n + 1 { map.insert(i, false); } all_permutations_help(&mut current_sequence, n, k, &mut map); } fn all_per...
use string_repr::StringRepr; use wdg_uri::path::Path; #[cfg(test)] mod path { use super::{Path, StringRepr}; mod string_repr { use super::{Path, StringRepr}; #[test] fn fc0f0dd2_530d_4e38_8d33_f9985ee0f848() { assert_eq!( Path::new("/path/to/something").str...
#![allow(dead_code)] #[macro_use] extern crate helloworld_derive; trait HelloWorld { fn hello_world(); } #[derive(HelloWorld)] struct FrenchToast; #[derive(HelloWorld)] struct Waffles; fn main() { println!("Hello"); }
#![doc = "generated by AutoRust 0.1.0"] #![allow(non_camel_case_types)] #![allow(unused_imports)] use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct OperationListResult { #[serde(default, skip_serializing_if = "Vec::is_empty")] pub value: Vec<Operation>, ...
pub mod scene; pub mod geometry; pub mod sprite; pub mod input; pub mod tiles; pub mod ui; pub mod text; pub mod physics; pub mod rendering; pub mod game_context;
use packed_secret_sharing::packed::*; use packed_secret_sharing::*; use packed_secret_sharing::ntt; /* use this prime : 4610415792919412737 512th root ot unity: 1266473570726112470 729th root of unity: 2230453091198852918 3073700804129980417, 414345200490731620, 1697820560572790570, 8, 27, 2, 10 from [5, 5] [5, ...
extern crate alga; extern crate fps_counter; extern crate generic_array; #[macro_use] extern crate imgui; #[macro_use] extern crate lazy_static; extern crate nalgebra as na; extern crate ncollide; extern crate nphysics3d as nphysics; extern crate pathfinding; extern crate png; extern crate rand; extern crate ron; #[mac...
use clang::*; use std::io::Write; #[macro_use] use super::gen_context::*; use super::symbol_status::SymbolStatus; use super::compile_entity_children; pub fn gen(gen_context: &mut GenContext, entity: Entity) { if let Some(entity_name) = entity.get_name() { // Write a Obj-C Interface binding gen_fm...
#[allow(unused_imports)] use super::util::prelude::*; use super::util::{Pack, PackDepth}; use super::BlockMut; pub type NumberValue = f64; pub type NumberMin = NumberValue; pub type NumberMid = NumberValue; pub type NumberMax = NumberValue; #[derive(Clone)] pub enum Value { Number(NumberValue), NumberMinMax(N...
/// An enum to represent all characters in the ArabicExtendedA block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum ArabicExtendedA { /// \u{8a0}: 'เข ' ArabicLetterBehWithSmallVBelow, /// \u{8a1}: 'เขก' ArabicLetterBehWithHamzaAbove, /// \u{8a2}: 'เขข' ArabicLetterJeemWithTwoDotsAbove,...
extern crate docopt; extern crate pbr; extern crate rustc_serialize; use std::cmp; use std::fs::File; use std::io::{BufWriter, Write}; use std::iter; use docopt::Docopt; use pbr::ProgressBar; const USAGE: &'static str = " Lines Generate many many lines of \"hi\" Usage: lines <count> <file> lines (-h | --help) ...
use amethyst::{ SimpleState, StateData, GameData, StateEvent, Trans, SimpleTrans, input::{is_mouse_button_down}, ui::{Anchor, UiLabelBuilder, UiEvent, UiCreator}, prelude::* }; use crate::components::*; use amethyst::renderer::rendy::wsi::winit::MouseButton; use amethyst::core::e...
use alga::general::AbstractMonoid; use alga::general::AbstractMagma; use alga::general::Operator; use alga::general::Identity; use crate::TimeWindow; use crate::flat_fat::fat::FAT; use crate::flat_fat::flat_fat::FlatFAT; use crate::flat_fat::item::{Item,Combine}; pub struct TimeRA<Value, BinOp> where Value: Abstr...
use chrono::prelude::*; use std::fmt; use std::time::{Duration, UNIX_EPOCH}; use tonic::Code; mod discount_types; pub struct ServerError { pub code: Code, pub message: String, } // Implement std::fmt::Debug for ServerError impl fmt::Display for ServerError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::...
use actix_web::{HttpRequest, Responder}; pub fn index(_req: &HttpRequest) -> impl Responder { "version: 1.0" }
use std::collections::HashMap; use std::ops::Deref; pub struct KvStore { data: HashMap<String, String>, } impl KvStore { pub fn new() -> KvStore { KvStore { data: HashMap::new(), } } pub fn get(&mut self, key: String) -> Option<String> { match self.data.get(&key) {...
///How to write a Virtual Dom in Rust ///inspired from https://medium.com/@deathmood/how-to-write-your-own-virtual-dom-ee74acc13060 /// use html_parser::{ Dom, Node }; use html_parser::Element; use wasm_bindgen::prelude::*; use std::panic; use web_sys::console; macro_rules! log { ( $( $t:tt )* ) => { web...
use crate::{entry_functions, expressions, types}; use std::collections::HashMap; pub fn compile_definition( module_builder: &fmm::build::ModuleBuilder, definition: &pir::ir::Definition, global_variables: &HashMap<String, fmm::build::TypedExpression>, types: &HashMap<String, pir::types::RecordBody>, ) -...
use crate::prelude::*; use bitvec::prelude::*; fn solve(disc_size: usize, seed: BitVec) -> Result<String> { if disc_size % 2 != 0 { return Err(anyhow!("disc size must be even")); } let mut buf: BitVec = seed; let mut double_buf: BitVec = BitVec::with_capacity(disc_size * 2); buf.reserve(dis...
//! Implementation of the simulation's calculations and logic. use super::io::{Score, IO}; /// Lander simulation /// /// The terse member names come from the names of global variables in the /// original FOCAL code. #[derive(Copy, Clone, Default)] pub struct Lander { /// Altitude (miles) pub a: f64, /// G...
use std::io::prelude::*; use std::io::SeekFrom; use std::os::unix::io::{AsRawFd, RawFd}; use mio::{EventLoop, Handler, Token, EventSet, PollOpt}; use sys::{Edge, Selector, GPIOSelector, GPIOPinSelector}; use {Result, Error, Logic, DigitalLogic, DigitalWrite, DigitalRead, is_root}; #[derive(Debug)] pub struct Pin { ...
use std::sync::Arc; use super::{MongoProductDao, MongoSourceDao, MongoWishlistDao}; use crate::persistence::{ProductDao, SourceDao, WishlistDao}; lazy_static! { static ref PRODUCT_DAO: Option<Arc<MongoProductDao>> = MongoProductDao::new().map(Arc::new).ok(); static ref WISHLIST_DAO: Option<Arc<MongoWi...
use super::alias_from_arg_or_channel_name; use serenity::framework::standard::{Args, CommandError}; use serenity::model::channel::Message; use serenity::prelude::Context; use crate::db::DbConnectionKey; pub fn describe( context: &mut Context, message: &Message, mut args: Args, ) -> Result<(), CommandErro...
fn main() { let name = String::from("Umair"); let name_length = name.len(); println!("{}",name_length); let age = [20,22,24,26]; //element 0 1 2 3 4 5 6 7 8 9 let temp = 9; println!("Age is : {}",age[temp]); //age.9 //tuple calling //age[3] //array calling // ...
// Generated from vec.rs.tera template. Edit the template, not the generated file. use crate::{BVec2, I64Vec2, IVec2, U64Vec2, UVec3}; #[cfg(not(target_arch = "spirv"))] use core::fmt; use core::iter::{Product, Sum}; use core::{f32, ops::*}; /// Creates a 2-dimensional vector. #[inline(always)] pub const fn uvec2(x:...
use std::path::Path; use ggez::error::GameError::FontError; use ggez::graphics::{self, DrawParam, Image, Rect}; use ggez::mint; use ggez::{Context, GameResult}; #[derive(Debug)] pub struct Font { img: Image, } impl Font { const NCOL: usize = 16; const NROW: usize = 6; pub fn new<P: AsRef<Path>>(ctx:...
use crate::{ gc::Gc, primitives::ListOperations, rerrs::ErrorKind, rvals::{FromSteelVal, IntoSteelVal, Result}, SteelErr, SteelVal, }; use std::collections::{HashMap, HashSet}; // Vectors impl<T: IntoSteelVal> IntoSteelVal for Vec<T> { fn into_steelval(self) -> Result<SteelVal> { let ve...
use crate::{BotResult, Database}; use dashmap::DashMap; use futures::stream::StreamExt; impl Database { pub async fn add_stream_track(&self, channel: u64, user: u64) -> BotResult<bool> { let done = sqlx::query!( "INSERT INTO stream_tracks VALUES ($1,$2) ON CONFLICT DO NOTHING", cha...
type DataType = std::collections::HashMap<u32, u32>; fn knapsack( data: &[u32], limit: u32, current_weight: u32, count: &mut DataType, containers_used: u32, ) { for (idx, _) in data.iter().enumerate() { let new_weight = current_weight + data[idx]; if new_weight == limit { ...
use std::collections::HashSet; use std::env; use std::fs; #[derive(Debug)] enum Instruction { Acc(i32), Jmp(i32), Nop, } fn to_instruction(line: &str) -> Instruction { let mut split = line.split_ascii_whitespace(); match split.next().unwrap() { "acc" => Instruction::Acc(split.next().unwrap...
//!Acid testing program #![feature(array_chunks, core_intrinsics, thread_local)] const PAGE_SIZE: usize = 4096; mod cross_scheme_link; mod daemon; mod scheme_data_leak; fn e<T, E: ToString>(error: Result<T, E>) -> Result<T, String> { error.map_err(|e| e.to_string()) } fn create_test() -> Result<(), String> { ...
use std::env; use std::ffi::OsString; use std::io::ErrorKind; use std::process; use std::process::Command; use starship::config::StarshipConfig; use std::fs::File; use std::io::Write; use toml::map::Map; use toml::Value; #[cfg(not(windows))] const STD_EDITOR: &str = "vi"; #[cfg(windows)] const STD_EDITOR: &str = "not...
pub fn dfs<F, GT: ::graph::GraphTraversal>(g: &GT, s: usize, mapped_function: &mut Box<F>, marker: &mut ::mark::Marker) where F: FnMut(usize) { mapped_function(s); marker.mark(s); for &v in g.fwd_edges(s) { if !marker.is_marked(v) { dfs(g, v, mapped_function, marker); } } } ...
use std::net::SocketAddr; use rsocket_rust::{async_trait, error::RSocketError, transport::ServerTransport, Result}; use tokio::net::TcpListener; use super::client::WebsocketClientTransport; const WS_PROTO: &str = "ws://"; #[derive(Debug)] pub struct WebsocketServerTransport { addr: SocketAddr, listener: Opt...
use num::Num; use rand::distributions::Distribution; use rand::distributions::Standard; use rand::random; use std::convert::Into; use std::fmt::Debug; use std::ops::Add; use std::ops::AddAssign; use std::ops::Div; use std::ops::DivAssign; use std::ops::Index; use std::ops::Mul; use std::ops::MulAssign; use std::ops::Ne...
//! Utilities for creating optimal work schedules. //! //! # Weeks //! //! This library relies heavily on the concept of a _week_ as a unit of time. A _week_ is defined //! as a series of 7 _weekdays_ beginning with Monday and ending with Sunday. Weekdays are //! represented by variants of the [`chrono::Weekday`] enum....
use crate::Event; use libc::{c_int, ioctl, sighandler_t, signal, winsize, SIGWINCH, STDIN_FILENO, TIOCGWINSZ}; use std::sync::atomic::{AtomicU32, Ordering}; use std::sync::{mpsc, Mutex}; use std::thread; use super::Terminal; static TERM_WIDTH: AtomicU32 = AtomicU32::new(0); static TERM_HEIGHT: AtomicU32 = AtomicU32::...
use petgraph::graphmap::UnGraphMap; use petgraph::algo::astar; use arrayvec::ArrayString; use std::fs::File; use std::io::{BufReader, BufRead}; use std::io; fn populate_graph(g: &mut UnGraphMap::<ArrayString::<[u8; 3]>, i32>) -> Result<(), io::Error> { let f = File::open("input")?; let br = BufReader::ne...
extern crate wasmer_runtime; use std::sync::{Arc, Mutex}; use wasmer_runtime::{error, func, imports, instantiate, Array, Ctx, WasmPtr}; // Make sure that the compiled wasm-sample-app is accessible at this path. static WASM: &'static [u8] = include_bytes!("../wasm-sample-app/target/wasm32-unknown-unknown/release/w...
use std::{collections::HashSet, str::FromStr, usize}; use lazy_static::lazy_static; use regex::{Regex}; // compile regex statically so it does not have to be recompiled in loop iterations lazy_static! { static ref re_statement: Regex = Regex::new(r"(\w{3})\s+([+-])(\d+)").unwrap(); } pub fn day8 () { let exam...
use clearTimeout; use setTimeout; use MessageEvent; use WebSocket; use carrier_core::dns::DnsRecord; use carrier_core::identity::{Address, Identity, Secret, SignedAddress}; use carrier_core::noise; use carrier_core::packet::{EncryptedPacket, RoutingKey}; use carrier_core::rpc::{self, CallHandler}; use carrier_core::tr...
#![feature(start)] extern crate GolfManiaLib as glib; mod view; mod login_logic; use glib::model::{score_card}; use glib::model::map::*; use view::console; #[start] fn main( argc : isize, argv: *const *const u8 ) -> isize { let test : Map = MapBuilder::from_named(None).unwrap(); for thing in test.into_iter(...
mod query_subcommand { use std::process::Command; use assert_cmd::prelude::*; fn build_cmd() -> Command { let mut cmd = Command::cargo_bin("qsv").unwrap(); cmd.arg("query"); cmd } #[test] fn it_can_run_the_commandline_for_a_simple_query() -> Result<(), Box<dyn std::error...
/// Position is a (row, col) position on a Grid. /// /// For example such table has 4 cells. /// Which indexes are (0, 0), (0, 1), (1, 0), (1, 1). /// /// ```text /// โ”Œโ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ” /// โ”‚ 0 โ”‚ 1 โ”‚ /// โ”œโ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”ค /// โ”‚ 1 โ”‚ 2 โ”‚ /// โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”˜ /// ``` pub type Position = (usize, usize);
use super::Value; use crate::value::Quotes; use std::default::Default; use std::fmt; /// the actual arguments of a function or mixin call. /// /// Each argument has a Value. Arguments may be named. /// If the optional name is None, the argument is positional. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd)] pub str...
// // Copyright ยฉ 2017, ACM@UIUC // // This file is part of the Groot Project. // // The Groot Project is open source software, released under the // University of Illinois/NCSA Open Source License. You should have // received a copy of this license in a file with the distribution. mod server; fn main() { ser...
//! # Message Broker //! //! This module contains the message broker client interface through which actor modules access //! a bound `wascc:messaging` capability provider use wapc_guest::host_call; const CAPID_MESSAGING: &str = "wascc:messaging"; use crate::HandlerResult; use codec::messaging::{BrokerMessage, Reques...
// MIT License // // Copyright (c) 2021 Ferhat GeรงdoฤŸan All Rights Reserved. // Distributed under the terms of the MIT License. // // use { crate::{ ast::{ ast_helpers::{ to, from_module }, GreteaKeywords }, parser::{Gretea...
use crate::AsTable; use clap::{crate_authors, crate_version, App, AppSettings, Arg, ArgMatches}; use digitalocean::prelude::*; use failure::Error; use serde; use serde_json; use serde_yaml; use toml; mod account; pub use self::account::Root as Account; mod certificate; pub use self::certificate::Root as Certificate; m...
//! Sx127x LoRa mode definitions //! //! Copyright 2019 Ryan Kurte pub use super::common::*; /// LoRa Radio Configuration Object #[derive(Copy, Clone, PartialEq, Debug)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", serde(default))] pub struct LoRaConfig {...
mod info_routes; pub use info_routes::*;
use std::time::Instant; const INPUT: &str = include_str!("../input.txt"); const OFFSETS: [(isize, isize); 8] = [ (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1), ]; type GridRow = Vec<char>; type Grid = Vec<GridRow>; fn read_grid() -> Grid { INPUT.lines().map(...
use iron::prelude::*; use common::http::*; use common::utils::*; use services::message::*; use services::user::get_user_id; pub fn render_unread_message(req: &mut Request) -> IronResult<Response> { let session = get_session_obj(req); let username = session["username"].as_str().unwrap(); let user_id = get...
use bayard_client::client::client::{create_client, Clerk}; use clap::ArgMatches; use crate::util::log::set_logger; pub fn run_search_cli(matches: &ArgMatches) -> Result<(), String> { set_logger(); let servers: Vec<_> = matches .values_of("SERVERS") .unwrap() .map(|addr| create_client(...
extern crate oxygengine_core as core; extern crate oxygengine_input as input; pub mod component; pub mod resource; pub mod system; pub mod ui_theme_asset_protocol; // reexport macros. pub use raui_core::{ post_hooks, pre_hooks, prelude::{MessageData, Prefab, PropsData}, unpack_named_slots, widget, }; pub...
fn is_prime(n: u32) -> bool { for i in (2..n) { if n % i == 0 { return false; } } true }
use std::collections::HashMap; #[derive(Debug)] #[derive(PartialEq)] enum Token { OpenBracket, CloseBracket, Atom(String), } fn to_tokens(text: &str) -> Vec<Token> { let mut tokens = Vec::<Token>::new(); let mut atom = String::new(); for c in text.chars() { if !atom.is_empty() ...