text
stringlengths
8
4.13M
use std::fmt::{Display, Error as FmtError, Formatter}; ///Kind of library and its version. #[derive(Debug, Clone)] pub enum LibraryVersion { PCap(String), WPCap(String), PFRing(String), } impl Display for LibraryVersion { fn fmt(&self, f: &mut Formatter) -> Result<(), FmtError> { match self { ...
//! Functionality specific to Centos, RHEL, Amazon Linux, and other related distros. use spurs::{cmd, SshCommand}; /// Install the given .rpm packages via `rpm`. Requires `sudo` priveleges. pub fn rpm_install(pkg: &str) -> SshCommand { cmd!("sudo rpm -ivh {}", pkg) } /// Install the given list of packages via `y...
use anyhow::Result; use super::super::config::{Options, StackConfig}; use super::super::git::{apply_patches as git_apply_patches, enter_detached}; use super::super::series::*; fn process_stack(base_path: &std::path::Path, stack_config: &StackConfig) -> Result<()> { let mut src_dir = base_path.to_path_buf(); l...
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #![allow(non_camel_case_types)] pub use cssparser::RGBA; macro_rules! define_css_keyword_enum { ($name: iden...
use clap::ArgMatches; use serde::Deserialize; use std::fs; #[derive(Debug, Deserialize)] pub struct Config { pub brokers: String, } impl Config { pub fn new(args: &ArgMatches) -> Config { let file_path = args.value_of("config-file").unwrap(); let content = fs::read_to_string(file_path).expect(...
pub static FOLDER_DISALLOWEDS: &[&str; 2] = &[ "JPG", "." ]; pub static IMAGE_QUALITY: u8 = 82; pub static IMAGE_RESIZE_PERCENTAGE: f32 = 50.0; pub static IMAGE_RESIZE_FILTER: image::FilterType = image::CatmullRom; pub static IMAGE_ADJUST_BRIGHTNESS: i32 = -2; pub static RECOMPRESS: bool = true; pub static RECOMPRE...
#[allow(unused_imports)] use serde_json::Value; #[derive(Debug, Serialize, Deserialize)] pub struct HardwareStopItem { /// The nodepool ID or name on which to stop the upgrade. #[serde(rename = "node_pool")] pub node_pool: String, /// Argument to indicate whether the nodepool should split into upgraded...
use clap::{App, Arg}; use std::process; #[macro_use] extern crate lazy_static; mod jwt; fn main() { let matches = App::new("jwtinfo") .version("0.1.0") .about("Shows information about a JWT token") .arg( Arg::with_name("token") .help("the JWT token as a string"...
/* Copyright 2019 Supercomputing Systems AG 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...
extern crate xrb; use xrb::XClient; use xrb::models::*; use settings::Settings; use tiling::{Tiled, TiledDirection, TiledChild}; use std::process::Command; pub struct WindowManager { client: XClient, workspaces: Vec<Workspace>, current_workspace: usize, gc: GraphicsContext, settings: Settings, ...
//! Implement num-traits traits. use crate::{ibig::IBig, parse::ParseError, sign::Abs, ubig::UBig}; impl num_traits::Zero for UBig { fn zero() -> Self { Self::from(0u8) } fn is_zero(&self) -> bool { *self == Self::from(0u8) } } impl num_traits::Zero for IBig { fn zero() -> Self {...
pub mod ipfs { use std::path::Path; use std::process::{Stdio, Command}; use std::ffi::OsStr; use std::io::{Read, Write}; pub fn ipfs_hash<T: AsRef<[u8]>>(filecont: T) -> String { let mut process = Command::new("ipfs") .arg("add") ....
ApBegin(RS,CLSID_EMAPP) WndBegin(EMAPP_WND_MAINLIST) WdgBegin(CLSID_VTMMENU, MainListVtm) VtmCreateMenuRC(IMG_NULL_ID,TXT_LTL_N_NO_TITLE,WDG_MENU_TYPE_NUMERIC,WDG_MENU_ITEM_TYPE_IMAGE_TEXT,WDG_MENU_CHECK_STYLE_NONE,0,0,0) WdgEnd(CLSID_VTMMENU,MainListVtm) WndEnd(EMAPP_WND_MAINLIST) WndBe...
use std::iter; use std::fmt::Debug; #[derive(Debug)] pub struct CircularBuffer<T> { data: Vec<T>, cap: usize, len: usize, lo: usize, hi: usize, } #[derive(Debug,PartialEq)] pub enum Error { EmptyBuffer, FullBuffer, } impl<T: PartialEq + Default + Clone + Debug> CircularBuffer<T> { pu...
use eyre::{Result, WrapErr}; use structopt::StructOpt; use yup_oauth2::{ noninteractive::NoninteractiveTokens, InstalledFlowAuthenticator, InstalledFlowReturnMethod, }; #[derive(Debug, StructOpt)] #[structopt(name = "get-token", about = "Get token for the given scopes")] struct Opt { #[structopt(short = "c", l...
use super::{Drawable, Modul}; #[derive(Default)] pub struct WindowSettings {} impl Drawable for WindowSettings { fn draw(&mut self, egui_ctx: &egui::Context, modul: &mut Modul) { egui::Window::new("Settings").show(egui_ctx, |ui| { ui.label("Settings"); }); } }
/** * [127] Word Ladder * * A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every adjacent pair of words differs by a single letter. Every si for 1 <= i <= k is in wordList. Note that beginWord does not ...
use pimoroni_fanshim::Fanshim; use std::error::Error; use structopt::StructOpt; use env_logger; use log::debug; #[derive(StructOpt, Debug)] #[structopt(name = "Status of the led")] enum Switch { Off, On { #[structopt(long, help = "brightness, from 0 to 31")] br: u8, #[structopt(short,...
use crate::game::base::Color; use crate::game::board::Board; use crate::game::square::Square; pub mod exhausive; pub mod naive; pub mod nega_scout; pub use exhausive::Exhausive; pub use naive::Naive; pub use nega_scout::NegaScout; pub trait Strategy { fn next_move(&self, board: Board, color: Color) -> Option<Squ...
use std::path::{Path, PathBuf}; /// Returns /tmp/hh_server or equivalent path /// The algorithm for determining this is fixed and common to all hack executables. /// This does no validation of the environment var, nor of UTF8-safety of tmpdir. fn hh_tmp_dir() -> PathBuf { match std::env::var("HH_TMPDIR") { ...
extern crate libflate; use crate::{SobolParams, ParamDimension}; use std::io::{BufRead, BufReader, Cursor}; use libflate::gzip::Decoder; pub struct JoeKuoD6 { pub dim_params: Vec<JoeKuoD6Dim>, pub max_dims: usize } impl JoeKuoD6 { /** * Load parameter values supporting up to 1000 dimensions ...
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
use std::{fs::File, path::Path, time::Instant}; use ark_ec::pairing::Pairing; use ark_ff::Field; use ark_groth16::VerifyingKey; use ark_relations::r1cs::{ConstraintSynthesizer, ConstraintSystem, OptimizationGoal}; use ark_serialize::CanonicalDeserialize; use nimiq_zkp_circuits::{ circuits::{mnt4, mnt6}, setup:...
use std::io; use std::io::BufRead; pub fn main() { let stdin = io::stdin(); // Vector of stdin lines let mut lines: Vec<String> = stdin.lock().lines().map(|el| el.unwrap()).collect(); lines.remove(0); // First input is useless to me while lines.len() > 0 { // While there are more test cases let length = lines[...
//! Iterators types and traits. mod abstract_mut; mod into_abstract; mod into_iter; #[allow(clippy::module_inception)] mod iter; mod mixed; #[cfg(feature = "parallel")] mod par_iter; #[cfg(feature = "parallel")] mod par_mixed; #[cfg(feature = "parallel")] mod par_tight; mod tight; mod with_id; pub use abstract_mut::A...
//! frontend/rest/services/browser.rs //! //! Launches the user's web browser on request from the frontend. use crate::frontend::rest::services::Future as InternalFuture; use crate::frontend::rest::services::{Request, Response, WebService}; use crate::logging::LoggingErrors; use futures::{Future, Stream}; use hyper::h...
use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; // The output is wrapped in a Result to allow matching on errors // Returns an Iterator to the Reader of the lines of the file. fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> where P: AsRef<Path>, { let file = File:...
#![allow(dead_code)] #[cfg(feature = "frontend")] pub(crate) const CF_WORKER_BACKEND: &str = "http://localhost:8787/api"; pub(crate) const RECAPTCHA_SECRET: &str = include_str!("../../RECAPTCHA_SECRET");
use libc::{c_char, c_int, c_void, uintptr_t}; use std::mem::{transmute, size_of}; use super::*; // c macros pub unsafe fn jl_astaggedvalue(value: *mut jl_value_t) -> *mut jl_taggedvalue_t { let newv: *mut c_char = transmute(value); let ptr = newv.wrapping_offset(-(size_of::<jl_taggedvalue_t>() as isize)); ...
use std::io; use misc::misc::chat::ChatComponent; use protocol_internal::{ProtocolSupportDecoder, ProtocolSupportEncoder, ProtocolVersionEnum}; use uuid::Uuid; use crate::packet; #[derive(Debug, protocol_derive::ProtocolSupport)] #[packet(0x00)] #[packet_size(max = 17)] pub struct LoginStart { #[protocol_field(r...
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.a...
//! Bayer image definitions. use std::io::Read; use byteorder::{BigEndian,LittleEndian,ReadBytesExt}; use ::BayerResult; /// The 2x2 colour filter array (CFA) pattern. /// /// The sequence of R, G, B describe the colours of the top-left, /// top-right, bottom-left, and bottom-right pixels in the 2x2 block, /// in th...
// This file is part of Substrate. // Copyright (C) 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 Free Softwa...
use kreida::*; use crate::effects::Effect; #[derive(Default)] pub struct Sinusoid1 {} impl Effect for Sinusoid1 { fn update(&mut self, buffer: &mut Buffer<'_>, phi: f64) { let bar = ToolBox::default().pixel_bar(); let h_2 = buffer.height() / 2; let h_3 = buffer.height() / 5; let ...
use crate::state::{Entity, State}; use crate::events::{BuildHandler, Event, EventHandler}; use crate::widgets::{Dropdown, DropdownEvent, Item, Textbox, TextboxEvent}; use crate::state::style::*; #[derive(Clone)] pub struct LengthBox { pub value: Entity, pub unit: Entity, pub pixels: f32, pub percent...
mod counts; mod data; mod decomposer; mod shanten; use shanten::decompose_min_shanten; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub fn decompose_from_counts(counts: &[u8], meld: i32) -> JsValue { let results = decompose_min_shanten(counts, meld); serde_wasm_bindgen::to_value(&results).unwrap_or(JsValue::...
#[doc = "Register `STAT0` reader"] pub struct R(crate::R<STAT0_SPEC>); impl core::ops::Deref for R { type Target = crate::R<STAT0_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<STAT0_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<STA...
// Copyright (c) 2012 Leonhard Gruenschloss (leonhard@gruenschloss.org) // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights to /...
import std::io::reader; import std::io::reader_util; import std::{sort, io}; import math3d::*; import float::{fmax, fmin}; type mesh = { vertices: [vec3], indices: [uint], normals: [vec3] }; type model = { mesh: mesh, kd_tree: kd_tree }; fn find_split_plane( distances: [float], indices: [uint], faces: [uint] ) -> fl...
///! Contains a mutation operator based on ruin and recreate principle. use super::*; use crate::utils::parallel_into_collect; /// A mutation operator based on ruin and recreate principle. pub struct RuinAndRecreate { /// A ruin method. ruin: Box<dyn Ruin + Send + Sync>, /// A recreate method. recreate...
// MIT License // // Copyright (c) 2018 Visly Inc. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, ...
use crate::decode::Decode; use crate::encode::{Encode, IsNull}; use crate::error::BoxDynError; use crate::types::array_compatible; use crate::types::Type; use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueRef, Postgres}; use std::borrow::Cow; impl Type<Postgres> for str { fn type_info() -> PgTypeInf...
use regex::Regex; #[allow(dead_code)] pub fn day2(input : &String) -> () { println!("Part1: {}", day2_1(&input)); println!("Part2: {}", day2_2(&input)); } #[allow(dead_code)] pub fn day2_1(input : &String) -> i64 { let mut pos = 0; let mut depth = 0; let reg = Regex::new(r"(\w+) (\d+)").unwrap(); for line in...
use core::{ marker::PhantomData, mem, ptr, }; use std::collections::BTreeMap; use crate::{ MEGABYTE, Arch, MemoryArea, PageEntry, PhysicalAddress, VirtualAddress, arch::x86_64::X8664Arch, }; #[derive(Clone, Copy)] pub struct EmulateArch; impl Arch for EmulateArch { const P...
//! assembling events from matrix use crate::{BareEvent, Error}; use ndarray::{Array2, Axis}; /// A single line as a byte sequence. pub type Event = BareEvent; pub struct Input { data_channel: Option<crossbeam_channel::Sender<Event>>, ack_channel: crossbeam_channel::Receiver<super::SeqNo>, data: Array2<V...
use tcod::Color; #[derive(Clone, Copy, Debug)] pub struct Palette { pub dark_wall: Color, pub light_wall: Color, pub dark_ground: Color, pub light_ground: Color, }
use crate::architecture::arm::{ ap::{AccessPort, MemoryAp}, memory::adi_v5_memory_interface::ArmProbe, ApAddress, }; use crate::{ architecture::arm::{communication_interface::Initialized, ArmCommunicationInterface}, error, }; use anyhow::anyhow; use anyhow::Result; /// An interface to be implement...
use std::collections::HashMap; // A variation of kahn's topological sort. // Instead of removing edges this function decreases counter of incoming edges for each node. // Advantages: // - graph is immutable and can be used later // Disadvantages: // - space overhead for one HashMap // - sort initial sources vect...
use proc_macro2::TokenStream as TokenStream2; use quote::quote; use rtfm_syntax::{ast::App, Context}; use crate::{ analyze::Analysis, codegen::{locals, module, resources_struct}, }; pub fn codegen( app: &App, analysis: &Analysis, ) -> ( // const_app_idle Vec<TokenStream2>, // mod_idle ...
extern crate amethyst; use amethyst::{ assets::Processor, core::{transform::TransformBundle, frame_limiter::FrameRateLimitStrategy}, input::{InputBundle, StringBindings}, prelude::*, renderer::{sprite::SpriteSheet, types::DefaultBackend, RenderingSystem}, ui::{DrawUiDesc, UiBundle}, utils::...
use super::verify_checksum; use crate::error::{Error, Result}; use byteorder::{ByteOrder, NativeEndian}; use core::fmt; use core::ops::Range; use core::slice; use core::str; /// Offsets from `ACPI § 5.2.6` mod offsets { use super::*; /// Well known bytes, "RST PTR ". pub const SIGNATURE: Range<usize> = 0.....
//! The [`Merge`] struct, which provides a merge-join based implementation of //! [`Join`]. use std::cmp::Ordering; use std::iter::Peekable; use crate::tuple::{CloneTuple, FieldSet, HasFieldSet, OrdTuple, Tuple, TuplePool}; use super::product::Product; use super::Join; /// A [`Join`] implementation that uses a [`Me...
// 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 ...
extern crate bytes; extern crate futures; extern crate tokio_core; extern crate tokio_io; extern crate tokio_proto; extern crate tokio_service; use std::io; use std::io::{Read, Write}; use std::net::{SocketAddr, TcpListener}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; use bytes::BytesMut; ...
mod animator; mod components; mod keyboard; mod physics; mod renderer; use crate::components::*; use sdl2::event::Event; use sdl2::image::{self, InitFlag, LoadTexture}; use sdl2::keyboard::Keycode; use sdl2::pixels::Color; use sdl2::rect::Point; use sdl2::rect::Rect; use specs::prelude::*; use std::time::Duration; pu...
use std::fmt; use serde::{Deserialize, Serialize}; use tantivy::query::{Query, TermQuery}; use tantivy::schema::{IndexRecordOption, Schema}; use crate::query::*; use crate::Result; /// An exact term to search for #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ExactTerm { term: KeyValue<String, String...
#[warn(dead_code)] pub struct RecentCounter { pub array: Vec<i32>, } ///Binary-Search /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ #[allow(dead_code)] impl RecentCounter { #[warn(dead_code)] pub fn new() -> Self { ...
use hacspec_lib::*; array!(Block, 8, U32); pub fn shuffle(b: Block) -> Block { let mut b = b; let tmp = b[0]; b[0] = b[1]; b[1] = tmp; b }
use log; use crate::{flow::FlowDirection, structs::rtp::{RTP, RtpHeader}}; use super::{FlowData, FlowHeader, FlowPacket, FlowPayload, FlowType}; use std::{collections::HashMap, net::SocketAddr, time::{Duration, SystemTime}}; #[derive(Clone)] pub struct ConnectionHeader { pub ftype: FlowType, pub local: SocketA...
use makepad_render::*; use crate::normalbutton::*; use crate::tab::*; use crate::desktopwindow::*; use crate::tabclose::*; use crate::texteditor::*; use crate::textinput::*; use crate::scrollbar::*; use crate::scrollshadow::*; use crate::desktopbutton::*; use crate::splitter::*; use crate::tabcontrol::*; use crate::xrc...
#[doc = "Writer for register ERASE"] pub type W = crate::W<u32, super::ERASE>; #[doc = "Register ERASE `reset()`'s with value 0"] impl crate::ResetValue for super::ERASE { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Erase the cache\n\nValue on reset: 0"] #[...
use super::abs; use super::ast; use super::make::Stage; use super::name::Name; use super::parser; use pbr; use rayon::prelude::*; use std::collections::HashMap; use std::path::Path; use std::path::PathBuf; use std::sync::atomic::Ordering; use std::sync::{Arc, Mutex}; #[derive(Clone)] pub enum Module { C(PathBuf), ...
pub mod cil; pub mod c_qv_bool; pub mod c_qv_float; pub mod c_qv_int; pub mod general_iter; pub mod c_qv_str; pub mod clist; pub mod null_or; pub mod mitem; pub mod mlist; pub mod ref_desc; pub mod citem; pub mod table; pub mod member_desc; pub mod root; pub use root::RootObjectPtr as RootObjectPtr; pub use table::Ta...
#![recursion_limit = "1024"] mod api; mod app; mod components; mod utils; mod views; use wasm_bindgen::prelude::*; pub(crate) use webgame_protocol as protocol; #[wasm_bindgen] pub fn run_app() -> Result<(), JsValue> { console_error_panic_hook::set_once(); web_logger::init(); yew::start_app::<crate::app:...
fn main() { struct Point { x: i32, y: i32 } let p1 = Point{ x: 1, y: 2 }; println!("Point is ( {}, {} )", p1.x, p1.y); let p2 = Point { x: 1, .. p1}; println!("Point 2's y is {}", p2.y); struct Color { i32, i32, i32 }; // it's an tuple struct let black = Color(0, 0, 0...
use crate::config::ActionSpec; #[derive(Clone)] pub enum Kind { Move, Copy, Undefined(String), } #[derive(Clone)] pub struct Action { id: String, description: String, files: Vec<String>, destination: String, kind: Kind, replace: bool, } pub trait Dispatchable { fn dispatch(&se...
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.a...
enum List { Cons(i32, Box<List>), Nil, } use crate::rust_book::r#box::List::{Cons, Nil}; //box - is a smart pointer #[allow(dead_code)] pub fn run() { let b = Box::new(5); println!("b = {}", b); // let x = 5; let y = Box::new(x); println!("Value {} is same as {}", x, *y); // p...
use itertools::Itertools; use std::error::Error as StdError; use std::fmt::Debug; use std::fs::File; use std::io::prelude::*; use std::io::{BufReader, Error as IoError}; use std::str::FromStr; use thiserror::Error; #[derive(Error, Debug)] pub enum ParseLinesError<L: StdError> { #[error("IO Error reading from strea...
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: Apache-2.0 // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.a...
fn main() { let page_size = page_size::get(); // In particular, this checks that it is not 0. assert!(page_size.is_power_of_two(), "page size not a power of two: {}", page_size); // Most architectures have 4k pages by default #[cfg(not(any( target_arch = "wasm32", target_arch = "was...
//! Instruction decoder //! //! This module provides a decoder and enum type for the 22 different instructions //! supported by this architecture. These are summarised in the following table: //! //! | Variant | Opcode | Assembly | Description | //! | --- | --- | --- | --- | //! | `Halt` | `0` | `halt ` | Stop execu...
use { super::{DEFAULT_FONT_SIZE, DEFAULT_PADDING}, crate::gui::{style, Interaction, Message, Mode, SelfUpdateState, State}, crate::localization::localized_string, crate::VERSION, ajour_core::{ config::{Config, Flavor}, theme::ColorPalette, }, iced::{ button, Align, Bu...
// TODO - break this down into smaller bits use crate::alphamap::Alphamap; use crate::ground_plane::GroundPlane; use crate::heightmap::Heightmap; use crate::origin_model::OriginModel; use crate::ortho_view::OrthoView; use kiss3d::camera::{Camera, FirstPerson}; use kiss3d::event::{Action, Key, WindowEvent}; use kiss3d:...
use crate::rendering::texture::{Dimensions, Texture}; use crate::rendering::tile::Tile; use crate::rendering::position::Position; use crate::rendering::color::Color; #[derive(Debug, Clone)] pub struct Canvas { pub dimensions: Dimensions, rows: Vec<Vec<Tile>>, buffer: String, } impl Default for Canvas { ...
#[cfg(test)] #[macro_use] extern crate quickcheck; extern crate arrayvec; extern crate buffer; #[macro_use] extern crate common; #[cfg(feature = "uuid")] extern crate uuid; extern crate warn; use arrayvec::ArrayVec; use buffer::Buffer; use buffer::BufferRef; use buffer::CapacityError; use buffer::with_buffer; use com...
use proc_macro::TokenStream; //use proc_macro2::TokenStream as TokenStream2; //use quote::quote; use syn::{parse_macro_input, Fields}; //use syn::punctuated::IntoIter; use crate::switch::enum_impl::generate_enum_impl; use crate::switch::shadow::ShadowMatcherToken; use crate::switch::struct_impl::generate_struct_impl; u...
use std::env; use jsonwebtoken::{decode as jwt_decode, DecodingKey, Validation}; use serde::Deserialize; #[derive(Deserialize)] pub struct AuthPayload { pub sub: String, pub uuid: String, pub exp: u128, } pub fn decode(token: &str) -> Option<AuthPayload> { let validation = Validation { sub: S...
//! Port of https://github.com/opencv/opencv/blob/master/samples/dnn/text_detection.cpp //! Check the source cpp file for where to get the NN files. //! This example requires at least OpenCV 4.5.1. use std::env; use std::error::Error; use std::fs::File; use std::io::{BufRead, BufReader}; use dnn::{TextDetectionModel_...
// Generated from Labels.g4 by ANTLR 4.8 #![allow(dead_code)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(nonstandard_style)] #![allow(unused_imports)] #![allow(unused_mut)] use super::labelslistener::*; use antlr_rust::atn::{ATN, INVALID_ALT}; use antlr_rust::atn_deserializer::ATNDeserializer;...
use std::mem; use std::ptr::{self, NonNull}; use libc; use util::Nullable; /// A pointer to the start of a `malloc`'ed block. Provides rudimentary bounds checking based on /// `malloc_usable_size`. Dereferencing is still unsafe since there is no guarantee that the /// contents are initialized. #[derive(Debug)] pub...
use crate::common::*; use parameterized_macro::parameterized; use std::fs; #[parameterized(env_name = {"default", "alpine"})] pub fn test_export_published_version(env_name: &str) { let state = setup(); if !cfg!(feature = "docker") && env_name == "alpine" { return; } publish_components(&state, ...
#[doc = "Register `INTF` reader"] pub struct R(crate::R<INTF_SPEC>); impl core::ops::Deref for R { type Target = crate::R<INTF_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &self.0 } } impl From<crate::R<INTF_SPEC>> for R { #[inline(always)] fn from(reader: crate::R<INTF_SP...
extern crate clap; use clap::{App, Arg}; mod ddg; mod files; mod geocode; mod grid; fn main() { let matches = App::new("Goose") .version("0.1.1") .author("Nate D.") .about("Query Duck Duck Go to get location data.") .arg( Arg::with_name("QUERY") .help("S...
#[doc = "Reader of register SCANC"] pub type R = crate::R<u32, super::SCANC>; #[doc = "Writer for register SCANC"] pub type W = crate::W<u32, super::SCANC>; #[doc = "Register SCANC `reset()`'s with value 0"] impl crate::ResetValue for super::SCANC { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
//! # path //! //! Path utility functions and traits. //! pub mod as_path; pub mod from_path; #[cfg(feature = "temp-path")] mod temp_path; #[cfg(test)] #[path = "./mod_test.rs"] mod mod_test; use crate::error::FsIOError; use crate::types::FsIOResult; use as_path::AsPath; use from_path::FromPath; use std::fs; use st...
struct Solution {} impl Solution { pub fn arrange_coins(n: i32) -> i32 { if n <= 1 { return n; } let n = n as i64; let mut left = 0 as i64; let mut right = n as i64; while left <= right { let mid = left + (right - left) / 2; let c...
use crate::gl_std::Object; use std::collections::HashMap; pub struct Env { env: HashMap<String, Object>, } impl Env { pub fn new() -> Env { Env { env: std::collections::HashMap::new() } } pub fn set(&mut self, key: &String, value: Object) { self.env.insert(String::from(key), value); } pub fn get(&self, ke...
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors // // 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 // // Unl...
// Copyright 2021 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 ...
// Copyright (C) 2017 Afonso Bordado // // Licensed under the MIT license <http://opensource.org/licenses/MIT>, // This file may not be copied, modified, or distributed except according // to the terms of that license. mod texture_atlas; pub use self::texture_atlas::TextureAtlas;
use std::ops::Deref; use std::sync::Arc; use rocket::{response::Redirect, State}; use super::super::super::super::super::{errors::Result, i18n::I18n, jwt::Jwt, orm::Database}; use super::super::super::models::user::Dao as UserDao; use super::super::api::users::{Action, Token}; const SIGN_IN_PATH: &'static str = "/my...
use std::fmt; use std::process; use std::time; #[cfg(debug_assertions)] pub fn pdbg(args: fmt::Arguments) { eprintln!("[DBG ] {}", args); } #[cfg(not(debug_assertions))] pub fn pdbg(_: fmt::Arguments) {} pub fn pdie(args: fmt::Arguments) -> ! { perr(args); process::exit(1) } pub fn perr(args: fmt::Arguments) ...
use std::fs::File; use std::io::{BufRead, BufReader}; type SeatID = i32; pub fn main() { let path = "./src/input.txt"; qn1(path); qn2(path); } fn qn1(path: &str) { let file = File::open(path).expect("cannot open file"); let reader = BufReader::new(file); let mut max_seat_id = 0; reader ...
//! The code in this file is inefficient and quite spaghetti-ish, but //! it only has to run to generate the library. use kserde::*; use std::collections::{HashMap, HashSet}; use std::fmt::Write as FmtWrite; use std::path::Path; #[derive(Debug)] struct Property { name: String, required: bool, schema: Sche...
extern crate rand; use std::io::Cursor; use byteorder::{ReadBytesExt, WriteBytesExt, LittleEndian}; use std::io::{Read, Write}; use std; use std::str; use std::net::UdpSocket; use std::net::{IpAddr, Ipv4Addr, SocketAddr, SocketAddrV4}; use std::thread; use std::time; use rand::Rng; const messaging_port: u16 = 80; cons...
use serde::Deserialize; use std::collections::HashMap; use std::env; use std::fs::{create_dir, File}; use std::io::copy; use std::path::Path; #[derive(Deserialize, Debug)] struct Emoji { ok: bool, emoji: HashMap<String, String>, } const ENDPOINT: &str = "https://slack.com/api/emoji.list"; const SLACK_API_TOKE...
// extern crate crust; #[macro_use] extern crate clap; use clap::{App, Arg, SubCommand}; // use crust::Config; /** * TODO: * add * remove * list * find * vote * init */ macro_rules! subcommands { ($name:expr, $description:expr) => { SubCommand::with_name($name).about($description) }; } fn main() { ...
use crate::intcode::{self, Intcode}; use crate::problem::Problem; #[derive(Default)] pub struct DayNine {} impl DayNine {} impl Problem for DayNine { fn new() -> Self { Self {} } fn soln_one(&self) -> Option<String> { Some("2662308295".to_string()) } fn part_one(&self, program: &str) -> Option<St...
use super::locks::range_lock::c_flock; use super::*; use util::mem_util::from_user; #[derive(Debug)] pub enum FcntlCmd<'a> { /// Duplicate the file descriptor fd using the lowest-numbered available /// file descriptor greater than or equal to arg. DupFd(FileDesc), /// As for `DupFd`, but additionally s...