text
stringlengths
8
4.13M
use crate::adapter::repository::user_dao::UserRepositoryBySQLite; use crate::usecase::user_creation::UserOperation; use crate::entity::user::UserID; use actix_web::{get, web, Responder}; #[get("/users/{id}")] pub async fn show(info: web::Path<i64>) -> impl Responder { let user_operation = UserOperation { ur: U...
use std::{ borrow::{Borrow, Cow}, collections::HashMap, hash::Hash, }; /// A HashMap like structure for accessing query parameters. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Query<'a>( HashMap< Cow<'a, str>, Cow<'a, str> > ); impl<'a> Query<'a> { pub fn new<Q>(query: Q) -> Query<'a> where Q: In...
fn main() { let mut build = cc::Build::new(); build.file("the_worst_support.cpp"); build.flag("-fexceptions"); build.cpp(true); build.compile("the_worst_support"); println!("cargo:rerun-if-env-changed=CC"); println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=th...
//! Memory bookkeeping. use prelude::*; use core::ops::Range; use core::{ptr, mem, ops}; use shim::config; /// Elements required _more_ than the length as capacity. /// /// This represents how many elements that are needed to conduct a `reserve` without the /// stack overflowing, plus one (representing the new elem...
use anyhow::{format_err, Error}; use async_google_apis_common as common; use common::{ yup_oauth2::{self, InstalledFlowAuthenticator}, DownloadResult, TlsClient, }; use crossbeam::atomic::AtomicCell; use futures::future::try_join_all; use itertools::Itertools; use lazy_static::lazy_static; use log::debug; use m...
use crate::primitive::{Quad, Sphere}; use glam::Vec3; use serde::Deserialize; use std::io::Read; #[derive(Debug, Deserialize)] pub struct Light { pub position: Vec3, pub diffuse: Vec3, pub specular: Vec3, } #[derive(Debug, Deserialize)] pub struct Scene { pub shininess: f32, pub antialias: u32, ...
use nom::branch::alt; use nom::bytes::complete::{tag, take_until}; use nom::character::complete::{digit0, space0}; use nom::character::is_alphabetic; use nom::sequence::tuple; use nom::{dbg_dmp, named, tag, take_while, IResult}; use std::collections::BTreeMap; use std::convert::TryInto; #[derive(Debug, PartialEq)] pub...
#[macro_use] extern crate validator_derive; extern crate dotenv; extern crate validator; use actix_web::{middleware, web, App, HttpServer}; use dotenv::dotenv; use postgres::NoTls; use r2d2_postgres::PostgresConnectionManager; use std::env; mod accounts; mod handler; mod auth; mod jwt; mod model; #[actix_rt::main] a...
#[doc = "Register `SR` reader"] pub type R = crate::R<SR_SPEC>; #[doc = "Register `SR` writer"] pub type W = crate::W<SR_SPEC>; #[doc = "Field `PE` reader - Parity error"] pub type PE_R = crate::BitReader; #[doc = "Field `FE` reader - Framing error"] pub type FE_R = crate::BitReader; #[doc = "Field `NE` reader - Noise ...
use crate::options::{self, BuildMode, BuildOptions, Sanitizer}; use crate::utils::default_target; use anyhow::{anyhow, bail, Context, Result}; use std::collections::HashSet; use std::io::Read; use std::io::Write; use std::path::{Path, PathBuf}; use std::{ env, ffi, fs, process::{Command, Stdio}, time, }; c...
use apllodb_storage_engine_interface::StorageEngine; use super::query::query_plan::query_plan_tree::query_plan_node::node_repo::QueryPlanNodeRepository; /// Context object each Processor/Executor has. /// A context object must be moved out after an SQL process. #[derive(Debug)] pub struct SqlProcessorContext<Engine: ...
#[doc = "Reader of register ANA_CTL0"] pub type R = crate::R<u32, super::ANA_CTL0>; #[doc = "Writer for register ANA_CTL0"] pub type W = crate::W<u32, super::ANA_CTL0>; #[doc = "Register ANA_CTL0 `reset()`'s with value 0x0400"] impl crate::ResetValue for super::ANA_CTL0 { type Type = u32; #[inline(always)] ...
use itertools::iproduct; use std::cmp::max; const SERIAL_NUMBER: i32 = 3613; fn get_power((x, y): (i32, i32)) -> i32 { let rack_id = x + 10; (rack_id * y + SERIAL_NUMBER) * rack_id / 100 % 10 - 5 } fn part1() { let (x, y) = iproduct!(1..299, 1..299) .max_by_key(|&(x, y)| iproduct!(x..x + 3, y..y ...
use crate::{ error::*, ffi::*, }; pub type gpio_num_t = u32; pub type gpio_int_type_t = u32; pub const gpio_int_type_t_GPIO_INTR_DISABLE: gpio_int_type_t = 0; pub const gpio_int_type_t_GPIO_INTR_POSEDGE: gpio_int_type_t = 1; pub const gpio_int_type_t_GPIO_INTR_NEGEDGE: gpio_int_type_t = 2; pub const gpio_int_...
use std::cell::RefCell; use std::rc::Rc; use crate::pager_manager::Pager_manager; use crate::{BTree, Attribute, DATATYPE, toDATATYPE, Page_info}; use crate::data_item::{Data_item, Data_item_info}; use anyhow::{Result, anyhow}; use std::borrow::{BorrowMut, Borrow}; use std::collections::HashMap; use std::ops::Deref; use...
use itertools::Itertools; static FILE: &str = include_str!("../inputs/5.txt"); lazy_static! { static ref SEAT_IDS: Vec<usize> = FILE .lines() .map(|s| { let mut row = 0..128; let mut col = 0..8; for c in s.chars() { match c { ...
// A disk will be how the file system interacts with the underlying file. A disk instance is created // when the file is mounted and will open the file for read/write. The file will stay opened through // the disk structure as long as the file system is mounted. The fields in the disk structure listed use serde_json::s...
#[doc = "Register `APB2RSTR` reader"] pub type R = crate::R<APB2RSTR_SPEC>; #[doc = "Register `APB2RSTR` writer"] pub type W = crate::W<APB2RSTR_SPEC>; #[doc = "Field `TIM1RST` reader - TIM1 reset"] pub type TIM1RST_R = crate::BitReader<TIM1RST_A>; #[doc = "TIM1 reset\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug,...
//! Type definitions for `<metal_common>`. use super::*; pub trait Common: Sized { // Called clamped instead of clamp because std has claimed // the name. fn clamped<U, V, R>(self, minval: U, maxval: V) -> R where Self: MinMax<U, R>, R: MinMax<V, R>, { self.max(minval).min(maxval) } fn mix<...
#![allow(non_snake_case)] #![allow(non_camel_case_types)] #![allow(unknown_lints)] #![allow(clippy::all)] pub mod core { pub mod cmp { pub enum Ordering { /// An ordering where a compared value is less than another. Less = -1, /// An ordering where a compared value is ...
#[doc = "Register `ETH_MACLMIR` reader"] pub type R = crate::R<ETH_MACLMIR_SPEC>; #[doc = "Register `ETH_MACLMIR` writer"] pub type W = crate::W<ETH_MACLMIR_SPEC>; #[doc = "Field `LSI` reader - LSI"] pub type LSI_R = crate::FieldReader; #[doc = "Field `LSI` writer - LSI"] pub type LSI_W<'a, REG, const O: u8> = crate::F...
use crate::{backend::SchemaBuilder, prepare::*, types::*, SchemaStatementBuilder}; /// Drop a table /// /// # Examples /// /// ``` /// use sea_query::{*, tests_cfg::*}; /// /// let table = Table::truncate() /// .table(Font::Table) /// .to_owned(); /// /// assert_eq!( /// table.to_string(MysqlQueryBuilder),...
use std::collections::HashMap; #[allow(dead_code)] fn read_line() -> String { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim_end().to_owned() } fn main() { let stdin = read_line(); let mut iter = stdin.split_whitespace(); let a = iter.next().unwrap().pa...
pub mod bump; // Bump allocator - the most simple. Has a counter that only goes up or down. When it is at 0, there are no allocations pub mod linked_list; // Linked list allocator, which keeps track of free spaces pub mod fixed_size_block; // Instead of the dynamic sizing of linked list, you have set sizes (Hence fixe...
use std::io; use rayon::prelude::*; use crate::base::Part; pub fn part1(r: &mut dyn io::Read) -> Result<String, String> { solve(r, Part::One) } pub fn part2(r: &mut dyn io::Read) -> Result<String, String> { solve(r, Part::Two) } fn solve(r: &mut dyn io::Read, part: Part) -> Result<String, String> { let...
// xfail-fast use std; import std::task; import std::comm; import std::uint; fn die() { fail; } fn iloop() { task::unsupervise(); let f = die; task::spawn(f); } fn main() { for each i in uint::range(0u, 100u) { let f = iloop; task::spawn(f); } }
use polars::chunked_array::ChunkedArray; use sqlx::{postgres::*, query}; use std::{env, i32}; use std::fmt::Error; use std::fs::File; use std::future::Future; use std::io::{self, BufRead}; use std::path::Path; use polars::prelude::{ChunkApply, CsvReader}; use polars::prelude::SerReader; use polars::prelude::Series; use...
extern crate futures; mod runtime; mod lifecycled; mod objectkey; mod provider;
use serde_json::json; pub trait SearchQuery { fn to_json(&self) -> serde_json::Value; } pub struct QueryStringQuery { query: String, } impl QueryStringQuery { pub fn new(query: String) -> Self { Self { query } } } impl SearchQuery for QueryStringQuery { fn to_json(&self) -> serde_json::V...
#[doc = "Register `MMC_CONTROL` reader"] pub type R = crate::R<MMC_CONTROL_SPEC>; #[doc = "Register `MMC_CONTROL` writer"] pub type W = crate::W<MMC_CONTROL_SPEC>; #[doc = "Field `CNTRST` reader - CNTRST"] pub type CNTRST_R = crate::BitReader; #[doc = "Field `CNTRST` writer - CNTRST"] pub type CNTRST_W<'a, REG, const O...
pub mod common; use std::cmp; use std::collections::HashMap; use std::error; use std::fmt; #[derive(Debug, Clone, PartialEq)] pub enum ErrorKind { Internal, Application, } impl ToString for ErrorKind { fn to_string(&self) -> String { match self { ErrorKind::Internal => "internal".to_o...
use std::env; use std::fs; use std::path::Path; fn main() { let target = env::var("TARGET").unwrap(); println!("target={}", target); if target.find("-windows-").is_some() { // do not build c-code on windows, use binaries let output_dir = env::var("OUT_DIR").unwrap(); let prebuilt_d...
use rand::Rng; use stream::{BackendBuilder, BackendStream}; use std::collections::HashMap; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::sync::Arc; use protocol::{Protocol, Resource}; unsafe impl<P> Send for Topology<P> {} unsafe impl<P> Sync for Topology<P> {} #[derive(Default)] pub...
/*! When working with data pipes it is often necessary to distinguish between EOF on the reader side caused by writer thread finishing write and writer panicking. This crate provides fused reader type that if writer thread dies while holding armed fuse the reader will get `BrokenPipe` error. Fuses can also be blown wi...
#![cfg_attr(docsrs, feature(doc_cfg))] #![doc = include_str!("../README.md")] use std::{ sync::{Mutex, MutexGuard, PoisonError, TryLockError}, thread::yield_now, }; /** * Lock several locks at once. Algorithms is taken from the gcc's libstdc++: * lock the first lock and try_lock the next one; if some one f...
fn main() -> std::io::Result<()> { let input = std::fs::read_to_string("examples/18/input.txt")?; use crate::Operator::*; use Token::*; let lines = input.lines().map(|line| { line.chars().filter_map(|ch| match ch { ' ' => None, '+' => Some(Operator(Add)), '*' ...
// Copyright © 2019 Bart Massey // [This program is licensed under the "MIT License"] // Please see the file LICENSE in the source // distribution of this software for license terms. // Workaround for `Vec::retain()` passing `&T` instead of // `&mut T`. See RFC #2160 and issue #25477 for discussion // of inclusion of ...
//! Transform contains a position, a rotation, and a size used by every shape in fumarole use crate::*; use math::*; use serde::{Serialize, Deserialize}; #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize)] pub struct Transform { pub position: Vec2<f32>, pub rotation: f32, pub size: Vec2<f32>, ...
//! [ECS](https://aws.amazon.com/ecs/) bindings for Rust //! //! To get started, see the docs for [ECSClient](struct.ECSClient.html) #![allow(non_snake_case)] use credentials::AWSCredentialsProvider; use regions::Region; use signature::SignedRequest; include!(concat!(env!("OUT_DIR"), "/ecs.rs")); include!(concat!(e...
//! Clipping Region //use crate::POLY_SUBPIXEL_SCALE; use crate::cell::RasterizerCell; /// Rectangle #[derive(Debug,Copy,Clone)] pub struct Rectangle<T: std::cmp::PartialOrd + Copy> { /// Minimum x value x1: T, /// Minimum y value y1: T, /// Maximum x value x2: T, /// Maximum y value y...
mod sc2000; use sc2000::*; use ini::Ini; use std::process::abort; fn main() { let mut h0 = String::new(); let file = Ini::load_from_file("input.ini").unwrap(); let mut input_name = String::new(); for (sec, prop) in file.iter() { for (k, v) in prop.iter() { match (sec, k) { ...
use crate::material::Material; use crate::ray::Ray; use crate::vec::{Point3, Vec3}; use std::ops::Range; use std::rc::Rc; pub struct HitRecord { pub point: Point3, pub normal: Vec3, pub t: f64, pub front_face: bool, pub material: Rc<dyn Material>, } impl HitRecord { pub fn new(point: Point3, ...
mod advanced_traits; mod advanced_fn_closure; fn main() { }
use crate::*; use thiserror::Error; #[derive(Debug, Error)] pub enum ImageError { #[error("Image decoding error: {0}")] Load(&'static str), #[error("Image encoding error: {0}")] Save(&'static str), #[error("Image packing error: {0}")] Packing(&'static str), #[error(transparent)] Common(#[from] CommonError)...
use clap::{Arg, App}; use rand::Rng; const CHECK_CODES: [i32; 8] = [7, 9, 5, 3, 2, 4, 6, 8]; fn get_digits(number: i32) -> Vec<i32> { let mut digits = Vec::new(); let mut n = number; while n > 9 { digits.push(n % 10); n = n / 10; } digits.push(n); digits } fn main() { l...
fn hex_to_byte(byte: u8) -> u8 { match byte { 48..=57 => byte - 48, 97..=102 => byte - 87, _ => 0, } } fn byte_to_hex(byte: u8) -> u8 { match byte { 0..=9 => byte + 48, 10..=15 => byte + 87, _ => 0, } } pub fn hex_value<T: AsRef<[u8]>>(input: T) -> Vec<u...
//! ITP1_8_Dの回答 //! [https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_D](https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_8_D) use std::io::BufRead; /// ITP1_8_Dの回答 #[allow(dead_code)] pub fn main() { loop { if let Some(dataset) = read_dataset(std::io::stdin().lock()) { ...
#[doc = "Register `PUCR` reader"] pub type R = crate::R<PUCR_SPEC>; #[doc = "Register `PUCR` writer"] pub type W = crate::W<PUCR_SPEC>; #[doc = "Field `URCL` reader - URCL"] pub type URCL_R = crate::BitReader; #[doc = "Field `URCL` writer - URCL"] pub type URCL_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>; #[...
// Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of Substrate. // Substrate is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any la...
#[doc = "Reader of register TR_CTRL2"] pub type R = crate::R<u32, super::TR_CTRL2>; #[doc = "Writer for register TR_CTRL2"] pub type W = crate::W<u32, super::TR_CTRL2>; #[doc = "Register TR_CTRL2 `reset()`'s with value 0x3f"] impl crate::ResetValue for super::TR_CTRL2 { type Type = u32; #[inline(always)] fn...
use anyhow::Result; use confy::load; use console::Term; use protonvpn::{cli::CliOptions, constants::APP_NAME, main as main_cli, vpn::util::Config}; #[paw::main] fn main(args: CliOptions) -> Result<()> { // Stdio handle is passed through the entire program let mut terminal = Term::buffered_stdout(); let config = lo...
//! Replaces the game's broken cheats system with our own system that integrates with the menu. use std::sync::atomic::{AtomicBool, Ordering}; use crate::{ call_original, gui, hook, menu::{self, RowData, TabData}, settings::Settings, }; use lazy_static::lazy_static; use log::error; use once_cell::sync::La...
use std::{ env, fmt::Write, io::Cursor, thread, time::{Duration, Instant}, }; use futures::StreamExt; use image::io::Reader as ImageReader; use inline_python::{python, Context}; use serde::Deserialize; use telegram_bot::{ prelude::*, reply_markup, Api, CanSendMessage, MessageKind, ParseMode, Up...
use glium::glutin::{self, event::{ElementState, VirtualKeyCode, Event, WindowEvent}, platform::unix::WindowExtUnix}; use glium::{Display, Surface}; use imgui::{Context, FontConfig, FontGlyphRanges, FontSource, Ui}; use imgui_glium_renderer::Renderer; use imgui_winit_support::{HiDpiMode, WinitPlatform}; use std::time::I...
use crate::io::TwzIOHdr; use crate::io::{PollStates, ReadFlags, ReadOutput, ReadResult, WriteFlags, WriteOutput, WriteResult}; use std::sync::atomic::{AtomicU32, Ordering}; use twz::event::{Event, EventHdr}; use twz::mutex::TwzMutex; pub const BSTREAM_METAEXT_TAG: u64 = 0x00000000bbbbbbbb; #[repr(C)] #[derive(Default...
//! VapourSynth cores. use std::ffi::{CStr, CString, NulError}; use std::fmt; use std::marker::PhantomData; use std::ptr::NonNull; use vapoursynth_sys as ffi; use crate::api::API; use crate::format::{ColorFamily, Format, FormatID, SampleType}; use crate::map::OwnedMap; use crate::plugin::Plugin; /// Contains informa...
use apllodb_immutable_schema_engine_infra::test_support::sqlite_database_cleaner::SqliteDatabaseCleaner; use apllodb_server::ApllodbServer; use apllodb_shared_components::{DatabaseName, Session}; use super::{session_with_db, Step, Steps}; #[derive(Debug, Default)] pub struct SqlTest { server: ApllodbServer, s...
use nostalgia::{Key, Record}; use nostalgia_derive::Storable; use serde::{Deserialize, Serialize}; #[derive(Storable, Serialize, Deserialize)] #[key = "id"] struct Thing { id: u32, } fn main() {}
pub mod p0001; pub mod p0002; pub mod p0003; pub mod p0004; pub mod p0005; pub mod p0006; pub mod primes;
#![deny(warnings)] #[macro_use] extern crate serde_derive; extern crate futures; extern crate hyper; extern crate hyper_rustls; extern crate rustls; extern crate tls_client; extern crate tokio_core; extern crate serde_json; use futures::future; use futures::Stream; use hyper::rt::Future; use hyper::{Body, Request, U...
// This file is part of rdma-core. 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/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ...
use crate::{ define_node_command, get_set_swap, scene::commands::{Command, SceneContext}, }; use rg3d::{ core::{color::Color, pool::Handle}, resource::texture::Texture, scene::{graph::Graph, node::Node}, }; define_node_command!(SetSpriteSizeCommand("Set Sprite Size", f32) where fn swap(self, node) ...
//! The index holds all the data presented to the gui, and all read operations are directed here. //! Whenever something changes in the repository, the change is reflected in the index. use notify::{ RecommendedWatcher, Watcher, RecursiveMode }; use std::path::Path; use std::time::Duration; use std::sync::mpsc::channe...
use ansi_colors::*; fn main(){ let mut str1 = ColouredStr::new("string1sdaasdsdasda\nsdasdasdasd\nadasds"); str1.green(); str1.bold(); str1.back_black(); println!("{}",str1); }
use super::Pattern; pub fn is_life_106_file<S: AsRef<str>>(s: &S) -> bool { s.as_ref().starts_with("#Life 1.06") } pub fn parse_life_106_file<S: AsRef<str>>(s: &S) -> Result<Pattern, String> { let s = s.as_ref(); // Skip first line, because it is the header. let lines = s.lines().skip(1); let mu...
use bitflags::bitflags; use crate::uses::*; use crate::mem::VirtRange; #[derive(Debug)] pub struct Section<'a> { pub virt_range: VirtRange, pub data: Option<&'a [u8]>, // data virtual offset from start of virt_range pub data_offset: usize, pub flags: PHdrFlags, } #[derive(Debug)] pub struct ElfParser<'a> { dat...
extern crate slow_primes; pub fn factor(input: usize) -> [usize; 20] { let mut number: usize = input as usize; let prime_list = &slow_primes::Primes::sieve(number as usize); let mut divisors: [_; 20] = [0; 20]; let mut n = 0; if slow_primes::is_prime_miller_rabin(number as u64) == false { for p in prime_list.p...
use std::boxed::Box; use std::io::BufReader; use std::fs::File; use std::path::PathBuf; use std::collections::HashMap; use std::io::Read; use std::io::Cursor; use rodio::Device; use rodio::Sink; use rodio::Source; #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] pub enum Sound { TapMuted, Holst, } lazy_sta...
use std::ops::Deref; use std::thread; use crossbeam::queue::ArrayQueue; use reqwest::header::{HeaderMap, HeaderName, HeaderValue, USER_AGENT}; use serde_json::{Map, Value}; use crate::alpaca::account::APCA_SECRET_KEY; use crate::alpaca::account::{Account, APCA_API_KEY}; use crate::alpaca::positions::{Portfolio, Posi...
//! Sync your Org with your favorite applications. //! //! > This project is still in *alpha stage*. Don't forget to backup your //! > orgmode files before trying! //! //! # Installation //! //! ```text //! $ cargo install orgize-sync //! ``` //! //! # Subcommand //! //! ## `init` //! //! Initializes a new configuratio...
use super::preludes::*; use std::cell::RefCell; use std::rc::Rc; use crate::evaluator::objects; use vm::bytecode; pub const MAX_FRAMES: usize = 1024; #[derive(Clone, Debug, Default, PartialEq)] pub struct Frame { pub cl: objects::Closure, pub pointer: usize, pub base_pointer: usize, } impl Frame { ...
use serde::{Deserialize, Serialize}; use common::event::EventPublisher; use common::result::Result; use crate::domain::author::{AuthorId, AuthorRepository}; use crate::domain::category::{CategoryId, CategoryRepository}; use crate::domain::collection::{Collection, CollectionRepository}; use crate::domain::publication:...
pub mod drive; pub mod dumper; pub mod intake; pub mod digital_monitor; pub trait SubsystemFactory<T>: ToString { fn produce(self: Box<Self>) -> T; }
extern crate debug; enum List<T> { Cons(T, Box<List<T>>), Nil } impl<T: PartialEq> PartialEq for List<T> { fn eq(&self, ys: &List<T>) -> bool { match (self, ys) { (&Nil, &Nil) => true, (&Cons(ref x, box ref xs_tail), &Cons(ref y, box ref ys_tail)) if x == y => xs_tail == ys_tail, ...
use std::collections::HashMap; pub struct SymbolTable { map: HashMap<String, usize>, } impl SymbolTable { pub fn new() -> SymbolTable { Self { map: HashMap::new(), } } pub fn add_entry(&mut self, symbol: String, address: usize) { self.map.insert(symbol, address); ...
use std::collections::{HashMap, HashSet}; use super::prelude::*; /// Phase for voting on a mission proposal pub struct Voting { /// Map from players to whether they up- or down-voted the proposal. votes: HashMap<String, bool>, /// Whether or not the voting results are obscured obscured: bool, } impl ...
use std::vec::IntoIter; use std::iter::IntoIterator; use std::collections::VecDeque; #[derive( Clone )] pub struct BufferedPeekable<T> { iter: IntoIter<T>, buf: VecDeque<T>, } impl<T> BufferedPeekable<T> { pub fn new( v: Vec<T> ) -> BufferedPeekable<T> { BufferedPeekable { iter: v.into...
use dtn::system; use clap::Clap; use log::{debug}; #[derive(Debug)] #[derive(Clap)] struct Opts { // #[clap(short = "e", long = "eid", help = "Local EID (ex: dtn://example.com")] // local_eid: String, // #[clap(long = "stcp", help = "Enable STCP listener ")] // stcp_enable: bool, // #[clap(long =...
// Copyright 2019 The xi-editor Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or ag...
use std::os::raw::c_char; use crate::error::{check_status, Error, ErrorKind}; /// Initial number of bytes to allocate when copying a string out of a string vector const INITIAL_SIZE: usize = 128; /// Maximum number of bytes to allocate when copying a string out of a string vector const MAX_SIZE: usize = 1024 * 1024; ...
#[doc = "Register `DDRCTRL_HWLPCTL` reader"] pub type R = crate::R<DDRCTRL_HWLPCTL_SPEC>; #[doc = "Register `DDRCTRL_HWLPCTL` writer"] pub type W = crate::W<DDRCTRL_HWLPCTL_SPEC>; #[doc = "Field `HW_LP_EN` reader - HW_LP_EN"] pub type HW_LP_EN_R = crate::BitReader; #[doc = "Field `HW_LP_EN` writer - HW_LP_EN"] pub type...
//! The RFC 959 Print Working Directory (`PWD`) command // // This command causes the name of the current working // directory to be returned in the reply. use crate::{ auth::UserDetail, server::controlchan::{ error::ControlChanError, handler::{CommandContext, CommandHandler}, Reply, Re...
extern crate pest; #[macro_use] extern crate pest_derive; mod parser { use {Entity, Attribute, Relationship, Cardinality}; use pest; use pest::Parser; #[cfg(debug_assertions)] const _GRAMMAR : &'static str = include_str!("grammar.pest"); #[derive(Parser)] #[grammar = "grammar.pest"] s...
use crate::{InterfaceIpAddr, InterfaceIpv4, InterfaceIpv6}; pub(crate) fn np_ipv4_to_nmstate( np_iface: &nispor::Iface, ) -> Option<InterfaceIpv4> { if let Some(np_ip) = &np_iface.ipv4 { let mut ip = InterfaceIpv4::default(); if !np_ip.addresses.is_empty() { ip.enabled = true; ...
#[cfg(feature = "async_mode")] use curl::easy::{Easy2, Handler, WriteError}; #[cfg(feature = "async_mode")] use crate::error::ReturnError; // TESTED #[cfg(feature = "async_mode")] struct Collector(Vec<u8>); #[cfg(feature = "async_mode")] impl Handler for Collector { fn write(&mut self, data: &[u8]) -> Result<us...
#![allow(dead_code)] extern crate rsnl; extern crate rsgnl; fn main() { let mut nls = rsnl::socket::alloc().unwrap(); let p = rsgnl::socket::connect(&mut nls); let s= "nl80211"; let family = rsgnl::controller::resolve(&nls, s); println!("Family Index: {}", family); // connect the socket to...
use crate::codegen::AatbeModule; use llvm_sys_wrapper::{LLVMBasicBlockRef, LLVMValueRef}; pub fn branch(module: &AatbeModule, block: LLVMBasicBlockRef) -> LLVMValueRef { module.llvm_builder_ref().build_br(block) } pub fn cond_branch( module: &AatbeModule, cond: LLVMValueRef, then_block: LLVMBasicBlock...
#[doc = "Register `D3PCR2H` reader"] pub type R = crate::R<D3PCR2H_SPEC>; #[doc = "Register `D3PCR2H` writer"] pub type W = crate::W<D3PCR2H_SPEC>; #[doc = "Field `PCS48` reader - Pending request clear input signal selection on Event input x= truncate ((n+96)/2)"] pub type PCS48_R = crate::FieldReader<PCS48_A>; #[doc =...
extern crate rusthub; extern crate rustc_serialize; use std::fs::File; use std::path::Path; use std::io::Read; use rusthub::oauth; use rustc_serialize::json; #[test] #[ignore] fn create_authorization() { let auth = oauth::AuthBody { scopes: vec!["notifications".to_string()], note: "gh-notify".to_st...
#![crate_type = "lib"] extern crate i3ipc; pub mod focuswatcher; pub mod sockethandler;
use crate::vec3::Vec3; use crate::ray::Ray; use std::f64::consts::PI; use crate::sphere::random_in_unit_disk; pub struct Camera { origin: Vec3, lower_left_corner: Vec3, horizontal: Vec3, vertical: Vec3, w: Vec3, u: Vec3, v: Vec3, lens_radius: f32 } impl Camera { pub fn new(lookfrom...
use std::fmt::Display; use std::iter::{self, FromIterator}; pub fn pre_format<T>(i: T, len: usize, prefix: char) -> String where T: Display, { let s = i.to_string(); if s.len() >= len { s } else { let pre = iter::repeat(prefix).take(len - s.len()); format!("{}{}", String::from_i...
// q0187_repeated_dna_sequences struct Solution; use std::collections::HashMap; impl Solution { pub fn find_repeated_dna_sequences(s: String) -> Vec<String> { let l = s.len(); if l <= 10 { return vec![]; } let mut map = HashMap::new(); for i in 0..=l - 10 { ...
mod metadata; pub use self::metadata::*;
#[macro_use] extern crate nom; use nom::line_ending; use nom::types::CompleteByteSlice; use Dir::{ U, D, R, L }; const INPUT: &'static str = include_str!("day2.txt"); #[derive(Debug)] enum Dir { U, D, R, L } named!(match_up<CompleteByteSlice, Dir>, map!(char!('U'), |_| U)); named!(match_down<CompleteByteSlice, Dir...
#![deny(missing_docs)] #![cfg_attr(test, deny(warnings))] #![cfg_attr(test, feature(core))] //! # lazylist //! //! A lazy, reference counted linked list similar to Haskell's []. #[macro_use(lazy)] extern crate lazy; use lazy::single::Thunk; use std::rc::Rc; use std::iter::FromIterator; #[macro_export] macro_rules!...
fn main() { let greeting = String::from("Hallo, ich bin Alexander!"); /* Variants Type => i8, u8 Option => 8, 16, 32, 64, 128 Two more thing -> The upper/lower limit still applies like C. -> The val of 'isize' is dpding on ur PC'...
//! Builders for customizing asynchronous Metric Sinks. use tokio::time::Duration; use crate::{DEFAULT_BATCH_BUF_SIZE, DEFAULT_MAX_BATCH_DELAY, DEFAULT_QUEUE_CAPACITY}; /// Builder allows you to override various default parameter values before creating an instance /// of the desired Metric Sink. #[derive(Debug)] pub...
use crate::{ gui::{make_dropdown_list_option, BuildContext, Ui, UiMessage, UiNode}, scene::commands::{ mesh::{ SetMeshCastShadowsCommand, SetMeshDecalLayerIndexCommand, SetMeshRenderPathCommand, }, SceneCommand, }, send_sync_message, sidebar::{ make_bool_i...
use std::{collections::{HashMap, hash_map::Entry}, rc::Rc}; use rand::{distributions::WeightedIndex, prelude::Distribution}; use crate::{abstractions::CustomDistribution}; use crate::algorithm::algorithm::GenHash; use crate::abstractions::FitFunc; use std::hash::Hash; // use crate::Chromosome; // #[derive(Clone, C...