text
stringlengths
8
4.13M
// =============================================================================== // Authors: AFRL/RQQA // Organization: Air Force Research Laboratory, Aerospace Systems Directorate, Power and Control Division // // Copyright (c) 2017 Government of the United State of America, as represented by // the Secretary of th...
use necsim_core_bond::{ClosedUnitF64, NonNegativeF64}; #[must_use] #[inline] pub fn floor(val: f64) -> f64 { unsafe { core::intrinsics::floorf64(val) } } #[must_use] #[inline] pub fn ceil(val: f64) -> f64 { unsafe { core::intrinsics::ceilf64(val) } } #[must_use] #[inline] pub fn ln(val: f64) -> f64 { #[c...
use { Clipboard, errors::ClipboardError, clipboard_metadata::ClipboardContentType, }; use x11_clipboard::Clipboard as SystemClipboard; use std::time::Duration; pub struct X11Clipboard { inner: SystemClipboard, } impl Clipboard for X11Clipboard { type Output = Self; fn new() -> Result<Self::Output, Clipboard...
use azure_core::errors::{extract_status_headers_and_body, AzureError, UnexpectedHTTPResult}; use hyper::{Body, Client, Method, Request, StatusCode}; use hyper_tls::HttpsConnector; use serde::Deserialize; use serde_json::json; use crate::service::{ServiceClient, API_VERSION}; /// The DirectMethodResponse struct contai...
use bc::BlockChain; use proto::byzan; use ring::*; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Block { pub idx: u32, pub id: String, pub key: String, pub value: String, pub prev_hash: String, pub self_hash: String, } impl From<byzan::Block> for Block { fn from(b: byzan::Bloc...
extern crate pretty_env_logger; extern crate teledex; use teledex::{DefinitionFetcher, DexBot, MockDefinitionFetcher}; fn main() { pretty_env_logger::init(); let telegram_token = std::env::var("TELEGRAM_TOKEN") .expect("Must provide telegram bot token as TELEGRAM_TOKEN environment variable."); l...
#[doc = "Reader of register RCC_MP_APB5LPENCLRR"] pub type R = crate::R<u32, super::RCC_MP_APB5LPENCLRR>; #[doc = "Writer for register RCC_MP_APB5LPENCLRR"] pub type W = crate::W<u32, super::RCC_MP_APB5LPENCLRR>; #[doc = "Register RCC_MP_APB5LPENCLRR `reset()`'s with value 0x0011_391d"] impl crate::ResetValue for super...
// a trait which implements the print marker: `{:?}` use std::fmt::Debug; trait HasArea { fn area(&self) -> f64; } impl HasArea for Rectangle { fn area(&self) -> f64 { self.length * self.height } } #[derive(Debug)] struct Rectangle { length: f64, height: f64 } #[allow(dead_code)] struct Triangle { length: f6...
pub const REGION_DIM: u8 = 16; pub const REGION_LEN: usize = REGION_DIM as usize * REGION_DIM as usize;
pub mod display; pub mod parse; pub mod cache; /// The Cell type #[derive(Clone, Copy, PartialEq, Debug)] pub enum Cell { Unknown, Black, White, } /// A Picross board #[derive(Clone, Debug)] pub struct Picross { /// Height of the board pub height: usize, /// Length of the board pub length:...
use super::super::context::Context; use super::super::error::CrawlResult; use super::super::traits::WorkType; use super::super::utils::station_fn_ctx2; use super::super::work::{WorkBox, WorkOutput, Worker}; use conveyor::into_box; use conveyor_work::package::Package; use std::sync::Arc; #[derive(Debug, Serialize, Des...
use std::{ alloc::{handle_alloc_error, Layout}, mem::MaybeUninit, }; pub fn box_uninit<T>() -> Box<MaybeUninit<T>> { let layout = Layout::new::<MaybeUninit<T>>(); unsafe { let ptr: *mut MaybeUninit<T> = std::alloc::alloc(layout).cast(); if ptr.is_null() { handle_alloc_error(...
/// An enum to represent all characters in the Buhid block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Buhid { /// \u{1740}: 'ᝀ' LetterA, /// \u{1741}: 'ᝁ' LetterI, /// \u{1742}: 'ᝂ' LetterU, /// \u{1743}: 'ᝃ' LetterKa, /// \u{1744}: 'ᝄ' LetterGa, /// \u{174...
use std::{fmt::Debug, time::Duration}; use crate::Namespace; use futures::stream::{StreamExt, TryStreamExt}; use lazy_static::lazy_static; use semver::VersionReq; use serde::{de::DeserializeOwned, Deserialize, Serialize}; use crate::{ bson::{doc, to_document, Bson, Document}, error::{ErrorKind, Result, WriteF...
#[doc = "Register `D2CCIP2R` reader"] pub type R = crate::R<D2CCIP2R_SPEC>; #[doc = "Register `D2CCIP2R` writer"] pub type W = crate::W<D2CCIP2R_SPEC>; #[doc = "Field `USART234578SEL` reader - USART2/3, UART4,5, 7/8 (APB1) kernel clock source selection"] pub type USART234578SEL_R = crate::FieldReader<USART234578SEL_A>;...
extern crate proc_macro; use proc_macro::TokenStream; use proc_macro_hack::proc_macro_hack; mod from_captures; use from_captures::from_captures_impl; mod route; use route::route_impl; /// Derives `FromCaptures` for the specified struct. /// /// # Note /// All fields must have types that implements `yew_router::match...
#![cfg_attr(not(feature = "std"), no_std)] use frame_system::ensure_signed; use codec::{Encode, Decode}; use frame_support::{ decl_module, decl_storage, decl_event, decl_error, StorageValue, StorageDoubleMap, RuntimeDebug, dispatch, traits::{ Currency, ExistenceRequirement, Get, ReservableCurrency, WithdrawReason...
#![feature(nll)] extern crate lazy_static; extern crate dice_roller; use std::io; use dice_roller::rng::Rng; use dice_roller::dice::Dice; fn main() -> io::Result<()> { unsafe { Rng::feature_check(); } loop { let mut buffer = String::new(); match io::stdin().read_line(&mut buffer) ...
// pub mod bundle; // pub mod eid; pub mod stcp; pub mod cla; pub mod routing; pub mod cli; pub mod bus; pub mod conf; pub mod system; pub mod processor; pub mod user; pub mod agent;
use crate::error::ErrorMessage; use rocket_contrib::json::Json; use std::io; use std::process::Command; #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct UpdateACResponse { message: String, } #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct UpdateACReques...
use super::prelude::*; #[derive(Debug, Clone, PartialEq)] pub struct Index { pub left: Box<Expr>, pub index: Box<Expr>, } impl Display for Index { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "({}[{}])", self.left, self.index) } } impl TryFrom<Expr> for Index { type Err...
use std::sync::Arc; use std::sync::mpsc::sync_channel; use crate::framework::Runnable; use crate::mechatronics::bucket_ladder::Intake; use crate::mechatronics::commands::RobotCommandFactory; use crate::mechatronics::controller::RobotController; use crate::mechatronics::drive_train::DriveTrain; use crate::mechatronics:...
use crate::builder::HighwayBuilder; use crate::key::Key; use crate::traits::HighwayHash; use std::hash::{BuildHasher, Hasher}; #[derive(Debug, Default)] pub struct HighwayHasher { builder: HighwayBuilder, } impl HighwayHasher { pub fn new(key: Key) -> Self { HighwayHasher { builder: Highwa...
//! Manually create the interrupts portion of the vector table #![deny(unsafe_code)] #![deny(warnings)] #![no_main] #![no_std] extern crate cortex_m_rt as rt; extern crate panic_halt; use rt::entry; #[entry] fn main() -> ! { loop {} } // interrupts portion of the vector table pub union Vector { handler: un...
use std::ops::*; use std::fmt; use std::default::Default; #[derive(Debug, Copy, Clone)] pub struct Vec2 { pub x: f32, pub y: f32 } impl Vec2 { #[inline(always)] pub fn new(_x: f32, _y: f32) -> Vec2 { Vec2 { x: _x, y: _y } } #[inline(always)] pub fn ...
use super::*; #[derive(Clone, PartialEq)] pub enum Token { Inc, Dec, Fwd, Rev, Prnt, Inp, OpenWhile(usize), CloseWhile(usize), End, } pub trait TokenizeBF { fn tokenize(&self) -> Result<Vec<Token>>; } impl TokenizeBF for String { fn tokenize(&self) -> Result<Vec<Token>> {...
extern crate glium; extern crate ctrlc; extern crate winit; extern crate notify; #[macro_use] extern crate objc; mod handle; use std::process::{Command, Child}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::sync::mpsc::channel; use std::time::Duration; use std::thread::sleep; use winit...
#![recursion_limit = "1024"] extern crate gl; extern crate glutin; extern crate libc; extern crate glm; extern crate num_traits; #[macro_use] extern crate error_chain; mod errors { error_chain!{} } use glutin::GlContext; use errors::*; use gl::types::*; use num_traits::identities::One; use std::ffi::CString; u...
use crate::{ keywords::{compile_draft_validators, DraftValidator}, types::{ draft_version::DraftVersion, keyword_type::KeywordType, schema_error::SchemaError, scope_builder::ScopeBuilder, validation_error::ValidationError, validator_error_iterator::ValidationErrorIterator, }, }; use json_tra...
// Rust Bitcoin Library // Written by // The Rust Bitcoin developers // // To the extent possible under law, the author(s) have dedicated all // copyright and related and neighboring rights to this software to // the public domain worldwide. This software is distributed without // any warranty. // // You should have ...
// Copyright 2021 The Matrix.org Foundation C.I.C. // // 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...
//! Extract and normalize author names. //! //! Names in the book data — both in author records and in their references in //! book records — come in a variety of formats. This module is responsible for //! expanding and normalizing those name formats to improve data linkability. //! Some records also include a year o...
use crate::aoc_utils::read_input; use std::collections::HashMap; use std::time::Instant; pub fn run(input_filename: &str) { let input = read_input(input_filename); let nums: Vec<u64> = input .split(',') .map(|n| n.parse::<u64>().unwrap_or(0)) .collect(); part1(&nums); part2(&n...
mod noprogress; pub use noprogress::NoProgress; pub trait Progress { type Id: Eq + Ord + std::hash::Hash; type Item: ?Sized; type Status: ?Sized; type ItemStatus: ?Sized; fn size_hint(&self, _hint: (usize, Option<usize>)) { } fn item(&self, id: Self::Id, item: &Self::Item); fn item_status(&self, id: Self:...
/* ---Sudoku Validator--- Given a Sudoku data structure with size NxN, N > 0 and √N == integer, write a method to validate if it has been filled out correctly. The data structure is a multi-dimensional Array, i.e: [ [7,8,4, 1,5,9, 3,2,6], [5,3,9, 6,7,2, 8,4,1], [6,1,2, 4,3,8, 7,5,9], [9,2,8, 7,1,5, 4...
#[get("/world")] pub fn world() -> &'static str { "Hello, world!" } #[get("/<name>/<age>")] pub fn hello(name: String, age: u8) -> String { format!("Hello, {} year old named {}!", age, name) }
use ::*; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct Version { major: i32, minor: i32, } #[derive(Debug, Clone)] pub struct ContextAttributes { pub alpha: bool, pub depth: bool, pub stencil: bool, pub antialias: bool, pub premultiplied_alpha: bool, pub preserve_drawin...
use std::borrow::Cow; use std::fmt; /// Equivalent to typescript type /// `'avatar'|'icon'|'medium'|'large'|'control'|null` /// /// See `GraphicType` [here](https://github.com/material-components/material-components-web-components/tree/master/packages/list#mwc-list-item-1) #[derive(Clone, Debug)] pub enum GraphicType ...
use crate::prelude::*; pub mod prelude { pub use super::{ UnsignedRemainder }; } mod marker { use crate::prelude::*; use crate::ExprMarker; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct UnsignedRemainderMarker; impl ExprMarker for UnsignedRemainderMarker { ...
use prelude::*; use config::{Config}; use enigo::{self,Enigo,KeyboardControllable}; use std::cell::RefCell; pub enum Event { KeyDown(u8), KeyUp(u8), } impl Event { pub fn from_raw(ev_byte: u8) -> Event { let idx = ev_byte & 0x7F; let state = (ev_byte & 0x80) != 0; if state { ...
extern crate doc_tests; use self::doc_tests::*; fn main() { println!("{}", sum(9, 33)); }
use crate::get_result; use itertools::Itertools; // https://adventofcode.com/2020/day/11 // https://www.reddit.com/r/rust/comments/kb3umi/advent_of_code_2020_day_11/ const INPUT_FILENAME: &str = "inputs/input11"; enum Part { ONE, TWO, } pub fn solve() { get_result(1, part01_optimized, INPUT_FILENAME); ...
use std::{ collections::HashMap, net::IpAddr, sync::{Arc, Mutex}, }; use insta::assert_snapshot; use packet_builder::*; use pnet::{datalink::DataLinkReceiver, packet::Packet}; use crate::{ start, tests::{ cases::test_utils::{ build_tcp_packet, opts_raw, os_input_output_dns, os_...
use std::borrow::Borrow; use std::mem::{self, ManuallyDrop}; use std::ops::Deref; use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use super::gen_lock::GenLockStrategy; use super::sealed::{CaS, InnerStrategy, Protected}; use crate::debt::Debt; use crate::gen_lock::{GenLock, LockStorage}; use crate::ref_cnt:...
use std::collections::HashMap; use std::io; use std::io::BufRead; use std::io::BufReader; #[derive(Copy, Clone)] struct Action { write: usize, move_right: bool, next_state: u8, } impl Action { fn new() -> Self { Action { write: 0, move_right: false, next_sta...
/// An enum to represent all characters in the Hatran block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Hatran { /// \u{108e0}: '𐣠' LetterAleph, /// \u{108e1}: '𐣡' LetterBeth, /// \u{108e2}: '𐣢' LetterGimel, /// \u{108e3}: '𐣣' LetterDalethDashResh, /// \u{108e4}...
#![allow(warnings)] use aoc::read_data; use std::error::Error; use std::num::ParseIntError; use std::rc::Rc; use std::str::FromStr; use std::sync::mpsc::sync_channel; use std::sync::Arc; #[derive(Clone, Copy, PartialEq, Debug)] enum Bus { Id(usize), X, } impl Bus { pub fn unwrap(self) -> usize { m...
use palette::{Rgb, Hsl, RgbHue, IntoColor}; use kdtree::kdtree::KdtreePointTrait; use cgmath::{Point3, EuclideanSpace}; struct LedInfo { pub loc: Point3<f64>, pub visibility: u64, } #[derive(Copy, PartialEq, Clone, Debug)] struct Particle { pub loc: Point3<f64>, pub color: Rgb, pub radius: f64,...
use regex::Regex; use std::cmp::{max, Ordering}; use std::collections::HashMap; use std::fs; use std::io; type Reaction = HashMap<String, (isize, Vec<(String, isize)>)>; type Stock = HashMap<String, isize>; fn parse_reactions(input: &str) -> Reaction { let re = Regex::new(r"(\d+) ([A-Z]+)").unwrap(); input ...
use super::{ combat::{ATTACK_DURATION, WIELD_DURATION}, movement::ROLL_DURATION, }; use crate::{ comp::{ self, item, projectile, ActionState::*, Body, CharacterState, ControlEvent, Controller, Item, MovementState::*, PhysicsState, Projectile, Stats, Vel, ...
#[doc = "Register `DINR20` reader"] pub type R = crate::R<DINR20_SPEC>; #[doc = "Field `DIN20` reader - Input data received from MDIO Master during write frames"] pub type DIN20_R = crate::FieldReader<u16>; impl R { #[doc = "Bits 0:15 - Input data received from MDIO Master during write frames"] #[inline(always)...
use super::Captures; use super::Matcher; use crate::matcher::MatcherProvider; use regex::Regex; impl MatcherProvider for Regex { fn match_route_string<'a, 'b: 'a>(&'b self, route_string: &'a str) -> Option<Captures<'a>> { if self.is_match(route_string) { let names: Vec<&str> = self ...
/* chapter 4 syntax and semantics */ struct Electron; fn main() { let n = Electron; } // output should be: /* */
// Copyright 2017 The Spade Developers. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except acc...
use std::{thread, time}; #[cfg(target_os = "linux")] extern crate notify_rust; #[cfg(target_os = "macos")] extern crate mac_notification_sys; #[cfg(target_os = "macos")] use mac_notification_sys::*; #[cfg(target_os = "linux")] use notify_rust::{Notification, Timeout}; fn main() { #[cfg(target_os = "macos")] ...
use std::mem; use pin_project::pin_project; use tokio::sync::watch; use std::future::Future; use std::pin::Pin; use std::task::{self, Poll}; pub async fn channel() -> (Signal, Watch, watch::Receiver<()>) { let (tx, mut rx) = watch::channel(()); rx.recv().await; (Signal { tx }, Watch { rx: rx.clone() }, r...
fn main() { println!("Cubasm") }
extern crate rand; extern crate nalgebra; mod input; mod structs; mod nn; use input::{read, commands}; use std::env; use structs::{FlowerName, Classifier}; extern crate nalgebra as na; fn main() { // parses commands let (data, config, subcom) = commands(); // gets path for data let path = env::curr...
pub mod locale; pub mod utils; pub use locale::get_system_locale; pub use utils::{ enable_vt_processing, get_default_config, get_default_env, get_ls_colors, stderr_write_all_and_flush, stdout_write_all_and_flush, };
#![no_std] #![allow(non_snake_case)] #![allow(non_camel_case_types)] //! # LuaJIT 2.1 //! //! <http://luajit.org> //! //! <http://www.lua.org/manual/5.1/manual.html> //! //! ## Performance considerations //! //! The _Not Yet Implemented_ guide documents which language features will be JIT compiled //! into native mach...
use std::sync::Arc; use ntex::web::{ types::{Json, State}, HttpResponse, Responder, }; use crate::{errors::CustomError, models::{article::Article, user::Admin}, AppState}; // #[web::post("/article")] pub async fn new_article( _: Admin, article: Json<Article>, state: State<Arc<AppState>>, ) -> Res...
use super::{BuiltinType, Function}; #[derive(Debug, Clone, Eq)] pub struct TypeID { pub idx: usize, pub ptr: bit_vec::BitVec <u8>, pub mutable: bool } impl PartialEq for TypeID { fn eq(&self, other: &Self) -> bool { self.idx == other.idx && self.ptr == other.ptr } } impl TypeID { pub ...
use k8s_openapi::api::core::v1::Pod; use kube::{ api::{Api, ListParams, ResourceExt}, Client, }; use tracing::*; const PAGE_SIZE: u32 = 5; #[tokio::main] async fn main() -> anyhow::Result<()> { tracing_subscriber::fmt::init(); let client = Client::try_default().await?; let api = Api::<Pod>::defaul...
mod comic; mod item; mod item_type; mod log_entry; mod news; mod occurrence; mod token; pub use comic::*; pub use item::*; pub use item_type::*; pub use log_entry::*; pub use news::*; pub use occurrence::*; pub use token::*;
use std::rc::Rc; use std::cell::RefCell; use std::num::FromPrimitive; use std::path::Path; use sdl2_window::Sdl2Window; use event::{Events, GenericEvent}; use graphics::{Context, ImageSize}; use input::{keyboard, mouse, Button}; use opengl_graphics::{Gl, Texture}; #[derive(FromPrimitive, PartialEq)] pub enum MainMenu...
mod get_devices; mod get_device_info; pub use get_devices::*; pub use get_device_info::*;
use std::io; #[derive(Debug)] pub enum Error { Io(io::Error), Generic(String), Utf8Error(std::str::Utf8Error), } pub type Result<T> = std::result::Result<T, Error>; impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { match *self { Er...
#![crate_name = "client"] #![crate_type = "bin"] #![allow(dead_code)] extern crate debug; extern crate nanomsg; use std::io::{Reader,Writer}; use nanomsg::AF_SP; use nanomsg::NN_PAIR; use nanomsg::NanoSocket; fn main() { let socket_address = "tcp://127.0.0.1:5555"; println!("client connecting to '{:s}'", soc...
use base::Bits; pub fn encode(input: Vec<u8>) -> Vec<u8> { let mut output = Bits::new(); for byte in input { for index in 0..=7 { let mask = 1 << (7 - index); output.push(byte & mask != 0); } } return output.finalize(); } pub fn decode(input: Vec<u8>) -> Vec<u...
pub mod api; pub mod auth; pub mod endpoints; pub mod health; mod id; pub mod kafka; pub mod labels; mod serde; pub mod version; pub use id::*;
use proconio::input; fn main() { input! { a:u32, b:u32, } let ans: &str = if a + b == 15 { "+" } else if a * b == 15 { "*" } else { "x" }; println!("{}", ans); }
extern crate phf_codegen; use std::ascii::AsciiExt; use std::env; use std::fs::File; use std::io::{Write, BufWriter}; use std::path::Path; use std::convert::AsRef; const ERRCODES_TXT: &'static str = r#" # # errcodes.txt # PostgreSQL error codes # # Copyright (c) 2003-2016, PostgreSQL Global Development Group # #...
use crate::block_hasher::HashProgress; use crate::file_tree::{FileTree, FileTreeProcessor}; use crate::hash_file::{HashFile, HashFileEntry}; use crate::{HashFileFormat, HashType}; use cancellation::{CancellationToken, CancellationTokenSource}; use crossbeam::channel::{select, unbounded, Sender}; use regex::Regex; use s...
//! Contains the code that listens to control channel connections in a non-proxy protocol mode. use super::{chosen::OptionsHolder, ServerError}; use crate::server::failed_logins::FailedLoginsCache; use crate::server::shutdown; use crate::{auth::UserDetail, server::controlchan, storage::StorageBackend}; use std::net::S...
//! This crate provides `hex!` macro for converting hexadecimal string literal //! to byte array at compile time. //! //! It accepts the following characters in the input string: //! //! - `'0'...'9'`, `'a'...'f'`, `'A'...'F'` — hex characters which will be used //! in construction of the output byte array //! - `'...
use crate::memory; use core::ops::Range; unsafe fn bss_range() -> Range<*mut usize> { extern "C" { static mut __bss_start: usize; static mut __bss_end: usize; } Range { start: &mut __bss_start, end: &mut __bss_end, } } #[inline(always)] unsafe fn zero_bss() { memor...
use std::path::Path; use std::collections::HashMap; use std::iter::FromIterator; use std::fmt; extern crate ansi_term; extern crate image; use self::ansi_term::Color as AnsiColor; use self::image::DynamicImage; /// Type that associates a `PixelColor` to how many pixels in image pub type ColorCounts = Vec<(PixelColor...
#![no_std] #![no_main] #![feature(asm)] #![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 defmt::*; use embassy::executor::Spawner; use embassy_rp::{gpio, Peripherals}; u...
use nia_interpreter_core::EventLoopHandle; use nia_interpreter_core::Interpreter; use nia_interpreter_core::NiaChangeMappingCommandResult; use nia_interpreter_core::NiaInterpreterCommand; use nia_interpreter_core::NiaInterpreterCommandResult; use std::sync::MutexGuard; use nia_protocol_rust::ChangeMappingResponse; us...
//! Actions, world updates the clients _intend_ to execute. //! mod attack_intent; mod dropoff_intent; mod log_intent; mod mine_intent; mod move_intent; mod pathcache_intent; mod spawn_intent; pub use self::attack_intent::*; pub use self::dropoff_intent::*; pub use self::log_intent::*; pub use self::mine_intent::*; pu...
use crate::error::{Error, Result}; use std::alloc::{self, Layout}; use std::mem; use std::ptr; #[derive(Debug)] pub struct Buffer { buf: *mut char, capacity: usize, gap_start: usize, gap_end: usize, } impl Buffer { const INIT_CAPACITY: usize = 65536; const GROW_CAPACITY: usize = 65536; con...
use argh::FromArgs; use assembly_pack::pk::reader::PackFile; use std::fs::File; use std::io::BufReader; use std::path::PathBuf; #[derive(FromArgs)] /// List the entries in a PK file struct Args { #[argh(positional)] /// the PK file file: PathBuf, } fn main() -> color_eyre::Result<()> { color_eyre::ins...
use std::convert::TryFrom; use std::ops::Range; use std::mem; use std::sync::{ Arc, Mutex }; use std::sync::atomic::{ AtomicUsize, Ordering }; use bitwise::morton; use cgmath::prelude::*; use itertools; use rayon::prelude::*; use crate::prelude::*; use crate::interaction::SurfaceInteraction; use crate::primitive::Pri...
pub mod mine; pub mod dwarf;
use failure::Fallible; use slog::{self, o, Drain}; // use slog_async; use slog_scope::{error, info, warn}; use slog_term; use std::sync::Arc; use rustberry::playback_requests::*; use rustberry::rfid::*; fn handle_tag(tag: Tag) -> Fallible<()> { let mut tag_reader = tag.new_reader(); let request_string = tag_r...
//! Containers style #![allow(clippy::module_name_repetitions)] use iced::widget::container::Appearance; use iced::{Background, Color}; use crate::gui::styles::style_constants::{ get_alpha_chart_badge, get_alpha_round_borders, get_alpha_round_containers, BORDER_ROUNDED_RADIUS, BORDER_WIDTH, }; use crate::gui...
extern crate num_traits; // Source: https://webarchive.nationalarchives.gov.uk/ukgwa/20160107193025/http://www.ons.gov.uk/ons/guide-method/geography/beginner-s-guide/census/output-area--oas-/index.html // We ignore the inner rings of polygons? extern crate polylabel; use std::collections::HashMap; use std::convert::T...
use error::RedError; use libc; use sds::SDS; use std; use std::mem::{size_of, transmute}; use std::ptr; pub const GREATER: &'static str = ">"; pub const GREATER_EQUAL: &'static str = ">="; pub const LESSER: &'static str = "<"; pub const LESSER_EQUAL: &'static str = "<="; pub const EQUAL: &'static str = "="; pub const ...
pub mod ring; pub mod ring_grpc;
/* chapter 4 syntax and semantics */ struct Circle { h: f64, v: f64, r: f64, } impl Circle { fn area(&self) -> f64 { std::f64::consts::PI * (self.r * self.r) } } struct CircleBuilder { h: f64, v: f64, r: f64, } impl CircleBuilder { fn new() -> CircleBuilder { CircleB...
use x11::xlib::{ Window as XWindow, XA_WINDOW, XDefaultRootWindow, XFree, XGetWMName, XTextProperty, }; use std::{ ffi::CStr, ops::Drop, os::raw::c_void, ptr::null_mut, slice, }; use crate::{ Atom, Display, NET_ACTIVE_WINDOW, NotSupported, Null, util::...
//! ChaCha20Poly1305 Authenticated Encryption with Additional Data Algorithm //! (RFC 8439) #![no_std] extern crate alloc; mod cipher; #[cfg(feature = "xchacha20poly1305")] mod xchacha20poly1305; pub use aead; #[cfg(feature = "xchacha20poly1305")] pub use xchacha20poly1305::XChaCha20Poly1305; use self::cipher::Cip...
pub mod answer; pub mod header; pub mod message; pub mod question; pub mod server;
use nom::error::{ErrorKind as NomErrorKind, ParseError as NomParseError}; pub type Input<'a> = &'a str; pub type Result<'a, T> = nom::IResult<Input<'a>, T, Error<Input<'a>>>; #[derive(Debug)] pub struct Error<I> { pub errors: Vec<(I, NomErrorKind)>, } impl<I> NomParseError<I> for Error<I> { fn from_error_kin...
mod canvas; mod label; mod nop; pub use canvas::{Canvas, CanvasState}; pub use label::{Label, LabelState}; pub use nop::{Nop, NopState};
pub mod group; pub mod zgroup;
use compile::utils::try_compile_block; use eval; use eval::exec::exec_until_done; use std::io; use std::io::Write; const STARTING_SNIPPET: &'static str = " print 'Starting REPL'; "; #[allow(unused_must_use)] pub fn do_repl() { let mut run_state = eval::initial_run_state(STARTING_SNIPPET, "<repl>"); let stdi...
//! The half-lock structure //! //! We need a way to protect the structure with configured hooks ‒ a signal may happen in arbitrary //! thread and needs to read them while another thread might be manipulating the structure. //! //! Under ordinary circumstances we would be happy to just use `Mutex<HashMap<c_int, _>>`. H...
use crate::targets::Failure; use core::str::Lines; use regex::Regex; use std::collections::VecDeque; lazy_static::lazy_static! { static ref FAILURE_RE: Regex = Regex::new(r"Z \w+Error").expect("Valid regex"); static ref URL_RE: Regex = Regex::new(r"URL: (.+)").expect("Valid regex"); } pub(crate) fn process_st...
use std::io; use rand::Rng; fn main() { let word_vec = vec!["word", "computer", "history", "science", "space"]; let random_index = rand::thread_rng().gen_range(0..4); let secret_word: String = word_vec[random_index].to_string(); let count = secret_word.chars().count(); let mut lives = 0; l...