text
stringlengths
8
4.13M
// Copyright 2020 Datafuse Labs. // // 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 ...
use std::sync::Arc; use crate::prelude::*; use crate::light::Light; use crate::math::*; use crate::primitive::Primitive; use crate::interaction::SurfaceInteraction; pub struct Scene { pub lights: Vec<Arc<dyn Light + Send + Sync>>, aggregate: Arc<dyn Primitive + Send + Sync>, world_bound: Bounds3<Float>, } ...
use std::sync::{Arc, Mutex}; use std::time::Duration; use crate::traits::Policy; use std::ops::DerefMut; pub struct RetryPolicy<'l, R> { pub(in crate) matchers: Vec<Arc<dyn Fn(&R) -> bool + 'l>>, pub(in crate) action: Arc<Mutex<dyn FnMut(R, usize) -> () + 'l>>, pub(in crate) durations: Vec<Duration>, } i...
use std::process; use std::sync::{Arc, RwLock}; use gtk::*; use super::{ Header, Content, ConnectedApp, open::open, save::save, equalize_histogram::equalize_histogram }; use image::Image; pub struct App { pub window: Window, pub header: Header, pub content: Content } impl App { pub fn new() -> App { ...
// We comment on Rust like in JavaScript /* * This also works, exactly like JavaScript. */ /// First Exercise of the Rust by Example Book! fn main() { println!("Hello World!"); println!("I'm a Rustacean!"); }
// Copyright (c) Meta Platforms, Inc. and affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use std::path::PathBuf; use std::sync::Arc; use anyhow::Result; use datastore::ChangesStore; use datastore::DeltaStore; use datastore...
use crate::{routes, Config}; use artell_usecase::system::check_scheduler::system_update_scheduler; use chrono::{Timelike, Utc}; use futures::{future, StreamExt}; use std::net::SocketAddr; use tokio::time::{interval_at, Duration, Instant, Interval}; use warp::Filter; pub async fn bind(config: Config, socket: impl Into<...
extern crate rustc_serialize; use self::rustc_serialize::hex::FromHex; use self::rustc_serialize::base64::{ToBase64, STANDARD, Config}; #[allow(dead_code)] // debugging pub fn pretty_print(string: Vec<u8>) -> String { match String::from_utf8(string) { Ok(v) => { v } Err(_) => { "UNPRINTABLE".to_st...
use std::fmt::Write; use crate::{ custom_client::OsekaiUserEntry, embeds::Footer, util::{constants::OSU_BASE, numbers::round, CowUtils}, }; pub struct MedalCountEmbed { description: String, footer: Footer, title: &'static str, url: &'static str, } impl MedalCountEmbed { pub fn new( ...
// Any code not in main() is moved here use std::error::Error; use std::fs; /* Using a struct helps to convey meaning that the two values are related it also makes it easier for others to read the code later case sensitivity is trigger by T/F - run() will need to check for this */ pub struct Config { pub query: S...
#![allow(unused_imports)] pub use flatbuffers; include!(concat!(env!("OUT_DIR"), "/mod.rs"));
use std::sync::Arc; use datafusion::{ arrow::util::pretty::pretty_format_batches, datasource::TableProvider, prelude::{ExecutionConfig, ExecutionContext}, }; fn make_ctx() -> ExecutionContext { // hardcode 1 thread to avoid consuming all CPUs on system which // both overheats my laptop causing pow...
extern crate ares; #[macro_use] mod util; #[test] fn test_and() { eval_ok!("(and)", true); eval_ok!("(and true)", true); eval_ok!("(and false)", false); eval_ok!("(and true false)", false); eval_ok!("(and true true)", true); eval_ok!("(and true true false)", false); } #[test] fn test_or() { ...
extern crate rsmath as r; #[cfg(test)] mod tests { use r::algebra::matrix::*; use r::algebra::vector::*; // --------------- Matrix TEST ---------------------------------------- #[test] fn matrix_init_test() { let values: Vec<Vec<i32>> = vec![vec![1, 2], vec![3, 4]]; let m = Matrix...
macro_rules! gost94_impl { ($state:ident, $sbox:expr) => { use $crate::gost94::{Gost94, SBox, Block}; use generic_array::typenum::U32; use digest; use generic_array::GenericArray; #[derive(Clone, Copy)] pub struct $state { sh: Gost94 } impl $state { pub fn new() ->...
extern crate clap; extern crate config; extern crate tinytemplate; mod cli; use std::error::Error; #[tokio::main] pub async fn main() -> Result<(), Box<dyn Error>> { cli::execute().await }
/// This enum defines the currently displayed modal. #[derive(PartialEq, Eq, Clone, Copy, Debug)] pub enum MyModal { /// Quit modal. Quit, /// Clear all modal. ClearAll, /// Connection details modal. ConnectionDetails(usize), }
use hyper::Method; use lib::models::*; use stq_static_resources::Currency; use stq_types::*; use stq_http::client::{self, ClientHandle as HttpClientHandle}; static MOCK_COMPANIES_PACKAGES_ENDPOINT: &'static str = "companies_packages"; fn create_companies_packages( company_id: CompanyId, package_id: PackageI...
use crate::bimap::BiMap; use crate::conn::{self, ConnEvent, DateTime}; use log::error; use std::sync::mpsc::SyncSender; use futures::{Future, Stream}; pub struct DiscordConn { token: String, guild_name: String, guild_id: discord::Snowflake, channel_ids: BiMap<String, discord::Snowflake>, last_mess...
use core::config::Configuration; use core::net::{self,TcpWriter}; use core::errors::MomoError; use core::parser::IrcMessage; use core::threads; use core::types::NoResult; // Synchronization primitives use std::thread; use chan; type THandle = thread::JoinHandle<()>; pub struct Momo { config: Configuration, ...
use opengl_graphics::Texture; use opengl_graphics::TextureSettings; use rayon::prelude::*; lazy_static! { pub static ref MARS: Texture = Texture::from_path(find_folder::Search::ParentsThenKids(3, 3).for_folder("images").unwrap().join("mars.png"), &TextureSettings::new()).unwrap(); }
use crate::schema::refresh_tokens; use compat_uuid::Uuid; use diesel::{ self, delete, insert_into, prelude::*, result::Error, update, Associations, FromSqlRow, Identifiable, Insertable, Queryable, }; use postgres_resource::*; #[resource(schema = refresh_tokens, table = "refresh_tokens")] struct RefreshToken {...
use validaten::crypto; fn main() { println!("1GiWxH6PzSSmbdcK72XfGpqhjSb6nae6h9 => {:?}", crypto::which_cryptocurrency("1GiWxH6PzSSmbdcK72XfGpqhjSb6nae6h9")); println!("qppjlghjlwg6tgxv7ffhvs43rlul0kpp4c0shk4dr6 => {:?}", crypto::which_cryptocurrency("qppjlghjlwg6tgxv7ffhvs43rlul0kpp4c0shk4dr6")); println!...
use std::collections::{HashMap, HashSet}; use std::fmt; use crate::object; use crate::ArcDataSlice; use crate::hlc; use crate::network; use crate::store; use crate::encoding; pub mod applyer; pub mod checker; pub mod driver; pub mod locker; pub mod messages; pub mod requirements; pub mod tx; pub use requirements::{T...
use std::sync::MutexGuard; use nia_interpreter_core::Interpreter; use nia_interpreter_core::NiaInterpreterCommand; use nia_interpreter_core::NiaInterpreterCommandResult; use nia_interpreter_core::{EventLoopHandle, NiaDefineModifierCommandResult}; use crate::error::{NiaServerError, NiaServerResult}; use crate::protoc...
use crate::{ db_conn, schema::{self, dialogs}, DirtyTransaction, Error, Transaction, }; use common::{ chrono::{DateTime, Utc}, rsip::{self, prelude::*}, uuid::Uuid, }; use diesel::{ deserialize::FromSql, pg::Pg, prelude::*, serialize::{Output, ToSql}, sql_types::Text, }; use ...
#![feature(str_split_once)] use anyhow::{anyhow, Result}; use reqwest::header::{AUTHORIZATION, USER_AGENT}; use serde::de::{DeserializeOwned, Deserializer}; use serde::Deserialize; use std::collections::{BTreeMap, BTreeSet}; fn main() -> Result<()> { println!( "# Libs Meeting {} ###### tags: `Libs Meetin...
use std::thread; fn main() { let th1 = thread::spawn(move || { loop { println!("Hello"); } }); let th2 = thread::spawn(move || loop { println!("World"); }); th1.join().expect("The th1 thread has panicked"); th2.join().expect("The th2 thread has panicked"); }...
use super::super::super::icon; use super::Msg; use crate::{block::chat::item::Icon, resource::Data, Resource}; use kagura::prelude::*; pub fn chat_icon(attrs: Attributes, icon: &Icon, alt: &str, resource: &Resource) -> Html { match icon { Icon::None => icon::none(attrs), Icon::Resource(r_id) => { ...
#[cfg(test)] mod tests; use std::marker::PhantomData; use serde::{Deserialize, Deserializer}; use serde::de::{DeserializeSeed, MapAccess, SeqAccess, Visitor}; use crate::track::Duration; #[derive(Debug, Clone, PartialEq, Eq, Hash, Deserialize)] pub struct Entry { pub id: Box<str>, pub url: Box<str>, // This is ...
mod global; pub mod metadata; pub use global::*; pub(crate) use metadata::is_alloced_by_malloc;
use crate::listnode::*; pub fn swap_pairs(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> { let mut dummy = Box::new(ListNode::new(0)); dummy.next = head; let mut p = dummy.as_mut(); fn core(p: &mut ListNode) { match p.next.as_ref() { None => {}, Some(n1) => { ...
#[doc = "Register `SUBGHZSPICR` reader"] pub type R = crate::R<SUBGHZSPICR_SPEC>; #[doc = "Register `SUBGHZSPICR` writer"] pub type W = crate::W<SUBGHZSPICR_SPEC>; #[doc = "Field `NSS` reader - sub-GHz SPI NSS control"] pub type NSS_R = crate::BitReader<NSS_A>; #[doc = "sub-GHz SPI NSS control\n\nValue on reset: 1"] #[...
//! Deserialization support for the `application/x-www-form-urlencoded` format. use form_urlencoded::parse; use form_urlencoded::Parse as UrlEncodedParse; use serde::de::value::MapDeserializer; use serde::de::Error as de_Error; use serde::de::{self, IntoDeserializer}; use serde::forward_to_deserialize_any; use std::bo...
pub mod regions { pub fn process_command() { loop { println!("Please input an army command or help to see available commands or back to go back!"); let mut input = String::new(); std::io::stdin() .read_line(&mut input) .expect("Error parsi...
use ndarray::prelude::*; use ndarray_stats::QuantileExt; use crate::neuron::{losses::Loss, networks::Network}; pub trait Optimizer { /// Get optimizer Loss fn get_loss(&self) -> &Loss; /// Optimize the network on batch fn optimize_batch( &self, network: &mut Network, batch_inp...
pub mod ping_result_processor; mod ping_result_processor_console_logger; mod ping_result_processor_csv_logger; pub mod ping_result_processor_factory; mod ping_result_processor_json_logger; mod ping_result_processor_latency_bucket_logger; mod ping_result_processor_latency_scatter_logger; mod ping_result_processor_result...
use vcf::population::Population; use vcf::predictor::{Predictor, PredictorFactory, PredictorJoaoFactory}; use vcf::stream::MetadataReader; use utils::{process_variant, split}; use itertools::Itertools; use std::collections::HashMap; fn predict<S, PF>(mut stream: S, population: &Population, ratio: f32, factory: PF, m...
use std::{ collections::HashMap, future::Future, io, pin::Pin, process::exit, sync::{Arc, Weak}, task::{Context, Poll}, time::{Duration, SystemTime, UNIX_EPOCH}, }; use byteorder::{BigEndian, ByteOrder}; use bytes::Bytes; use futures_core::TryStream; use futures_util::{future, ready, St...
pub mod iterm;
use std::cell::RefCell; use std::env; use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::rc::Rc; mod environment; mod execute; mod object; mod parser; mod scanner; #[cfg(test)] mod test; mod value; use crate::environment::Environment; use crate::execute::execute_node; use crate::parser::Parse...
// Javascript object style struct Point { x: f64, y: f64 } struct Line { start: Point, end: Point } fn structures() { let p = Point {x: 3.2, y:4.3}; println!("point at ({}, {})", p.x, p.y); } enum Color { Red, Green, Blue, RGBColor(u8, u8, u8), // tuple Cmyk{cyan:u8, magenta:u8,...
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CQPAUSE { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w m...
use jsonwebtoken::{decode, decode_header, Algorithm, DecodingKey, TokenData, Validation}; use serde::{Deserialize, Serialize}; use crate::config::CONFIG; use crate::jwks::FIREBASE_JWKS; #[derive(Debug, Serialize, Deserialize)] pub struct Claims { pub aud: String, pub exp: usize, pub iat: usize, pub is...
#[cfg(test)] mod tests { use lib::get_sum_numbers_combinations_for_amount; #[test] fn tests_get_sum_numbers_combinations_for_amount() { let allowed_numbers: [u8; 4] = [1, 2, 4, 5]; let amount: u32 = 5; assert_eq!( get_sum_numbers_combinations_for_amount( ...
#[doc = "Register `AHB2SMENR` reader"] pub type R = crate::R<AHB2SMENR_SPEC>; #[doc = "Register `AHB2SMENR` writer"] pub type W = crate::W<AHB2SMENR_SPEC>; #[doc = "Field `GPIOASMEN` reader - IO port A clocks enable during Sleep and Stop modes"] pub type GPIOASMEN_R = crate::BitReader<GPIOASMEN_A>; #[doc = "IO port A c...
#[doc = "Register `SRCR` reader"] pub type R = crate::R<SRCR_SPEC>; #[doc = "Register `SRCR` writer"] pub type W = crate::W<SRCR_SPEC>; #[doc = "Field `IMR` reader - Immediate Reload"] pub type IMR_R = crate::BitReader<IMR_A>; #[doc = "Immediate Reload\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq, Eq)]...
table! { datasets (id) { id -> Int4, seed -> Int8, gmm -> Array<Jsonb>, } }
extern crate rusty_flow; extern crate image; use std::path::Path; use std::fs::File; const DETAIL: u32 = 10; fn main() { let buffer = rusty_flow::diamond_square::construct(DETAIL); let buffer = rusty_flow::diamond_square::normalize_pixel_map(buffer); let image_size: u32 = buffer.size(); let mut img_b...
use std::io::prelude::*; use std::io::BufReader; use std::fs::File; extern crate tle; #[test] fn norad100() { let f = File::open("tests/visual-100-brightest-2018-01-13.txt").unwrap(); let mut reader = BufReader::new(f); let mut contents = String::new(); reader.read_to_string(&mut contents).unwrap(); ...
use abin::{AnyBin, BinFactory, NewBin, NewStr, Str, StrFactory}; #[test] fn slice() { let str1 = NewStr::from_static("Some text."); assert_eq!( "Some text.".get(5..9).unwrap(), str1.slice(5..9).unwrap().as_str() ); let str2 = NewStr::from_static("Warning: Don't open the door!"); as...
fn main() { c1_visibility(); println!(); c2_struct_visibility(); println!(); c3_use(); println!(); c4_super_self(); } mod c1_my { // Items in modules default to private visibility fn private_function() { println!("called c1_my::private_function()"); } // Use the `pu...
#[doc = "Reader of register CLK_ADC_SELECTED"] pub type R = crate::R<u32, super::CLK_ADC_SELECTED>; impl R {}
use crate::color::{color, Color}; use crate::texture::{perlin::Perlin, Texture, TextureColor}; use crate::vec::Vec3; // MarbleTexture #[derive(Debug, Clone)] pub struct MarbleTexture { pub noise: Perlin, pub scale: f64, } impl MarbleTexture { pub fn new(seed: u64, scale: f64) -> Texture { Texture:...
use std::collections::HashMap; fn main() { ///////////////////////// // CHAPTER 8 EXERCISES // ///////////////////////// /////////////////// // integer stats // /////////////////// // tests assert_eq!(mean(&vec![1, 2, 3]), 2.0); assert_eq!(median(&mut vec![1, 2, 3]), 2); asse...
/*! [![GitHub CI Status](https://github.com/LPGhatguy/nonmax/workflows/CI/badge.svg)](https://github.com/LPGhatguy/nonmax/actions) [![nonmax on crates.io](https://img.shields.io/crates/v/nonmax.svg)](https://crates.io/crates/nonmax) [![nonmax docs](https://img.shields.io/badge/docs-docs.rs-orange.svg)](https://docs.rs/...
#[doc = "Register `SYSCFG_CFGR1` reader"] pub type R = crate::R<SYSCFG_CFGR1_SPEC>; #[doc = "Register `SYSCFG_CFGR1` writer"] pub type W = crate::W<SYSCFG_CFGR1_SPEC>; #[doc = "Field `MEM_MODE` reader - Memory mapping selection bits This bitfield controlled by software selects the memory internally mapped at the addres...
use macroquad::prelude::*; use na::{Vector2}; use std::process::exit; use crate::fiz::Fiz; // use crate::thing::lines; use crate::thing::make_cube; use crate::thing::make_cuboid; // use crate::thing::transform; use crate::thing::make_grid_xy; pub struct Game { pub fiz: Fiz, } impl Game { pub fn new() -> Game { ...
// actual size of the window const SCREEN_WIDTH: i32 = 80; const SCREEN_HEIGHT: i32 = 50; // size of the map //thore: map_start für die statusanzeige hinzugefügt const MAP_WIDTH: i32 = 80; const MAP_HEIGHT: i32 = 50; const MAP_START_HEIGHT: i32 = 0; const ROOM_MAX_SIZE: i32 = 10; const ROOM_MIN_SIZE: i32 = 6; const MA...
#[doc = "Register `MMCTIMR` reader"] pub type R = crate::R<MMCTIMR_SPEC>; #[doc = "Register `MMCTIMR` writer"] pub type W = crate::W<MMCTIMR_SPEC>; #[doc = "Field `TGFSCM` reader - Transmitted good frames single collision mask"] pub type TGFSCM_R = crate::BitReader<TGFSCM_A>; #[doc = "Transmitted good frames single col...
use std::fs::File; use std::io::{BufRead, BufReader}; use std::collections::HashMap; fn orbit_count(orbits: &HashMap<String, Vec<String>>, object: &str, current: u32) -> u32 { current + match orbits.get(object) { Some(orbiting_objects) => orbiting_objects.iter().map(|x| orbit_count(orbits, x, current + 1))...
//! A helper module which contains functionality to run feasibility checks on solution. use vrp_pragmatic::checker::CheckerContext; use vrp_pragmatic::format::problem::{deserialize_matrix, deserialize_problem, PragmaticProblem}; use vrp_pragmatic::format::solution::deserialize_solution; use std::io::{BufReader, Read}...
use crate::{alphabet::Alphabet, nfa::NFA, range_set::Range, state::State}; use core::cmp::Ordering; use hashbrown::HashSet; use valis_ds::set::{Set, VectorSet}; // this variant of an NFA does not have any epsilon transitions #[derive(Debug, PartialEq, Eq, Clone)] pub struct StandardNFA<A: Alphabet, I: State> { // ...
use std::collections::{VecDeque, HashSet}; use crate::days::day22::{parse_input, default_input}; pub fn run() { println!("{}", combat_str(default_input()).unwrap()) } pub fn combat_str(input : &str) -> Result<i64, ()> { let (p1, p2) = parse_input(input); combat(p1, p2) } pub fn combat(mut p1: VecDeque<i6...
#![allow(dead_code)] use library::doc::DocType::*; use library::lexeme::definition::TokenType::*; use library::lexeme::definition::{TokenKind, TokenType}; use library::lexeme::token::Token; use library::parser::helper::*; use library::parser::rust_type::*; #[derive(Debug)] struct SymbolTable { symbol_type: TokenT...
// The noise channels produced white noise and was generally used for the // percussions of the songs use serde::{Deserialize, Serialize}; use super::LENGTH_TABLE; /// Table of the different timer periods const TIMER_TABLE: [u16; 16] = [ 4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 4068, ...
use ai::constants::AI_DTOR; use ai::vector::AtVector; #[repr(C)] #[derive(Copy, Clone)] pub struct AtMatrix { pub data: [[f32; 4]; 4], } pub const AI_M4_IDENTITY: AtMatrix = AtMatrix { data: [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]], }; pub const AI_M4_ZERO: AtMa...
#[doc = "Reader of register RCC_MCO2CFGR"] pub type R = crate::R<u32, super::RCC_MCO2CFGR>; #[doc = "Writer for register RCC_MCO2CFGR"] pub type W = crate::W<u32, super::RCC_MCO2CFGR>; #[doc = "Register RCC_MCO2CFGR `reset()`'s with value 0"] impl crate::ResetValue for super::RCC_MCO2CFGR { type Type = u32; #[i...
#![deny(unsafe_code)] #![no_std] #![no_main] extern crate cortex_m; extern crate cortex_m_rt; extern crate cortex_m_semihosting; extern crate panic_halt; extern crate stm32l4xx_hal; use crate::cortex_m_rt::entry; use crate::stm32l4xx_hal::delay::Delay; use crate::stm32l4xx_hal::prelude::*; use crate::cortex_m_semiho...
error_chain! { foreign_links { Bson(::bson::ValueAccessError); Bcrypt(::bcrypt::BcryptError); Jwt(::jwt::Error); } errors { NoCredentialsMatch } }
use serde::de; use crate::de::{Deserializer, Error, Result}; pub(crate) struct SeqAccess<'a, 'b> { first: bool, de: &'a mut Deserializer<'b>, } impl<'a, 'b> SeqAccess<'a, 'b> { pub fn new(de: &'a mut Deserializer<'b>) -> Self { SeqAccess { de, first: true } } } impl<'a, 'de> de::SeqAccess<'d...
use serde::Deserialize; use crate::models::media::{MediaBase, MediaConnection, MediaEdge}; use crate::models::{AniListID, MediaType}; use crate::utils::{media_base_to_legend, na_long_str, synopsis}; const MAX_RELATED_MEDIA_ENTRIES: usize = 10; #[derive(Clone, Debug, Deserialize)] pub struct CharacterConnection { ...
use std::collections::hash_map::DefaultHasher; use std::hash::{Hash, Hasher}; // !! Entry represents an entry in database. #[derive(Clone)] pub struct Entry { pub link: String, pub author: Option<u64>, } impl Hash for Entry { fn hash<H: Hasher>(&self, state: &mut H) { self.link.hash(state); }...
use tests_build::tokio; #[tokio::main] async fn missing_semicolon_or_return_type() { Ok(()) } #[tokio::main] async fn missing_return_type() { /* TODO(taiki-e): one of help messages still wrong help: consider using a semicolon here | 16 | return Ok(());; | */ return Ok(()); } ...
// =============================================================================== // 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 js_sys::Error; use serde::{Deserialize, Deserializer, Serialize, Serializer}; /// Tracks mutable access to a value using a dirty flag. /// /// The dirty flag is asserted whenever this type's `DerefMut` impl is /// invoked and can be reset to `false` via the `Dirty::clean` method. /// /// Values are initially dirty...
use std::ops; #[derive(Debug, PartialEq, Copy)] pub struct Vec3(pub f64, pub f64, pub f64); impl Vec3 { pub fn x(&self) -> f64 { self.0 } pub fn y(&self) -> f64 { self.1 } pub fn z(&self) -> f64 { self.2 } pub fn r(&self) -> f64 { self.0 } pub fn g(&...
use super::super::{ program::TableGridProgram, webgl::{WebGlF32Vbo, WebGlI16Ibo}, ModelMatrix, }; use super::WebGlRenderingContext; use crate::block; use ndarray::Array2; pub struct MeasureRenderer { vertexis_buffer: WebGlF32Vbo, index_buffer: WebGlI16Ibo, table_grid_program: TableGridProgram, ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - interrupt status register"] pub isr: ISR, #[doc = "0x04 - interrupt flag clear register"] pub ifcr: IFCR, #[doc = "0x08 - channel x configuration register"] pub ccr1: CCR1, #[doc = "0x0c - channel x number of da...
use futures::{Async, Future, Poll}; use super::{FilterBase, Filter}; #[derive(Clone, Copy, Debug)] pub struct Unit<T> { pub(super) filter: T, } impl<T> FilterBase for Unit<T> where T: Filter<Extract=((),)>, { type Extract = (); type Error = T::Error; type Future = UnitFuture<T>; #[inline] ...
use super::{callbacks, controls, ids}; use std::collections::HashMap; use std::fmt; use std::marker::PhantomData; use serde::de::{self, Deserialize, Deserializer, MapAccess, Visitor}; use typemap::{Key, TypeMap}; pub type MemberType = String; pub type MemberSpawner = fn() -> Box<dyn controls::Control>; struct Callb...
mod common; use cached::cached; use proptest::prelude::*; use valis_automata::nfa::{ standard_eps::{NFABuilder, StandardEpsilonNFA}, NFA, }; cached! { ALTERNATING; fn alternating_language() -> StandardEpsilonNFA<bool, u8> = { let mut builder = NFABuilder::new((0..=4).into()); builder ...
extern crate statrs; use statrs::function::erf::erf; use std::f64::consts::PI; #[derive(Copy, Clone)] pub enum OptionType { Call, Put, } pub struct NormalDistribution { mean: f64, std_dev: f64, } impl NormalDistribution { fn pdf(&self, value: f64) -> f64 { (-(value - self.mean).powi(2) /...
use std::io; use std::io::prelude::*; fn find_primes(primes: &mut Vec<i32>) { primes.retain(|&x| x > 1); let mut i = 2; while i < *primes.last().unwrap() { primes.retain(|&x| x == i || x % i != 0); i = *primes.iter().find(|&x| *x > i).unwrap(); } } fn main() { let mut input = St...
use std::{io, net::ToSocketAddrs}; use tokio::net::TcpStream; use url::Url; use crate::proxytunnel; pub async fn connect(host: &str, port: u16, proxy: Option<&Url>) -> io::Result<TcpStream> { let socket = if let Some(proxy_url) = proxy { info!("Using proxy \"{}\"", proxy_url); let socket_addr = ...
mod values; mod scalar; mod index; pub use self::values::{Array, Object, Value}; pub use self::index::Index; pub use self::scalar::{Date, Scalar};
// error-pattern:put in non-iterator fn f() -> int { put 10; } fn main() { }
use clap::ArgMatches; use config::Config; use std::error::Error; pub fn setup(app_m: &ArgMatches) -> Result<config::Config, Box<dyn Error>> { let mut config = Config::default(); config .set_default("debug", false)? .set_default("log_level", "info")? .set_default("database_url", "feedspo...
use std::env; fn main() { let args: Vec<String> = env::args().collect(); if args.len() <= 1 { eprintln!("Error: No brainfuck file specified."); std::process::exit(1); } match brainfuck_interpreter::run(&args[1][..]) { Ok(()) => (), Err(e) => eprintln!("Error: {}", e), ...
//! This crate allows you to display progress bar in a terminal. //! //! # Example //! //! ``` //! use progress_bar::progress_bar::ProgressBar; //! use progress_bar::color::{Color, Style}; //! use std::{thread, time}; //! //! // if you have 81 pages to load //! let mut progress_bar = ProgressBar::new(81); //! progre...
pub mod buffer; pub mod camera; pub mod camera_controller; pub mod instance; pub mod state; pub mod texture; pub mod tracing; pub mod uniforms;
use crate::ast::*; use proc_macro2::TokenStream; use quote::quote; pub fn gen(input: Input<'_>) -> TokenStream { match input { Input::Struct(input) => gen_input(input), } } fn gen_input(input: Struct<'_>) -> TokenStream { let struct_name = &input.ident; let status = input.status(); let int...
use crate::peer_info::{protocol, PeerInfo}; use futures::future::BoxFuture; use futures::prelude::*; use libp2p::core::upgrade::ReadyUpgrade; use libp2p::swarm::handler::{ ConnectionEvent, DialUpgradeError, FullyNegotiatedInbound, FullyNegotiatedOutbound, ListenUpgradeError, StreamUpgradeError as ConnectionHand...
use materials::Material; use patterns::pattern_at_shape; use shapes::Shape; use tuples::Tuple; #[derive(Copy, Clone, Debug, PartialEq)] pub struct PointLight { pub position: Tuple, pub intensity: Tuple, } impl PointLight { pub fn new(position: Tuple, intensity: Tuple) -> Self { PointLight { ...
use paris::{info, success, warn}; use std::io; use rand::prelude::*; fn main() { let mut correct_number = reset(); loop { let mut number = String::new(); info!("Guess a number:"); io::stdin().read_line(&mut number).unwrap(); println!("{}", number); let parsed_number = n...
#[doc = "Register `GICH_VTR` reader"] pub type R = crate::R<GICH_VTR_SPEC>; #[doc = "Field `LISTREGS` reader - LISTREGS"] pub type LISTREGS_R = crate::FieldReader; #[doc = "Field `PREBITS` reader - PREBITS"] pub type PREBITS_R = crate::FieldReader; #[doc = "Field `PRIBITS` reader - PRIBITS"] pub type PRIBITS_R = crate:...
use std::io; use structopt::StructOpt; extern crate guitar_pedal; #[derive(Debug, StructOpt)] struct Opt { #[structopt(short, long, default_value = "80")] bpm: usize, } fn main() { let opt = Opt::from_args(); let (playback_manager, loop_manager, interface) = guitar_pedal::init(opt.bpm); loop_man...
pub mod actrl { pub mod disfold { pub fn get() -> u32 { unsafe { (core::ptr::read_volatile(0xE000E008u32 as *const u32) >> 2) & 0x1 } } pub fn set(val: u32) { unsafe { let mut reg = core::ptr::read_volatile(0xE000E008u32 as...
//! Handles edge cases that have caused trouble at times. use anyhow::Result; use ndarray::{array, Array2}; use ndarray_glm::{Logistic, ModelBuilder}; use num_traits::float::FloatCore; /// Ensure that a valid likelihood is returned when the initial guess is the /// best one. #[test] fn start_zero() -> Result<()> { ...
// 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...