text
stringlengths
8
4.13M
use bonuses; use bonuses::BonusTracker; pub use self::charisma::{ Charisma }; pub use self::constitution::{ Constitution }; pub use self::dexterity::{ Dexterity }; pub use self::intelligence::{ Intelligence }; pub use self::strength::{ Strength }; pub use self::wisdom::{ Wisdom }; mod charisma; mod constitution; mod de...
pub mod file;
use ::std::*; /** --- Day 5: Sunny with a Chance of Asteroids --- You're starting to sweat as the ship makes its way toward Mercury. The Elves suggest that you get the air conditioner working by upgrading your ship computer to support the Thermal Environment Supervision Terminal. The Thermal Environment Su...
use oxidy::server::Server; use oxidy::structs::Context; fn index(ctx: &mut Context) -> () { ctx.response.body = "".to_string(); } fn user(ctx: &mut Context) -> () { ctx.response.body = ctx.request.params.get("id").unwrap().to_string(); } fn user_post(ctx: &mut Context) -> () { ctx.response.body = "".to_s...
use fugu_env::CommandType; use std::cmp::min; pub struct Selector { pub buf: Vec<(usize, CommandType)>, pub range: (usize, usize), pub max_print: usize, pub cursor: Option<usize>, } impl Default for Selector { fn default() -> Selector { Selector { max_print: 1, range...
use std::io::{self, BufRead}; const BASE: u64 = 7; const MODULUS: u64 = 20201227; fn reverse(a: u64, base: u64, modulus: u64) -> u64 { let mut current = 1; for x in 0.. { if current == a { return x; }; current *= base; current %= modulus; } unreachable!() } ...
/* chapter 4 syntax and semantics */ fn main() { // what to implement: /* fn coordinate() -> (i32, i32, i32) { // generate and return some sort of triple tuple } let (x, _, z) = coordinate(); */ fn coordinate() -> (i32, i32, i32) { // generate and return some sort of...
// extern crate libc; extern crate core_foundation; extern crate cocoa; use cocoa::base::{ NSUInteger, selector, nil}; use cocoa::appkit::{ NSApp, NSRect, NSPoint, NSSize, NSApplication, NSWindow, NSString, NSMenu, NSMenuItem, NSTitledWindowMask, NSBackingStoreBuffered }; struct RMainWindowDele...
use gdnative::prelude::*; use crate::globals::Globals; use std::ops::{MulAssign, AddAssign, SubAssign}; use gdnative::api::*; #[derive(NativeClass)] #[inherit(KinematicBody)] pub struct Player { up_velocity: f32, camera_rotation: Vector2, } #[methods] impl Player { fn new(_owner: &KinematicBody) -> Playe...
use crate::db::money_nodes as db_items; use crate::db::PgPool; use crate::models::money_node::{ InputMoneyNode as NewItem, InputUpdateMoneyNode as UpdateInputItem, NewMoneyNode as Item, UpdateMoneyNode as UpdateItem, }; use actix_web::web::ServiceConfig; use actix_web::{delete, get, patch, post, web, Error, Htt...
use std::cmp::{max, min}; use clap::{crate_version, App, Arg}; use rofuse::{ FileAttr, FileType, Filesystem, MountOption, ReplyAttr, ReplyData, ReplyDirectory, ReplyEntry, Request, }; use memmap2::{Mmap, MmapOptions}; use libc::ENOENT; use std::ffi::OsStr; use std::time::{Duration, UNIX_EPOCH}; use std::io::{Re...
// This file is part of Substrate. // Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // 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 // // ht...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Ethernet DMA bus mode register"] pub dmabmr: DMABMR, #[doc = "0x04 - Ethernet DMA transmit poll demand register"] pub dmatpdr: DMATPDR, #[doc = "0x08 - EHERNET DMA receive poll demand register"] pub dmarpdr: DMARPDR...
extern crate cryptominisat; use self::cryptominisat::*; extern crate bit_vec; use self::bit_vec::BitVec; use super::*; use std::collections::HashMap; use std::fmt; #[cfg(feature = "statistics")] use super::utils::statistics::TimingStats; type QMatrix = Matrix<TreePrefix>; pub struct CaqeSolver<'a> { matrix: ...
//! A safe wrapper for borrowed mutable references. //! //! See: https://github.com/PyO3/pyo3/issues/1180 use pyo3::Python; use std::sync::atomic::{AtomicPtr, Ordering}; /// A wrapper for a mutable reference. pub struct SafeRef<T>(*mut AtomicPtr<T>); unsafe impl<T> Send for SafeRef<T> {} impl<T> Drop for SafeRef<T>...
//! Portable relative UTF-8 paths for Rust. //! //! This provide a module analogous to [std::path], with the following characteristics: //! //! * The path separator is set to a fixed character (`/`), regardless of platform. //! * Relative paths cannot represent a path in the filesystem without first specifying what the...
use hydroflow::hydroflow_syntax; fn main() { let mut df = hydroflow_syntax! { pivot = union() -> tee(); x_0 = [0]pivot; x_1 = [1]pivot; x_0 -> [0]x_0; x_1[0] -> [1]x_1; // Error: `[1][1]pivot` }; df.run_available(); }
#[doc = "Reader of register INTERP1_POP_LANE0"] pub type R = crate::R<u32, super::INTERP1_POP_LANE0>; impl R {}
use std::convert::TryFrom; use std::fmt; #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub enum Code { MemInc, MemDec, PtrInc, PtrDec, SysWrite, SysRead, LoopStart, LoopEnd, } impl fmt::Display for Code { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( ...
use std::io; fn parse_ints(mut line: String) -> Vec<usize> { let mut mem = Vec::with_capacity(100); let mut value = String::new(); line.push(','); for c in line.chars() { match c { ',' => { let int = value.trim().parse().unwrap(); value.clear(); ...
//! ITP1_1_A の回答。 //! [https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A](https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A) /// ITP1_1_A の回答 エントリポイント。 /// 標準出力に`"Hello World"`を出力する。 #[allow(dead_code)] pub fn main() { println!("Hello World") }
extern crate ndarray; use crate::params::Update; use crate::types::*; use ndarray::{ Array, Array1, Array2, Array3, ArrayView1, Axis, Dimension, Ix2, Ix3, RemoveAxis, Slice, }; use ndarray_rand::rand_distr::{StandardNormal, Uniform}; use ndarray_rand::RandomExt; use std::collections::HashMap; pub fn preprocess(tex...
extern crate lru; use lru::LruCache; use crate::page::{Page, PageType, PAGE_SIZE, PageError}; use std::cell::{RefCell, RefMut}; use std::rc::Rc; use std::iter::Map; use crate::BTree; use std::fs::{File, OpenOptions}; use anyhow::{Result, Error}; use std::borrow::BorrowMut; use std::io::{Seek, SeekFrom, Read}; use std:...
use std::error::Error; use std::result::Result; //use crate::bknode::BkNode; pub trait NodeAllocator<'a> { type Key: Clone; type Node; // TODO: type AllocationError: Error; fn new_root(&'a self, key: Self::Key) -> Result<Self::Node, Box<dyn Error>>; fn new_child(&'a self, key: Self::Key) -> Resul...
use crate::utils::read_lines; use std::collections::HashMap; use regex::Regex; pub(crate) fn main() { // Tests let filename_ex = "B:\\Dev\\Rust\\projects\\aoc2020\\input\\7_ex.txt"; let all_bags_tests = parse_file(filename_ex); assert!(can_hold(all_bags_tests.get("bright white").unwrap(), all_bags_t...
///// chapter 4 "structuring data and matching patterns" ///// program section: // fn main() { struct Kilograms(u32); let weight = Kilograms(250); ///// extracting kgm // let Kilograms(kgm) = weight; println!("weight is {} kilograms", kgm); } ///// output should be: /* weight is 250 kilograms ...
#[doc = "Register `ETH_MACL4A0R` reader"] pub type R = crate::R<ETH_MACL4A0R_SPEC>; #[doc = "Register `ETH_MACL4A0R` writer"] pub type W = crate::W<ETH_MACL4A0R_SPEC>; #[doc = "Field `L4SP0` reader - L4SP0"] pub type L4SP0_R = crate::FieldReader<u16>; #[doc = "Field `L4SP0` writer - L4SP0"] pub type L4SP0_W<'a, REG, co...
use serde::de::{DeserializeSeed, Deserializer, EnumAccess, SeqAccess, VariantAccess, Visitor}; use std::error::Error; use std::marker::PhantomData; use std::ops::Deref; use std::vec::IntoIter; use headers::HeadersDeserializationError; pub(super) trait VisitableString<'de>: Deref<Target = str> { fn be_visited<V>(...
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use std::borrow::Cow; use std::hash::Hash; use im::HashMap; use crate::datatype::bitvec::BitVec; use crate::datatype::AbstractD...
#![forbid(unsafe_code, missing_docs, missing_debug_implementations, warnings)] #![doc(html_root_url = "https://docs.rs/rsa-der/0.2.0")] //! A simple crate to encode and decode DER-formatted public RSA keys. //! //! Public keys are passed to and returned from functions simply using the `n` and `e` //! components, so a...
use std::ops::RangeInclusive; use std::os::raw::c_void; use std::ptr; use crate::internal::DataTypeKind; use crate::string::ImStr; use crate::sys; use crate::Ui; /// Builder for a slider widget. #[derive(Copy, Clone, Debug)] #[must_use] pub struct Slider<'a, T: DataTypeKind> { label: &'a ImStr, min: T, ma...
use std::fmt; use super::{ ChannelId, Channel, Emoji, Member, RoleId, Role, UserId, User, IncidentStatus }; use ::internal::prelude::*; /// Allows something - such as a channel or role - to be mentioned in a message. pub trait Mentionable { fn mention(&self) -> String; } impl M...
extern crate serde_json; use failure; use failure::Error; use serde_json::Value; use std::fs; use std::io::Read; use std::path::Path; use util; #[derive(Deserialize, Debug)] pub struct PublicMessage { what: String, data: Option<serde_json::Value>, } #[derive(Deserialize, Debug)] pub struct Message { pub uid: St...
extern crate rand; extern crate flame; use std::fs::File; fn main() { let mut data = vec![0; 1000]; for di in 0..data.len() { data[di] = rand::random::<u64>(); } flame::start("sort n=1000"); data.sort(); flame::end("sort n=1000"); flame::start("binary search n=1000 100 times"); for _ i...
table! { accounts (id) { id -> Int4, url -> Varchar, } } table! { posts (id) { id -> Int4, src -> Int4, privacy -> Int4, content_warning -> Nullable<Varchar>, text -> Nullable<Varchar>, image_data -> Nullable<Json>, time -> Timestamptz...
#![no_std] #![no_main] #![feature(trait_alias)] #![feature(min_type_alias_impl_trait)] #![feature(impl_trait_in_bindings)] #![feature(type_alias_impl_trait)] #![allow(incomplete_features)] #[path = "../example_common.rs"] mod example_common; use embassy_stm32::{ gpio::{Level, Output, Speed}, rcc::*, }; use emb...
#![warn(clippy::pedantic)] // This is the canonical "Hello World" example for RLTK. // It's like example 01, but we implement a sparse second terminal using a nicer VGA font // for the FPS and frame time portions. This illustrates how you can combine multiple fonts // on a single layered console. //////////////////////...
/* * Copyright 2018 Intel Corporation * * 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 agre...
use nix::unistd::getppid; use std::env; fn main() { let ppid = getppid(); let pwd = env::current_dir().unwrap(); let is_current = true || false; if (is_current) { print!("*"); } println!("{}: {}",ppid,pwd.display()); }
mod add; mod array; mod bang; mod call; mod closure; mod constant; mod current_closure; mod div; mod equal; mod get_builtin; mod get_free; mod get_global; mod get_local; mod greater_than; mod hash; mod index; mod jump; mod jump_not_truthy; mod minus; mod mreturn; mod mul; mod not_equal; mod null; mod ofalse; mod otrue;...
/* * 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 */ /// SyntheticsCiTestBody : Object describing the synthetics tests to trigger. #[derive(Clone, Debug, ...
use num_derive::FromPrimitive; use num_enum::IntoPrimitive; use num_traits::FromPrimitive; use bytes::{ Bytes, Buf, BytesMut, BufMut }; #[derive(FromPrimitive, IntoPrimitive, Debug, PartialEq, Copy, Clone)] #[repr(u8)] pub enum Result { Ok = 0x0, Waiting = 0x3, Done = 0x4, Failed = 0x5 } ...
use rand; use std::collections::HashMap; type Point = (f64, f64); type Centers = Vec<Point>; type Labels = Vec<usize>; // Can be moved to its own module fn calculate_euclidian_distance(p: Point, q: Point) -> f64 { let (x1, y1) = p; let (x2, y2) = q; let x = x1 - x2; let y = y1 - y2; return (x * ...
#[derive(Debug, Clone)] struct Heap<T: PartialOrd> { queue: Vec<T>, } impl<T: PartialOrd + Clone> Heap<T> { fn new(items: &[T]) -> Self { let mut new_heap = Heap { queue: vec![] }; for i in items { new_heap.add(i.clone()); } new_heap } fn add(&mut self, item...
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput}; use palette::convert::FromColorUnclamped; use palette::encoding; use palette::{Hsl, Hsv, Hwb, LinSrgb, Srgb}; #[path = "../tests/convert/data_color_mine.rs"] #[allow(dead_code)] mod data_color_mine; use data_color_mine::{load_data, Col...
/// Marker trait to indicate that borrowed references are stable, /// even when the owning object is moved. pub unsafe trait StableBorrow {} unsafe impl<'a> StableBorrow for &'a str {} unsafe impl<'a, T> StableBorrow for &'a [T] {} unsafe impl StableBorrow for String {} unsafe impl StableBorrow for std::path::PathBuf ...
use core::ops::{Index, IndexMut}; use alloc::boxed::Box; use super::*; pub mod file; pub const TABLE_SIZE : usize = 480; pub const FT_ENTRY_ALIGN : usize = 32; pub const ENTRIES_PER_TABLE : usize = TABLE_SIZE / FT_ENTRY_ALIGN; #[repr(u8)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum FileType { Nul...
//! This module contains a [`Padding`] setting of a cell on a [`Table`]. //! //! # Example //! #![cfg_attr(feature = "std", doc = "```")] #![cfg_attr(not(feature = "std"), doc = "```ignore")] //! use tabled::{Table, settings::{Padding, Style, Modify, object::Cell}}; //! //! let table = Table::new("2022".chars()) //! ...
#[macro_use] extern crate log; mod utils; mod rtc_crypto; use yew::{html, Callback, MouseEvent, Component, ComponentLink, Html, ShouldRender}; use wasm_bindgen::prelude::*; use yew_mdc::components::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")...
use std::{ collections::HashMap, fmt, net::{IpAddr, SocketAddr}, }; #[derive(PartialEq, Hash, Eq, Clone, PartialOrd, Ord, Debug, Copy)] pub enum Protocol { Tcp, Udp, } impl Protocol { #[allow(dead_code)] pub fn from_str(string: &str) -> Option<Self> { match string { "TC...
pub fn gray_code(n: i32) -> Vec<i32> { if n == 0 { return vec![0] } let m = 2usize.pow(n as u32); let mut graycode = vec![0; m]; graycode[1] = 1; let mut delta = 2; for i in 1..n as usize { for j in 0..delta { graycode[delta*2-1-j] = graycode[j] + delta as i32; ...
use crate::scene::Scene; use crate::spawns::*; pub trait Factory<E: Entity> { fn init(&mut self, group: Group); fn build(&self, spawn: &Spawn) -> E; } pub trait System<E: Entity> { fn requirements(&self, target: &E) -> bool; fn update(&mut self, spawn: &Spawn, scene: &mut Scene<E>); } pub trait Enti...
use crate::adc::{AdcPin, Instance}; use core::convert::Infallible; use core::marker::PhantomData; use cortex_m::delay::Delay; use embassy::util::Unborrow; use embassy_extras::unborrow; use embedded_hal::blocking::delay::{DelayMs, DelayUs}; pub const VDDA_CALIB_MV: u32 = 3000; pub enum Resolution { TwelveBit, ...
use actix_web::HttpResponse; pub use index3ds_common::*; pub trait ToHttpResponse { fn http(&self) -> HttpResponse; } impl ToHttpResponse for NcchInfoResponse { fn http(&self) -> HttpResponse { match self { NcchInfoResponse::Ok(_) => HttpResponse::Ok(), NcchInfoResponse::NotFou...
use std::env; use std::io::Write; use env_logger; pub fn set_logger() { match env::var("RUST_LOG") { Ok(val) => { let log_level: &str = &val; match log_level { "error" => { /* noop */ } "warn" => { /* noop */ } "info" => { /* noop */ ...
//! Traits for testing code that uses [`Instant`] and [`SystemTime`]. //! //! [`Instant`]: std::time::Instant //! [`SystemTime`]: std::time::SystemTime use core::{ops::Add, time::Duration}; use std::{ error::Error, time::{Instant, SystemTime, SystemTimeError}, }; use thiserror::Error; pub trait InstantLik...
#[doc = "Reader of register TRANSMIT_WINDOW_SIZE"] pub type R = crate::R<u32, super::TRANSMIT_WINDOW_SIZE>; #[doc = "Writer for register TRANSMIT_WINDOW_SIZE"] pub type W = crate::W<u32, super::TRANSMIT_WINDOW_SIZE>; #[doc = "Register TRANSMIT_WINDOW_SIZE `reset()`'s with value 0"] impl crate::ResetValue for super::TRA...
#[doc = "Register `MACFFR` reader"] pub type R = crate::R<MACFFR_SPEC>; #[doc = "Register `MACFFR` writer"] pub type W = crate::W<MACFFR_SPEC>; #[doc = "Field `PM` reader - Promiscuous mode"] pub type PM_R = crate::BitReader<PM_A>; #[doc = "Promiscuous mode\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq,...
mod math; use math::ray::hitable::{HitRecord, Hitable, HitableList, Sphere}; use math::ray::Ray; use math::vec::Vec3; use std::f32; fn main() { let nx: i32 = 200; let ny: i32 = 100; print!("P3\n{} {}\n255\n", nx, ny); let lower_left_corner = Vec3::new(-2.0, -1.0, -1.0); let horizontal = Vec3::new(...
use bit_field::BitArray; use bitflags::_core::cmp::min; fn main() { // println!("Hello, world!"); // // let mut t = SegmentTreeAllocator::new(8); // t.alloc(); // t.alloc(); // t.alloc(); // t.alloc(); // t.alloc(); // // // t.dealloc(1); // let mut a = vec![1u8,2u8,3u8...
use std::mem; use std::collections::BTreeMap; use lv2_raw::atom::*; use lv2_raw::urid::LV2_URID as LV2_URID; pub struct AtomSequenceIter { pub seq: *const LV2_Atom_Sequence, pub next: *const LV2_Atom_Event, pub total: usize, } pub struct SequenceData { pub data_type: LV2_URID, pub time_frames: i6...
use hlist::*; use ty::{ Ar1, Eval, Eval1, Infer, Tm, Ty, infer }; use ty::bit::{ _0, _1, }; use ty::nat::pos; /// Type-level negative integers #[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub enum Zn<P> {} /// Type-level positive integers #[derive(Clone, Copy...
use crate::packet::Packet; use std::collections::HashMap; pub enum OutputResult { Entry(HashMap<String, String>), Packet(Packet), }
use std::collections::HashMap; fn main() { part1(); part2(); } fn part1() { let grid = get_populated_grid(); let mut highest = 0; let mut highest_point = (0, 0); for x in 0..=297 { for y in 0..=297 { let window_value = get_window_value((x, y), &grid, 3); if wi...
// Copyright 2020 David Li // // 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 agreed to in wri...
use crate::common::*; #[derive(Debug)] pub(crate) enum Setting<'src> { DotenvLoad(bool), Export(bool), PositionalArguments(bool), Shell(Shell<'src>), } #[derive(Debug, PartialEq)] pub(crate) struct Shell<'src> { pub(crate) command: StringLiteral<'src>, pub(crate) arguments: Vec<StringLiteral<'src>>, }
//! The module contains [`LimitColumns`] records iterator. use crate::grid::records::IntoRecords; /// An iterator which limits amount of columns. #[derive(Debug)] pub struct LimitColumns<I> { records: I, limit: usize, } impl LimitColumns<()> { /// Creates new [`LimitColumns`]. pub fn new<I: IntoRecor...
#[doc = "Register `RCC_MC_CIFR` reader"] pub type R = crate::R<RCC_MC_CIFR_SPEC>; #[doc = "Register `RCC_MC_CIFR` writer"] pub type W = crate::W<RCC_MC_CIFR_SPEC>; #[doc = "Field `LSIRDYF` reader - LSIRDYF"] pub type LSIRDYF_R = crate::BitReader; #[doc = "Field `LSIRDYF` writer - LSIRDYF"] pub type LSIRDYF_W<'a, REG, c...
use std::collections::{HashMap, HashSet}; fn to_graph(input: &str) -> HashMap<&str, &str> { input .lines() .map(|line| { let mut parts = line.trim().split(')'); let a = parts.next().expect("aoc input"); let b = parts.next().expect("aoc input"); (b, a) }) .collect() } fn pat...
#[cfg(test)] mod tests { use crate::cpu::Cpu; use crate::word::Word; use crate::{byte_le}; use crate::interrupt::Interrupt; macro_rules! bt_le { ( 0 ) => { 0 }; ( 1 ) => { 1 }; ( T ) => { -1 }; ( $trit:tt, $($rest:tt),+ ) => { bt_le!($trit) + 3 * bt_le!($($rest),+) }; } #[test] fn test_init() { le...
use crate::State; use crate::{Instruction, HaltState}; #[derive(Debug)] pub enum Operation{ Addition, Multiplication, Store, Output, JumpIfTrue, JumpIfFalse, LessThan, Equals, AdjustRelativeBase } impl Operation{ pub fn process(&self, st: &mut State, ins: &Instruction) -> Optio...
//! The pixel component trait. #[cfg(feature = "f16-pixel-type")] use half::f16; use crate::format::{Format, SampleType}; /// A trait for possible pixel components. /// /// # Safety /// Implementing this trait allows retrieving slices of pixel data from the frame for the target /// type, so the target type must be v...
extern crate pest; #[macro_use] extern crate pest_derive; #[macro_use] extern crate conrod_core; extern crate conrod_glium; // #[macro_use] extern crate conrod_winit; extern crate find_folder; extern crate glium; #[derive(Parser)] #[grammar = "_.pest"] pub struct OiParser; mod support; use glium::Surface; fn main...
use sightglass_data::{Measurement, Phase}; use std::{ borrow::Cow, fmt::{self, Debug}, str::FromStr, }; /// An in-progress collection of measurements that are currently being recorded. pub struct Measurements<'a> { arch: &'a str, engine: &'a str, wasm: &'a str, process: u32, iteration: ...
use super::{alternative::AlternativeId, issue::IssueId, user::UserId, DbExecutor}; use crate::span::AsyncSpanHandler; use actix::prelude::*; use actix_interop::with_ctx; use color_eyre::eyre::{eyre, Report, WrapErr}; use serde::{Deserialize, Serialize}; use sqlx::{types::Uuid, Executor, Postgres}; use tracing::{debug, ...
mod commands; mod config; mod error; mod image; mod ini_writer; mod launcher; mod network; mod qmp; mod storage; mod template; #[macro_use] extern crate clap; use tokio; #[tokio::main] async fn main() { let c = commands::Commands {}; if let Err(e) = c.evaluate().await { println!("error: {}", e.to_stri...
mod camera; mod hit; mod material; mod ray; mod sphere; mod util; use camera::Camera; use core::f32; use glam::Vec3A; use hit::{Hittable, HittableList}; use material::Material; use rand::random; use ray::Ray; use sphere::Sphere; use std::io::Write; use util::{random_between, vec3a_random}; fn main() { let mut sph...
extern crate ci_test; #[cfg(test)] mod tests { use ci_test::add_two; #[test] fn add_two_test2() { assert_eq!(4, add_two(2)); } }
mod difficulty; mod merkle_tree; pub use difficulty::{ compact_to_difficulty, compact_to_target, difficulty_to_compact, target_to_compact, DIFF_TWO, }; pub use merkle_tree::{merkle_root, MergeByte32, CBMT};
extern crate actix; extern crate futures; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, AtomicBool, Ordering}; use actix::prelude::*; #[derive(Debug)] struct Num(usize); impl ResponseType for Num { type Item = (); type Error = (); } struct MyActor(Arc<AtomicUsize>, Arc<AtomicBool>); impl Actor f...
mod counter; mod data; mod meta_data; mod rc; mod size_hint_extending_iter; mod utils; pub use {counter::*, data::*, meta_data::*, rc::*, size_hint_extending_iter::*, utils::*};
#![feature(plugin, custom_derive)] #![plugin(rocket_codegen)] extern crate rocket; use std::net::SocketAddr; #[get("/")] fn get_ip(remote: SocketAddr) -> String { remote.to_string() } mod remote_rewrite_tests { use super::*; use rocket::local::Client; use rocket::http::{Header, Status}; use std...
#![feature(async_await, await_macro, futures_api)] #[macro_use] extern crate serde_derive; #[macro_use] extern crate typetag; #[macro_use] extern crate slog; #[macro_use] extern crate lazy_static; #[macro_use] extern crate derive_builder; #[macro_use] #[macro_export] pub mod macros; pub mod context; pub mod descr...
use std::io; #[allow(non_snake_case)] #[allow(dead_code)] pub fn string_merathon() { println!("Enter Any String?"); let mut b = String::new(); io::stdin().read_line(&mut b) .expect("Failed to read line"); println!("How many Times To Run?"); let mut toberun = String::new(); ...
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use std::sync::{Arc, Mutex}; use chrono::Local; use dns_lookup::lookup_addr; use etherparse::{Ethernet2Header, IpHeader, PacketHeaders, TransportHeader}; use maxminddb::Reader; use pcap::{Active, Address, Capture, Device}; use crate::countries::country_utils::get_country; u...
pub mod part1; pub mod part2; pub fn run() { part1::run(); part2::run(); } pub fn default_input() -> &'static str { include_str!("input") } pub fn parse_input(input : &str) -> Vec<Vec<&str>> { input.split("\n\n").map(|g| {g.split("\n").collect::<Vec<_>>()}).collect() }
extern crate bytes; use std::io::{Error, Read, ErrorKind, Result, BufReader, Cursor}; use bytes::*; macro_rules! define_read_var { ($wrapper_name:ident, $typ:ty, $maxb:expr) => { pub fn $wrapper_name(bytes: &mut Cursor<Bytes>) -> Result<($typ, usize)> { let mut num_read: usize = 0; ...
//! NDS hardware functions. pub mod gpu_cmds; pub mod texture_formats; pub mod texture_params; pub mod decode_texture; pub use self::texture_formats::{TextureFormat, FormatDesc, Alpha}; pub use self::texture_params::TextureParams; pub use self::decode_texture::decode_texture;
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::star_chain_client::{faucet_sync, ChainClient, MockChainClient}; use libra_types::account_address::AccountAddress; use std::thread::spawn; #[test] fn test_mock_chain_client_faucet() { ::libra_logger::try_init_for_test...
//! Implementation of the first depth search algorithm use std::io::{stdout, Write}; use std::{thread, time}; use crossterm::{ cursor::{Hide, MoveTo}, execute, style::{Color, Colorize, PrintStyledContent, SetBackgroundColor, SetForegroundColor}, Result, }; use rand; use rand::distributions::{Independe...
pub mod client; mod frame;
use clap::{App, Arg}; use thunderbird_email_backup::run; use thunderbird_email_backup::runtime::Operation; fn main() { let matches = App::new("Thunderbird email backup") .version("0.1") .author("Richard Bradshaw") .about("Easily back up the email in a thunderbird profile folder") .a...
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use super::{models, API_VERSION}; #[non_exhaustive] #[derive(Debug, thiserror :: Error)] #[allow(non_camel_case_types)] pub enum Error { #[error(transparent)] Operations_List(#[from] operations::l...
fn main() { #[cfg(target_os = "windows")] download_windows_npcap_sdk().unwrap(); } #[cfg(target_os = "windows")] fn download_windows_npcap_sdk() -> anyhow::Result<()> { use std::{ env, fs, io::{self, Write}, path::PathBuf, }; use anyhow::anyhow; use http_req::request; ...
/* This module contains structs for representing a card and methods to determine if three cards * form a set. It also contains an enum for the result of looking for a set in a hand. */ use indexmap::set::IndexSet; /* State for each characteristic of a card */ #[derive(Hash, Eq, PartialEq, Copy, Clone, Debug)] pub en...
use super::super::ui; use super::prelude::*; pub fn clear(state: &ui::State) { show_msg(state, ""); } pub fn show_msg(state: &ui::State, msg: &str) { let statusbar: gtk::Statusbar = state.get_statusbar(); statusbar.remove_all(0); statusbar.push(0, msg); }
use anyhow::Result; use uvm_cli; use uvm_core; use console::style; use std::env; use std::path::PathBuf; use structopt::{ clap::crate_authors, clap::crate_description, clap::crate_version, clap::AppSettings, StructOpt, }; use uvm_cli::{options::ColorOption, set_colors_enabled, set_loglevel}; const SETTINGS: &'st...
extern crate js_sys; extern crate web_sys; mod utils; use wasm_bindgen::prelude::*; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; #[wasm_bindgen] extern { fn...
use std::io; fn confirm_choice(prompt: &str) -> bool { let mut answer = String::new(); println!("{}", prompt); io::stdin().read_line(&mut answer) .expect("Failed to read line"); if answer.trim() == "y" || answer.trim() == "Y" { true } else { false } } fn new_entry(...
use crate::server::Events; use log::{error, trace}; use serde::{Deserialize, Serialize}; use std::borrow::Cow; use std::collections::BTreeMap; use tokio::io::AsyncBufReadExt; use tokio::sync::RwLock; const TWO_HOURS: std::time::Duration = std::time::Duration::from_secs(3600 * 2); #[derive(Deserialize, Clone, PartialE...