text
stringlengths
8
4.13M
//! Test the [`clean_name`] function. use super::clean_name; #[test] fn test_clean_point() { let name = "W. Seiler"; let clean = clean_name(name); assert_eq!(&clean, "W Seiler"); } #[test] fn test_clean_spaces() { let name = "Zaphod Beeblebrox"; let clean = clean_name(name); assert_eq!(&clea...
// emuns are types which have a few definite values enum Movements { // Variants up, down, left, right } fn move_game(m: Movements){ match m { Movements::up => println!("Game is moving up"), Movements::down => println!("Game is moving down"), Movements::left => print...
use std::cmp; use std::collections; use std::ops; use rand::Rng; use rand; pub fn sum(rolls: &Vec<i32>) -> i32 { rolls.iter().fold(0, ops::Add::add) } pub fn roll(count: i32, sides: i32) -> Vec<i32> { let mut result = Vec::new(); for _ in 0..count { result.push(rand::thread_rng().gen_range(1, sid...
use core::f64::consts::*; use crate::coord_plane::CartPoint; use crate::projections::projection_types::ProjectionParams; pub fn mercator(params: ProjectionParams) -> Vec<CartPoint> { match params { ProjectionParams::PointsOnly(points) => { points.iter().map( |llpoint| CartPoint { ...
use criterion::{criterion_group, criterion_main, Criterion, BenchmarkId}; use std::fs::File; use std::io::prelude::*; use std::os::raw::{c_void, c_int}; use fastlz_sys::fastlz_compress_level as sys_compress; use fastlz_rs::fastlz_compress_level as native_compress; const CORPORA_DIR: &'static str = "../compression-c...
//! Most general VapourSynth API functions. use std::ffi::{CStr, CString, NulError}; use std::os::raw::{c_char, c_int, c_void}; use std::ptr::{self, NonNull}; use std::sync::atomic::{AtomicPtr, Ordering}; use std::{mem, panic, process}; use vapoursynth_sys as ffi; use crate::core::CoreRef; /// A wrapper for the Vapo...
use crate::{ core, server::{ route::auth::{password_meta, PasswordMeta}, route_json_config, route_response_empty, route_response_json, validate, Data, Error, FromJsonValue, }, }; use actix_web::{middleware::identity::Identity, web, HttpResponse}; use futures::{future, Future}; use va...
mod actor; mod ai; mod arena; mod geometry; mod tools; use crate::arena::{show, tick}; use crate::tools::clrscr; use actor::Actor; use arena::{Arena10x10, Layer10x10}; use geometry::Position; use std::thread; use std::time::Duration; fn main() { let mut player = Actor::new_player(Position::new(1, 1), '*'); le...
extern crate hyper; use hyper::Server; use hyper::server::Request; use hyper::server::Response; use hyper::net::Fresh; fn hello(req: Request, res: Response<Fresh>) { // println!("Got request"); let msg = format!("Hello, I don't know you, but you are asking for {:?}, right?", req.uri).into_bytes(); res.sen...
use super::connecter::skyway_connecter::{self, SkywayConnecter}; use super::page::{ initializer::{self, Initializer}, room_initializer::{self, RoomInisializer}, room_selector::{self, RoomSelector}, }; use super::util::router; use crate::libs::bcdice::js::DynamicLoader; use crate::libs::skyway; use crate::mo...
use avocado::prelude::*; use bson; use failure::Error; use crate::model::session::Session; // // // #[derive(Debug, Clone, Serialize, Deserialize, Doc)] pub struct User { #[serde(rename = "_id", skip_serializing_if = "Option::is_none")] pub id: Option<Uid<User>>, pub email: Option<String>, pub sub: ...
//! Global values. pub use self::obj::*; pub mod obj; use ir::Constant; pub struct GlobalValue<'ctx>(Constant<'ctx>); impl_subtype!(GlobalValue => Constant);
enum CitySize { Town, // approximate residents: 1_000 City, // approximate residents: 10_000 Metropolis, // approximate residents: 1_000_000 } struct City { description: String, residents: u64, is_coastal: bool, } impl City { fn new(city_size: CitySize, is_coastal: bool) -> Cit...
use crate::{Vec3}; #[derive(PartialEq, Debug)] pub struct SurfaceInteraction { pub point: Vec3, pub t_hit: f32, pub normal: Vec3 }
use std::io; use std::net::SocketAddr; use std::os::windows::io::AsRawSocket; use super::super::{add_socket, co_io_result, EventData}; #[cfg(feature = "io_cancel")] use crate::coroutine_impl::co_cancel_data; use crate::coroutine_impl::{is_coroutine, CoroutineImpl, EventSource}; #[cfg(feature = "io_cancel")] use crate:...
use crate::data::*; pub fn place_clue ( line: & Line, size: LineSize, ) -> CluePlacer <'_> { CluePlacer::new ( line, size, ) } pub struct CluePlacer <'a> { line: & 'a Line, size: LineSize, start: LineSize, } impl <'a> CluePlacer <'a> { fn new ( line: & Line, size: LineSize, ) -> CluePlacer <'_> {...
use cairo::{self, Context, ImageSurface}; use gdk::{Cursor, CursorType, EventMask, ModifierType, ScrollDirection}; use gio::prelude::*; use gtk::{prelude::*, DrawingArea, FileChooserExt, ResponseType, WidgetExt}; use std::{f64::consts::PI}; use gdk::WindowExt; use glib::clone; use gtk::{Application, ApplicationWindow}...
use crate::config::BlockAssemblerConfig; use crate::error::Error; use ckb_core::block::Block; use ckb_core::cell::ResolvedTransaction; use ckb_core::extras::EpochExt; use ckb_core::header::Header; use ckb_core::script::Script; use ckb_core::service::{Request, DEFAULT_CHANNEL_SIZE, SIGNAL_CHANNEL_SIZE}; use ckb_core::tr...
//! A representation of memory given by an executable/loader. use error::*; use translator::TranslationMemory; use std::collections::BTreeMap; use std::cmp::{Ord, Ordering, PartialOrd}; bitflags! { /// RWX permissions for memory. pub struct MemoryPermissions: u32 { const NONE = 0b000; const...
#[macro_export] macro_rules! static_table { ($($line:expr)*) => { concat!( $($line, "\n",)* ) .trim_end_matches('\n') }; } #[macro_export] macro_rules! test_table { ($test:ident, $table:expr, $($line:expr)*) => { #[test] fn $test() { $crate::a...
//! Pokemon // Features #![feature(format_args_capture, array_methods)] // Modules mod ability; mod base_stats; mod body_color; mod egg_group; mod growth_rate; mod item; mod species; mod ty; // Exports pub use ability::Ability; pub use base_stats::{BaseStats, Gender}; pub use body_color::BodyColor; pub use egg_group...
use crate::common::Loc; use crate::lexer::token::Token; use std::error::Error as StdError; use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub enum ParseError { UnexpectedToken(Token), NotExpression(Token), UnclosedOpenParen(Loc), RedudantClosedParen(Token), RedudantExpression(Token), ...
extern crate rust_gpiozero; use rust_gpiozero::*; fn main() { // Create a button which is attached to Pin 2 // Wait for button press // print message }
use cssparser::{Color as CssColor, Parser, ParserInput, ToCss}; use std::{borrow::Cow, fmt::Display, str::FromStr}; #[cfg(feature = "serde_de")] use serde::{de, Deserialize, Deserializer, Serialize}; use super::error::ColorError; const DEFAULT_WHITE: &'static str = "rgb(255, 255, 255)"; const DEFAULT_BLACK: &'static...
use std::io::{Error, ErrorKind}; use std::iter::Iterator; use std::fmt; #[derive(Default, Clone)] pub struct Headers { f: Vec<(Vec<u8>,Vec<u8>)>, } impl Headers { pub fn new() -> Self { Self::default() } pub fn ok() -> Self { Self { f: vec![ (":status".int...
use bytes::Bytes; use ed25519::signature::Verifier; use ed25519_dalek::{PublicKey}; use hash::{self, KECCAK_NULL_RLP, KECCAK_EMPTY_LIST_RLP, keccak}; use rand::distributions::Distribution; use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream}; use rustc_hex::{ToHex}; use std::cmp; use std::collections::{BTreeMa...
use grid::Grid; use regex::Regex; use std::fmt; use std::str::FromStr; use std::string::ParseError; struct Location { pub x: usize, pub y: usize, pub id: Option<String>, pub num_closest: u32, pub infinite: bool, } static mut NEXT_ID: usize = 0; static ALPHABET: &str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; impl From...
#![feature(custom_derive, plugin)] #![plugin(serde_macros)] #![cfg_attr(feature="clippy-lint", plugin(clippy))] #[cfg_attr(feature="afl", feature(plugin))] #[cfg_attr(feature="afl", plugin(afl_coverage_plugin))] #[cfg(feature="afl")] extern crate afl_coverage; extern crate ansi_term; extern crate getopts; #[macro_us...
use crate::comp; use parking_lot::Mutex; use specs::Entity as EcsEntity; use sphynx::Uid; use std::{collections::VecDeque, ops::DerefMut}; use vek::*; pub enum LocalEvent { Jump(EcsEntity), WallLeap { entity: EcsEntity, wall_dir: Vec3<f32>, }, Boost { entity: EcsEntity, ...
//! A simple and lightweight fuzzy search engine that works in memory, searching for //! similar strings (a pun here). //! //! # Examples //! //! ``` //! use simsearch::SimSearch; //! //! let mut engine: SimSearch<u32> = SimSearch::new(); //! //! engine.insert(1, "Things Fall Apart"); //! engine.insert(2, "The Old Man ...
use std::boxed::Box; // use std::cell::{Cell, RefCell}; // use std::rc::Rc; use std::cmp::Ordering; // use std::borrow::Borrow; // immutable version #[derive(Debug, Clone)] enum BinTree<T: Ord + Copy> { Leaf { v: T, l: Box<Self>, r: Box<Self> }, Empty } impl<T: Ord + Copy> BinTree<...
use crate::{ErrorKind, Result}; use clap::{App, Arg, ArgMatches}; use ronor::{PlaybackState, Sonos}; pub const NAME: &str = "now-playing"; pub fn build() -> App<'static, 'static> { App::new(NAME) .visible_alias("np") .about("Describes what is currently playing") .arg(Arg::with_name("GROUP")) } pub fn r...
#[macro_use] extern crate mime; extern crate iron; extern crate router; use iron::prelude::*; use iron::status; use router::Router; fn main() { let mut router = Router::new(); router.get("/", page, "index"); router.get("/static/:name", static_file, "static_file"); let server = Iron::new(router).http("...
use cgmath::{Point3, Vector3, prelude::InnerSpace]; use std::marker::PhantomData; use super::intersection::Intersection; use super::ray::Ray; use crate::components::{Sphere, Transform}; pub struct IntersectionChecker<T> { _t: PhantomData<T>, } const EPSILON: f64 = 0.0000000001; impl IntersectionChecker<Sphere> {...
/// An enum to represent all characters in the BraillePatterns block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum BraillePatterns { /// \u{2800}: '⠀' BraillePatternBlank, /// \u{2801}: '⠁' BraillePatternDotsDash1, /// \u{2802}: '⠂' BraillePatternDotsDash2, /// \u{2803}: '⠃' ...
use artell_domain::image::{Image, ImageRepository}; use std::path::PathBuf; pub struct FsImageRepository { path: PathBuf, } impl FsImageRepository { pub fn new(path: PathBuf) -> Self { assert!(path.is_dir()); FsImageRepository { path } } } #[async_trait] impl ImageRepository for FsImageR...
use std::rc::Rc; use nitro::Name; use nitro::info_block; use errors::Result; use util::cur::Cur; use nds::{TextureParams, TextureFormat}; pub struct Texture { pub name: Name, pub params: TextureParams, pub data1: Vec<u8>, /// Only used by block-compressed textures. pub data2: Vec<u8>, } pub struct...
use std::io::Error as IoError; use mqtt_codec::error::{EncodeError, DecodeError}; #[derive(Debug)] pub enum MQTTClientError { NotAuthorized, ConnectionLost, MPSCError, TimeoutError, SomethingWentWrong, IoError(IoError), EncodeError(EncodeError), DecodeError(DecodeError) } impl From<IoError> for MQT...
// This file is part of Substrate. // Copyright (C) 2017-2020 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the F...
use regex::Regex; use std::env; use std::io::Read; use std::process::ExitCode; use reqwest::header::USER_AGENT; use serde::{Deserialize, Serialize}; use text_colorizer::*; #[derive(Serialize, Deserialize)] struct LocationProperties { forecast: String, } #[derive(Serialize, Deserialize)] struct LocationPayload { ...
use crate::ctx::ClientContext; use anyhow::Result; use js_sys::{ArrayBuffer, Uint8Array}; use rustimate_core::ResponseMessage; use std::rc::Rc; use std::sync::RwLock; use wasm_bindgen::prelude::{Closure, JsValue}; use wasm_bindgen::JsCast; use web_sys::{Blob, ErrorEvent, FileReader, MessageEvent}; pub(crate) fn on_op...
use std::collections::HashMap; use std::io::{self, BufRead}; use std::iter::repeat; fn solve(xs: &[usize], target: usize) -> usize { let mut next = 0; let mut map = HashMap::new(); for (i, x) in xs .iter() .map(Some) .chain(repeat(None)) .enumerate() .take(target - 1...
#[doc = "Register `L1BFCR` reader"] pub type R = crate::R<L1BFCR_SPEC>; #[doc = "Register `L1BFCR` writer"] pub type W = crate::W<L1BFCR_SPEC>; #[doc = "Field `BF2` reader - Blending Factor 2"] pub type BF2_R = crate::FieldReader; #[doc = "Field `BF2` writer - Blending Factor 2"] pub type BF2_W<'a, REG, const O: u8> = ...
pub struct Grad { pub x: f32, pub y: f32, pub z: f32, pub w: f32, } impl Grad { pub fn new(x: f32, y: f32, z: f32, w: f32) -> Grad { Grad { x: x, y: y, z: z, w: w, } } }
#[doc = "Reader of register CLK_TRIM_CCO_CTL2"] pub type R = crate::R<u32, super::CLK_TRIM_CCO_CTL2>; #[doc = "Writer for register CLK_TRIM_CCO_CTL2"] pub type W = crate::W<u32, super::CLK_TRIM_CCO_CTL2>; #[doc = "Register CLK_TRIM_CCO_CTL2 `reset()`'s with value 0x0088_4110"] impl crate::ResetValue for super::CLK_TRIM...
use crate::Dist; use std::vec::Vec; pub trait BkNode { type Key; fn key(&self) -> &Self::Key; fn has_child_at(&self, dist: Dist) -> bool; fn child_at(&self, dist: Dist) -> Option<&Self>; fn children_vector(&self) -> Vec<(Dist, &Self)>; // Needs RFC 1598: GATs: because the child is not copyabl...
use youchoose; fn main() { let mut menu = youchoose::Menu::new(0..100); let choice = menu.show(); // `choice` is a Vec<usize> containing the chosen indices println!("Index of the chosen item: {:?}", choice); }
/* * 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 */ /// UsageSnmpHour : The number of SNMP devices for each hour for a given organization. #[derive(Clone...
use std::sync::Arc; use async_process::{Command, Stdio}; use tracing::warn; use super::Config; const NOTIFY_SEND_PATH: &'static str = "/usr/bin/notify-send"; pub struct Notificator { config: Arc<Config>, desktop_notifications_possible: bool, } impl Notificator { pub fn new(config: Arc<Config>) -> Self ...
use super::nfa::CharacterSet; use super::rules::{Alias, Symbol, TokenSet}; use std::collections::BTreeMap; pub(crate) type ProductionInfoId = usize; pub(crate) type ParseStateId = usize; pub(crate) type LexStateId = usize; use std::hash::BuildHasherDefault; use indexmap::IndexMap; use rustc_hash::FxHasher; #[derive(...
use serde::Serialize; #[derive(Serialize, Debug)] #[serde(untagged)] pub enum Response { Error { success: bool, error: String }, Success { success: bool }, } impl Response { pub fn error(error: String) -> Response { Response::Error { success: false, error, } } ...
use ocl; use std::ffi::CString; use parenchyma::error::Result; use parenchyma::frameworks::OpenCLContext; /// Caches instances of `Kernel` #[derive(Debug)] pub struct OpenCLPackage { pub(in frameworks::open_cl) program: ocl::Program, } impl OpenCLPackage { pub fn compile(cx: &mut OpenCLContext<()>) -> Result<...
pub use codespan_derive_proc::IntoDiagnostic; pub use codespan_reporting::diagnostic::{Diagnostic, Label, LabelStyle}; pub trait IntoDiagnostic { type FileId; fn into_diagnostic(&self) -> Diagnostic<Self::FileId>; } pub trait IntoLabel { type FileId; fn into_label(&self, style: LabelStyle) -> Label<...
use serde::{Deserialize, Serialize}; use crate::models::multi_filter_format; use crate::request::{FilterOptions, ModelRequest, RequestDetails, RequestParameters}; use std::collections::HashMap; pub(crate) fn model_path( portal: impl std::fmt::Display, project: impl std::fmt::Display, ) -> String { format!...
use regex::Regex; use std::collections::HashMap; use std::collections::HashSet; use std::env; use std::fs; use std::process; #[macro_use] extern crate lazy_static; type Validate = fn(&str) -> bool; fn valid_year(year: &str, min: u32, max: u32) -> bool { if year.len() != 4 { return false; } match...
use anyhow::anyhow; use futures_locks::Mutex; use smol::Async; use std::fs::File; use utuntap::tun::OpenOptions; use yggy_core::{dev::*, interfaces::tun, types::MTU}; // const MAX_UDP_SIZE: usize = (1 << 16) - 1; /// /// TODO rename #[derive(Debug)] pub struct Socket { name: String, // mtu: MTU, file: Opt...
#[cfg(feature = "enable-log")] use std::env; #[cfg(feature = "enable-log")] use easy_log::EasyLogConfig; #[cfg(feature = "enable-log")] #[derive(Debug)] pub struct DemoDebugLogConfig { pub network_handler_enable_request_debug_log: bool, pub network_handler_enable_body_debug_log: bool, pub network_handler_...
pub type Result<T> = std::io::Result<T>; pub fn fd_count_cur() -> Result<usize> { let path = "/dev/fd"; let dir_entries = std::fs::read_dir(path)?; let count = dir_entries.count(); Ok(count) } #[cfg(test)] mod test { use super::*; // We put these test case in one test to make them get execute...
extern crate libinjection; use libinjection::{sqli, xss}; #[test] fn test_sqli() { let (is_sqli, fingerprint) = sqli("' OR '1'='1' --").unwrap(); assert!(is_sqli); assert_eq!("s&sos", fingerprint); let (is_sqli, fingerprint) = sqli("SELECT * FROM users").unwrap(); assert!(!is_sqli); assert!(f...
pub fn add_and_sub_fn(value_1 : i32 , value_2 : i32) { if value_1 > value_2 { println!("The sum of value_1 {} and value_2 {} is {}",value_1,value_2,(value_1 + value_2)); } //add value_1 to value_2 else { println!("The subtraction of value_1 {} from value_2 {} is {}",value_1,value_2,(value_1 - value_...
/* Copyright (c) 2016-2017, Robert Ou <rqou@robertou.com> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of condit...
use std::collections::HashMap; use async_graphql::dataloader::Loader; use async_graphql::FieldError; use itertools::Itertools; use sqlx::types::Uuid; use sqlx::{Pool, Postgres}; use IntoIterator; use crate::database::models::{Match, Player, Team}; /// Builds a list of UUIDs for use in a SQL query fn uuid_list(keys: ...
use log::Level::Debug; use crate::{ ContextHandle, DotId, Multiplicity, State, Goal, Semantics, FiringSet, FiringSequence, AcesError, }; #[derive(Clone, Default, Debug)] pub(crate) struct Props { pub(crate) semantics: Option<Semantics>, pub(crate) max_steps: Option<usize>, pub(crate) num_passes: ...
#![macro_use] #[cfg_attr(adc_v3, path = "v3.rs")] mod _version; #[allow(unused)] pub use _version::*; use crate::gpio::NoPin; use crate::peripherals; pub(crate) mod sealed { use crate::gpio::Pin; pub trait Instance { fn regs() -> &'static crate::pac::adc::Adc; fn common_regs() -> &'static c...
// TODO: check pattern coverage use super::{unify::InferenceTable, Type, *}; use crate::{ builtins::Builtin, diagnostic::Diagnostic, hir, hir::*, scopes::{Denotation, Scopes}, }; use arena::ArenaMap; use either::{Either, Either::*}; use std::ops::Index; pub fn infer(module: Module, scopes: Scopes)...
$NetBSD: patch-library_std_src_sys_unix_thread.rs,v 1.12 2023/04/08 18:18:11 he Exp $ Fix stack-clash on SunOS. --- library/std/src/sys/unix/thread.rs.orig 2020-10-07 07:53:22.000000000 +0000 +++ library/std/src/sys/unix/thread.rs @@ -752,7 +752,7 @@ pub mod guard { let page_size = os::page_size(); ...
// Definition for a binary tree node. #[derive(Debug, PartialEq, Eq)] pub struct TreeNode { pub val: i32, pub left: Option<Rc<RefCell<TreeNode>>>, pub right: Option<Rc<RefCell<TreeNode>>>, } impl TreeNode { #[inline] pub fn new(val: i32) -> Self { TreeNode { val, lef...
// The NXM link format is not part of the API specification. It was found through trial and error. use crate::api::ApiError; use std::str::FromStr; use std::time::{SystemTime, UNIX_EPOCH}; use url::Url; #[derive(Debug)] pub struct NxmUrl { pub url: Url, pub query: String, pub domain_name: String, // this ...
extern crate regex; use std::io; use regex::Regex; fn main() { let mut line = String::new(); io::stdin().read_line(&mut line) .expect("Illegal usage of this binary need one line on stdin!"); let arg = std::env::args().last().expect("Need a col as CL arg"); let col = usize::from_str_radix(&arg,...
#[doc = "Register `DTS_ITENR` reader"] pub type R = crate::R<DTS_ITENR_SPEC>; #[doc = "Register `DTS_ITENR` writer"] pub type W = crate::W<DTS_ITENR_SPEC>; #[doc = "Field `TS1_ITEEN` reader - TS1_ITEEN"] pub type TS1_ITEEN_R = crate::BitReader; #[doc = "Field `TS1_ITEEN` writer - TS1_ITEEN"] pub type TS1_ITEEN_W<'a, RE...
use pyo3::exceptions::PyRuntimeError; use pyo3::PyErr; use thiserror::Error; #[allow(unused)] pub type Result<T> = std::result::Result<T, ConnectorXPythonError>; /// Errors that can be raised from this library. #[derive(Error, Debug)] pub enum ConnectorXPythonError { /// The required type does not same as the sch...
use std::path::Path; use clap::{crate_authors, crate_description, crate_name, crate_version, App, AppSettings, Arg}; use lindera_core::dictionary_builder::DictionaryBuilder; use lindera_ko_dic_builder::KodicBuilder; fn main() { let app = App::new(crate_name!()) .setting(AppSettings::DeriveDisplayOrder) ...
use std::env::current_dir; use std::error::Error; use git2::Repository; use crate::model::*; mod state; use state::State; pub fn open() -> Result<(), Box<dyn Error>> { let repository = Repository::discover(current_dir()?)?; let config = repository.config()?.snapshot()?; let current_user = config.get_strin...
use SafeWrapper; use ir::{Constant, Type, User}; use sys; use std::ffi; /// A floating point constant. pub struct ConstantFP<'ctx>(Constant<'ctx>); impl_subtype!(ConstantFP => Constant); impl<'ctx> ConstantFP<'ctx> { /// Creates a new floating point constant from a string. pub fn new_string(ty: &Type, ...
use super::Control; use std::mem; use ui::UI; use ui_sys::{self, uiControl, uiProgressBar}; /// An enum representing the value of a `ProgressBar`. /// /// # Values /// /// A `ProgressBarValue` can be either `Determinate`, a number from 0 up to 100, or /// `Indeterminate`, representing a process that is still in progre...
pub(crate) struct Shebang<'line> { pub(crate) interpreter: &'line str, pub(crate) argument: Option<&'line str>, } impl<'line> Shebang<'line> { pub(crate) fn new(line: &'line str) -> Option<Shebang<'line>> { if !line.starts_with("#!") { return None; } let mut pieces = line[2..] .lines(...
use crate::docker::BenchmarkCommands; use crate::io::Logger; use curl::easy::{Handler, WriteError}; #[derive(Clone)] pub struct BenchmarkCommandListener { logger: Logger, pub error_message: Option<String>, pub benchmark_commands: Option<BenchmarkCommands>, } impl BenchmarkCommandListener { pub fn new(t...
/// Left pads a slice of bytes with preceding zeros such that the /// result is a 32 byte fixed array. /// /// # Panics /// Panics if the input sequence lenght is greater than 32. #[inline] pub fn left_pad_to_32_bytes(seq: &[u8]) -> [u8; 32] { assert!( seq.len() <= 32, "Input sequence length ({}) mu...
#[doc = "Reader of register RCC_MPCKSELR"] pub type R = crate::R<u32, super::RCC_MPCKSELR>; #[doc = "Writer for register RCC_MPCKSELR"] pub type W = crate::W<u32, super::RCC_MPCKSELR>; #[doc = "Register RCC_MPCKSELR `reset()`'s with value 0x8000_0000"] impl crate::ResetValue for super::RCC_MPCKSELR { type Type = u3...
extern crate boondock; use boondock::Docker; fn main() { let docker = Docker::connect_with_defaults().unwrap(); let images = docker.images(false).unwrap(); for image in &images { println!("{} -> Size: {}, Virtual Size: {}, Created: {}", image.Id, image.Size, image.VirtualSize, image.Created); } ...
/// Macro for sending a formatted string through an ITM channel #[macro_export] macro_rules! iprint { ($channel:expr, $s:expr) => { $crate::itm::write_str($channel, $s); }; ($channel:expr, $($arg:tt)*) => { $crate::itm::write_fmt($channel, format_args!($($arg)*)); }; } /// Macro for sen...
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #![feature(async_await)] #![deny(warnings)] use failure::{Error, ResultExt}; use fidl_fuchsia_hardware_power as hpower; use fidl_fuchsia_power as fpower; ...
use std::{error::Error, fmt}; #[derive(Debug)] pub struct CodegenError { details: String, } pub type CodegenResult<T> = Result<T, CodegenError>; impl CodegenError { pub fn new(details: &str) -> CodegenError { CodegenError { details: details.to_string(), } } } impl Error for C...
use regex::Regex; use std::fs::{File, read_dir}; use std::io::{BufRead, BufReader}; use std::path::{Path, PathBuf}; use std::thread; use chrono::{DateTime, FixedOffset}; use crate::analyze_result::AnalyzeResult; use crate::dbase::DBase; // use crate::config::DBConfig; // use mongodb::{ Document}; // use mongodb::{Clie...
//! Callbacks for the `Mouse` object in the Lua libraries use ::lua::Lua; use libc::c_int; #[allow(non_snake_case)] pub trait Mouse { /* Methods */ fn mouse___index(&self, lua: &Lua) -> c_int; fn mouse___newindex(&self, lua: &Lua) -> c_int; fn mouse_coords(&self, lua: &Lua) -> c_int; fn mouse_obje...
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * All rights reserved. * * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ use reverie::syscalls::Errno; use reverie::syscalls::MemoryAccess; use reverie::syscalls::Syscall; ...
use crate::types::Vector3; pub struct Light { pub position: Vector3, pub colour: Vector3, pub attenuation: Vector3 } impl Light { pub fn new(position: Vector3, colour: Vector3, attenuation: Vector3, brightness: f32) -> Light { Light { position, colour: (colour * brightness), attenuation } } }
// use crate::front_of_house::hosting; use std::collections::HashMap; use std::fmt; use std::io::Result as IoResult; use rand::Rng; // use std::{cmp::Ordering, io}; // use std::{self, Write}; // use std::collections::*; fn main() { let mut map = HashMap::new(); map.insert("a", 2); println!("map: {:?}", map); ...
use crate::MyApp; use seed::{*, prelude::*}; use crate::traits::component_trait::Component; use crate::messages::Msg; use super::header_component::HeaderComponent; use super::item_wrapper_component::ToDoContainerComponent; //The entire page pub struct HomePageComponent; impl Component<MyApp, Msg> for HomePageComponen...
extern crate rand; use rand::{thread_rng, Rng}; use std::{io, cmp}; use std::io::{Read, Write}; struct FrameBuffer { width: i32, height: i32, buffer: Vec<String> } impl FrameBuffer { pub fn new(width:i32, height:i32, fill: &str) -> FrameBuffer { // Creates a new FrameBuffer let mut n...
use js_sys::{ArrayBuffer, Error}; use wasm_bindgen::{JsCast, JsValue}; use wasm_bindgen_futures::JsFuture; pub mod glutil; pub mod sound; pub mod util; async fn load_buffer(source: &str) -> Result<ArrayBuffer, String> { let response: web_sys::Response = JsFuture::from(web_sys::window().unwrap().fetch_with...
use bitflags::bitflags; bitflags! { pub struct BlockStatus: u32 { const UNKNOWN = 0; const HEADER_VALID = 1; const BLOCK_RECEIVED = Self::HEADER_VALID.bits | 1 << 1; const BLOCK_STORED = Self::HEADER_VALID.bits | Self::...
// This file is part of dpdk. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/dpdk/master/COPYRIGHT. No part of dpdk, including this file, may be copied, modified, propagated, or distributed except accordin...
//! System calls related to process managment. use arch::context::{context_clone, context_switch, Context, ContextFile}; use arch::regs::Regs; use collections::{BTreeMap, Vec}; use collections::string::ToString; use core::{intrinsics, mem}; use core::ops::DerefMut; use system::{c_array_to_slice, c_string_to_str}; us...
mod boo_enum; mod eq_ord; mod to_owned; mod types; pub use {boo_enum::*, eq_ord::*, to_owned::*, types::*};
// Copyright 2018 Fredrik Portström <https://portstrom.com> // This is free software distributed under the terms specified in // the file LICENSE at the top-level directory of this distribution. macro_rules! unwrap { ($context:ident $node:ident $warning_message:ident $value:expr) => { match $value { ...
use crate::node::*; use crossbeam_epoch::{Atomic, Guard, Owned, Shared}; use std::fmt::Debug; use std::sync::atomic::Ordering; #[derive(Debug)] pub(crate) struct Table<K, V> { bins: Box<[Atomic<BinEntry<K, V>>]>, } impl<K, V> From<Vec<Atomic<BinEntry<K, V>>>> for Table<K, V> { fn from(bins: Vec<Atomic<BinEntr...
#![feature(test)] extern crate test; extern crate rand; extern crate nalgebra as na; use rand::{IsaacRng, Rng}; use test::Bencher; use na::{Vector2, Vector3, Vector4}; use std::ops::{Add, Sub, Mul, Div}; #[path="common/macros.rs"] mod macros; bench_binop!(_bench_vec2_add_v, Vector2<f32>, Vector2<f32>, add); bench_b...
/* Copyright 2019-2023 Didier Plaindoux 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...
pub mod show; pub mod semigroup; pub mod monoid; #[macro_use]pub mod hlist; pub mod validated;