text
stringlengths
8
4.13M
use std::collections::HashMap; use proconio::input; const INF: u64 = std::u64::MAX; // [pi, qi] ร— [pj, qj] ใ‚’ t ๅŒบ็”ปใซๅˆ†ๅ‰ฒ // min(ๅŒบ็”ปๅ†…ใฎใ‚คใƒใ‚ดๅˆ่จˆ) >= m // max(ๅŒบ็”ปๅ†…ใฎใ‚คใƒใ‚ดๅˆ่จˆ) ใฎๆœ€ๅฐๅ€คใ‚’่ฟ”ใ™ fn solve( pi: usize, pj: usize, qi: usize, qj: usize, t: usize, m: u64, cum_sum: &CumulativeSum2D<u64>, memo: &mut Hash...
pub struct LinearGradientRectangle; use crate::{ types::{HitableList, Ray, Vec3}, Camera, {demos::Chunk, Demo}, }; impl Demo for LinearGradientRectangle { fn name(&self) -> &'static str { "linear-gradient-rectangle" } fn render_chunk( &self, chunk: &mut Chunk, ...
#[doc = "Reader of register SMIS"] pub type R = crate::R<u32, super::SMIS>; #[doc = "Reader of field `DATAMIS`"] pub type DATAMIS_R = crate::R<bool, bool>; #[doc = "Reader of field `STARTMIS`"] pub type STARTMIS_R = crate::R<bool, bool>; #[doc = "Reader of field `STOPMIS`"] pub type STOPMIS_R = crate::R<bool, bool>; #[...
#![forbid(unsafe_code)] use std::fs; use std::io; use std::io::{BufRead, BufReader, Read}; use std::path::PathBuf; use anyhow::bail; use atty::Stream; use structopt::StructOpt; use pop::notification::{Attachment, Notification}; #[derive(Debug, StructOpt)] #[structopt(about, author)] struct Opts { /// Verbose mo...
// 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 ...
use blisp; #[test] fn test_transpile() { let expr = " (defun snoc (l y) (Pure (-> ( '(t) t) '(t))) (match l (nil (Cons y nil)) ((Cons h b) (Cons h (snoc b y))))) (defun rev (l) (Pure (-> ( '(t)) '(t))) (match l (nil nil) ((Cons h t) (...
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 #![deny(missing_docs)] //! Utility for sending log related messages and metrics to two different storing destinations or //! simply to stdout/stderr. The logging destination is specified upon the initializ...
#[macro_use] extern crate lazy_static; extern crate regex; extern crate itertools; extern crate fnv; extern crate rustyline; use rustyline::error::ReadlineError; use rustyline::Editor; #[macro_use] #[allow(dead_code)] mod types; use types::{format_error}; mod reader; mod printer; // TODO: figure out a...
pub mod char_stream; pub mod tokens; pub mod tokeniser; pub mod token_printer; pub mod parser; pub mod parser_helpers; pub mod ast_utils; pub mod ast_printer; pub mod types; mod type_printer;
#![no_std] extern crate byte_tools; extern crate block_cipher_trait; mod sboxes_exp; #[macro_use] mod construct; use byte_tools::{read_u32v_le, read_u32_le, write_u32_le}; use block_cipher_trait::{BlockCipher, NewFixKey}; use block_cipher_trait::generic_array::GenericArray; use block_cipher_trait::generic_array::type...
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ...
// Copyright 2020-2021, The Tremor Team // // 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 agr...
//! Proof checker for Varisat proofs. use std::io; use anyhow::Error; use partial_ref::{IntoPartialRefMut, PartialRef}; use thiserror::Error; use varisat_dimacs::DimacsParser; use varisat_formula::{CnfFormula, Lit}; pub mod internal; mod clauses; mod context; mod hash; mod processing; mod rup; mod sorted_lits; mod...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "Win32_System_Diagnostics_Debug_WebApp")] pub mod WebApp; pub const ACTIVPROF_E_PROFILER_ABSENT: ::windows::core::HRESULT = ::windows::core::HRESULT(-2147220991i32 as _); pub ...
extern crate peg; use itertools::Itertools; use std::collections::HashMap; use std::ops; #[derive(PartialEq, Eq, Hash, Debug, Copy, Clone)] pub struct Hex { x: i32, y: i32, } impl Hex { pub fn new(x: i32, y: i32) -> Hex { Hex { x, y } } pub fn neighbours(&self) -> Vec<Hex> { vec!...
use gatt::characteristics as ch; use gatt::services as srv; use gatt::{CharacteristicProperties, Registration}; pub(crate) fn add(registration: &mut Registration<super::Token>) { registration.add_primary_service(srv::BATTERY); registration.add_characteristic( ch::BATTERY_LEVEL, vec![100], ...
use std::marker::PhantomData; use crate::{ type_level::impl_enum::{Implemented, Unimplemented}, GetStaticEquivalent, InterfaceType, StableAbi, }; use core_extensions::type_asserts::AssertEq; //////////////////////////////////////////////////////////////////////////////// #[repr(C)] #[derive(StableAbi)] #[sa...
mod helloworld; pub fn main() { yew::Renderer::<helloworld::App>::new().render(); }
#[doc = "Reader of register SECSR"] pub type R = crate::R<u32, super::SECSR>; #[doc = "Writer for register SECSR"] pub type W = crate::W<u32, super::SECSR>; #[doc = "Register SECSR `reset()`'s with value 0"] impl crate::ResetValue for super::SECSR { type Type = u32; #[inline(always)] fn reset_value() -> Sel...
// auto generated, do not modify. // created: Wed Jan 20 00:44:03 2016 // src-file: /QtQml/qqmldebug.h // dst-file: /src/qml/qqmldebug.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin => // <=...
use chrono::Utc; use serde::{Deserialize, Serialize}; use sqlx::types::chrono::DateTime; #[derive(Serialize, Deserialize, Debug)] pub struct Expedition { pub id: i64, pub url: String, pub name: String, pub start: DateTime<Utc>, pub end: Option<DateTime<Utc>>, }
use crate::debug::DebugState; use cvar::{INode, IVisit}; pub use soldank_shared::cvars::*; #[derive(Default)] pub struct Config { pub phys: Physics, pub net: NetConfig, pub debug: DebugState, } impl IVisit for Config { fn visit(&mut self, f: &mut dyn FnMut(&mut dyn INode)) { f(&mut cvar::List(...
#[no_mangle] #[inline(never)] pub fn sm_alloc(size: i32) -> i64 { let layout = std::alloc::Layout::from_size_align(size as usize, 4).unwrap(); let ptr = unsafe { std::alloc::alloc(layout) }; ptr as i64 }
use core::fmt; use crate::config::{ Configuration, auto_retransmit, auto_ack }; use crate::device::{ Device, UsingDevice }; use crate::rx::RxMode; use crate::tx::TxMode; use crate::ptx::PtxMode; use crate::registers::{ Feature, Dynpd }; use crate::PIPES_COUNT; /// Represents **Standby-I** mode /// /// This represents...
#[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::PATCHEN { #[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 fltk::{prelude::*, *}; use fltk_flex::Flex; fn main() { let a = app::App::default().with_scheme(app::Scheme::Gtk); let mut win = window::Window::default().with_size(640, 480); let mut col = Flex::new(5, 5, 630, 470, None).column(); { let mut row = Flex::default().row(); { ...
//Definition for singly-linked list. #[derive(PartialEq, Eq, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } struct Solution {} // ๅˆๅนถ k ไธชๆŽ’ๅบ้“พ่กจ๏ผŒ่ฟ”ๅ›žๅˆๅนถๅŽ็š„ๆŽ’ๅบ้“พ่กจใ€‚่ฏทๅˆ†ๆžๅ’Œๆ่ฟฐ็ฎ—ๆณ•็š„ๅคๆ‚ๅบฆใ€‚ // //็คบ...
#[doc = "Reader of register WKUPEPR"] pub type R = crate::R<u32, super::WKUPEPR>; #[doc = "Writer for register WKUPEPR"] pub type W = crate::W<u32, super::WKUPEPR>; #[doc = "Register WKUPEPR `reset()`'s with value 0"] impl crate::ResetValue for super::WKUPEPR { type Type = u32; #[inline(always)] fn reset_va...
use super::{ core::{Py, PyObject, PyObjectRef, PyRef}, payload::{PyObjectPayload, PyPayload}, }; use crate::common::{ atomic::{Ordering, PyAtomic, Radium}, lock::PyRwLockReadGuard, }; use crate::{ builtins::{PyBaseExceptionRef, PyStrInterned, PyType}, convert::{IntoPyException, ToPyObject, ToPyR...
use crate::{ bodies::AxisAlignedBoundingBox, systems, Acceleration, BodyType, Drag, EntityCollision, Forces, Gravity, Mass, PhysicsState, TileCollision, Velocity, TileCollisionAxis }; use game_core::{combinators::if_all, modes::ModeExt, GameStage, GlobalMode, ModeEvent}; use game_lib::bevy::{ecs as bevy_ecs, pr...
// Copyright (c) 2015-2016 Georg Brandl. Licensed under the Apache License, // Version 2.0 <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> // or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at // your option. This file may not be copied, modified, or distributed except // accordi...
// TODO // - MAKE AN ALERT FOR JEFFERY BECAUSE YOU LOVE HIM // - BUG - when bomb is on far right side, the space directly to the left often doesn't get // calculated properly // - add smiley // - requires facial animations while clicking on flagged // - add numbers // - need to create time and mines variables that...
use gfx_maths::*; /// Renders a brdf example use std::{path::Path, rc::Rc}; use vulkan_engine::{ core::engine::Engine, scene::{ component::{ camera_component::CameraComponent, debug_movement_component::DebugMovementComponent, light_component::LightComponent, renderer::RendererCom...
use std::io::{ Cursor, Error as IOError, ErrorKind, }; use std::path::Path; use std::sync::Arc; use regex::Regex; use sourcerenderer_core::Platform; use sourcerenderer_vpk::{ Package, PackageError, }; use crate::asset::asset_manager::{ AssetContainer, AssetFile, AssetLoadPriority, ...
// Copyright 2022 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 agre...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] pub const DEFAULT_WEIGHT: u32 = 1u32; #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core ...
use crate::{NewService, Service}; use futures::{Future, IntoFuture, Poll}; pub type BoxedService<Req, Res, Err> = Box< Service< Request = Req, Response = Res, Error = Err, Future = Box<Future<Item = Res, Error = Err>>, >, >; /// Create boxed new service pub fn new_service<T, C>...
use util::*; use BitSetLike; /// An `Iterator` over a [`BitSetLike`] structure. /// /// [`BitSetLike`]: ../trait.BitSetLike.html #[derive(Debug)] pub struct BitIter<T> { set: T, masks: [usize; 4], prefix: [u32; 3], } impl<T> BitIter<T> { /// Creates a new `BitIter`. You usually don't call this functio...
use crate::bryggio::{process, recipe::RecipeSrc, Recipe}; use beerxml; use brew_calculator::ibu; use std::convert::From; impl From<beerxml::Recipe> for Recipe<BeerXmlSrc> { fn from(beerxml_recipe: beerxml::Recipe) -> Self { Recipe { name: beerxml_recipe.name, type_: beerxml_recipe.t...
//! divrulesanddescription.rs - renders the div that shows rules and descriptions //! All is a static content. Great for implementing dodrio cache. //region: use use dodrio::builder::{br, text}; use dodrio::bumpalo::{self, Bump}; use dodrio::{Node, Render}; use typed_html::dodrio; //endregion ///Text of game rules. /...
use ::rayon::prelude::*; use ::rayon::slice::ParallelSliceMut; use ::std::sync::Mutex; use crate::util::Point; use crate::util::Minimum; #[allow(dead_code)] fn xsort_ser(points: &mut [Point]) -> (Point, Point) { points.sort_by(|p1, p2| p1.x.partial_cmp(&p2.x).unwrap()); let mut minimum = Minimum::new( ...
//! `tcplistener` provide an interface to establish tcp socket server. use crate::{Handle, IpAddress}; extern "Rust" { fn sys_tcp_listener_accept(port: u16) -> Result<(Handle, IpAddress, u16), ()>; } /// Wait for connection at specified address. #[deprecated(since = "0.3.0", note = "please use new BSD socket interf...
extern crate gunship; extern crate rand; use std::collections::VecDeque; use std::f32::consts::PI; use gunship::*; const ENTITIES_TO_CREATE: usize = 10_000; const ENTITIES_TO_DESTROY: usize = 1_000; fn main() { let mut engine = Engine::new(); engine.register_system(CreateDestroySystem { entities: V...
use std::env; use std::fs::File; use std::io::Write; use std::path::Path; use man::prelude::*; use regex::Regex; use yaml_rust::yaml::Hash; use yaml_rust::{Yaml, YamlLoader}; fn s2y<T: ToString>(s: T) -> Yaml { Yaml::String(s.to_string()) } fn parse_str<T: ToString>(a: &Hash, k: T) -> String { let s = a.get(...
//! DAG-JSON codec. use crate::ipld::{BlockError, Ipld}; use cid::Cid; use core::convert::TryFrom; use serde::de::Error as SerdeError; use serde::{de, ser, Deserialize, Serialize}; use serde_json::ser::Serializer; use serde_json::Error; use std::collections::BTreeMap; use std::fmt; /// Json codec. #[derive(Clone, De...
use crate::prelude::*; use std::os::raw::c_void; use std::ptr; #[repr(C)] #[derive(Debug)] pub struct VkRenderPassBeginInfo { pub sType: VkStructureType, pub pNext: *const c_void, pub renderPass: VkRenderPass, pub framebuffer: VkFramebuffer, pub renderArea: VkRect2D, pub clearValueCount: u32, ...
// This file is part of file-descriptors. 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/file-descriptors/master/COPYRIGHT. No part of file-descriptors, including this file, may be copied, modified, propag...
use ctpop::ctpop32; /** * Counts the number of leading zero bits in an unsigned 32-bit integer. */ pure fn lzc32(m: u32) -> u32 { let mut x = copy m; x |= (x >> 1); x |= (x >> 2); x |= (x >> 4); x |= (x >> 8); x |= (x >> 16); return(32 - ctpop32(x)); } #[test] fn test_lzc32_1() { assert(lzc32(0x0) ...
use crypto::{ encryption::ElGamal, helper::Helper, proofs::{decryption::DecryptionProof, keygen::KeyGenerationProof}, random::Random, types::Cipher as BigCipher, }; use hex_literal::hex; use num_bigint::BigUint; use pallet_mixnet::types::{Cipher, PublicKeyShare, Wrapper}; use sp_keyring::{sr25519::s...
fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let n: usize = rd.get(); let a: Vec<usize> = (0..n).map(|_| { rd.get() }).collect(); let mo: usize = 998244353; use mint::Mint; let mut ans = Mint::zero(mo); let mut left_cnt = vec![0; n]; // 0..j ...
use std::env; use std::fs::File; use std::io::{BufRead, BufReader}; fn main() { let a = env::args().skip(1).next() .and_then(|s| File::open(s).ok()) .map(|f| BufReader::new(f).lines()); for lines in a { for line in lines { println!("{}", line.unwrap()); // println!("{}", line.unwrap_or(String::from(""...
//! Implementation of gas price estimation. use crate::conv; use crate::future::CompatCallFuture; use futures::compat::Future01CompatExt; use futures::future::OptionFuture; use pin_project::{pin_project, project}; use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; use web3::api::Web3; use web3...
use super::{DataHandle, MemoryFS, OpenOptions, VPath, VFS}; use rust_embed::RustEmbed; pub fn assets_to_vfs<R: RustEmbed>() -> MemoryFS { let mem = MemoryFS::new(); for path in R::iter() { let parent = pathutils::parent_path(&path).unwrap(); let mem_path = mem.path(parent); mem_path.cr...
pub mod display; pub mod input; pub mod audio; pub mod config;
//! ะขะธะฟั‹ ัะตั‡ะตะฝะธะน ะบะพะปะพะฝะฝ, ะฑะฐะปะพะบ, ั„ัƒะฝะดะฐะผะตะฝั‚ะฝั‹ั… ะฑะฐะปะพะบ use crate::sig::HasWrite; use nom::{ bytes::complete::take, number::complete::{le_f32, le_u8}, IResult, }; use std::fmt; #[derive(Debug)] pub enum Sec { Rectangle(RectangleSec), Circle(CircleSec), Cross(CrossSec), Ring(RingSec), Box(Box...
fn main() { proconio::input!{n:u64,r:u64}; println!("{}", if n >= 10 { r } else { r + 1000 - 100 * n }) }
use crate::ast; use bitvec; use serde::{Deserialize, Serialize}; type BitVec = bitvec::vec::BitVec<bitvec::order::Lsb0, u64>; // TODO: Use entity-component system like the specs crate? // TODO: #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default)] pub struct Module { pub symbols: Vec<String>, ...
//! An interface to read data from the systemโ€™s power_supply class. //! Uses the built-in legoev3-battery if none is specified. use std::{fs, path::Path}; use crate::driver::DRIVER_PATH; use crate::utils::OrErr; use crate::{Attribute, Device, Driver, Ev3Error, Ev3Result}; /// An interface to read data from the syste...
use std::{ future::Future, path::{Path, PathBuf}, pin::Pin, sync::{Arc, Mutex}, task::{Context, Poll, Waker}, }; #[derive(Default)] struct ReaderState { res: Option<std::io::Result<Vec<u8>>>, waker: Option<Waker>, } struct Reader { state: Arc<Mutex<ReaderState>>, } impl Reader { f...
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use nannou::prelude::*; type Points = Vec<Point2<f32>>; fn smooth(points: &Points) -> Points { let last_index = points.len() - 1; let num_line_segments = points.len() - 1; // Each line segment creates two points. let mut smoothed...
use std::{ collections::{btree_map, BTreeMap, HashSet}, iter::{Iterator, Peekable}, }; use oasis_core_runtime::storage::mkvs; use super::{NestedStore, Store}; /// An overlay store which keeps values locally until explicitly committed. pub struct OverlayStore<S: Store> { parent: S, overlay: BTreeMap<V...
pub fn hello_world() { println!("\n--- hello_world() ---"); println!("Hello, world!"); }
use crate::apps::SubApp; use clap::Clap; use cli_table::{format::Justify, print_stdout, Cell, Style, Table}; use std::error::Error; use electric_lib::usb::{HidDevice, HidManager}; #[derive(Clap, Debug)] pub struct ShowUSBApp { #[clap(short = 'w', long = "watch", about = "Continuously watch changes of USB device c...
extern crate memmap; use std::fs::OpenOptions; use memmap::MmapMut; fn init_balancesheet() { const PATH: &str = "BALANCE"; let file = OpenOptions::new().read(true).write(true).create(true).open(&PATH).unwrap(); // 25 million users 4 bytes per balance file.set_len(25_000_000 * 4).unwrap(); let mu...
use reqwest::Client; use wiremock::matchers::any; use wiremock::{Mock, MockServer, ResponseTemplate}; async fn test_body() { // Arrange let mock_server = MockServer::start().await; let response = ResponseTemplate::new(200).set_delay(std::time::Duration::from_secs(60)); Mock::given(any()) .resp...
use std::env::args; use std::net::{SocketAddr, UdpSocket}; use std::str::FromStr; fn main() { let arguments: Vec<String> = args().collect(); let server = &arguments[1]; let client = &arguments[2]; let socket = UdpSocket::bind(server).unwrap(); let to = SocketAddr::from_str(client).unwrap(); l...
use header::Header; use std::fmt; use std::ops::{Index, IndexMut, Range}; #[derive(Debug)] pub struct Cart { pub mem: Vec<u8>, pub headers: Vec<Header>, } impl Cart { pub fn new(mem: Vec<u8>) -> Cart { Cart { mem: mem, headers: vec![ Header::new("entry poin...
// Day 12 use std::cmp::{max, min}; use std::error::Error; use std::fs; use std::process; fn main() { let input_filename = "input.txt"; if let Err(e) = run(input_filename) { println!("Application error: {}", e); process::exit(1); } } fn run(filename: &str) -> Result<(), Box<dyn Error>> { ...
use serde::{Deserialize, Serialize}; use crate::api::message::amount::*; // use serde::ser::{Serializer, SerializeStruct}; use crate::api::utils::tx_flags::*; use std::error::Error; use std::fmt; #[derive(Serialize, Deserialize, Debug)] pub struct SetBrokerageTxJson { #[serde(rename="Flags")] pub flags: u32,...
//! Developer extensions for basic-http-server use super::{Config, HtmlCfg}; use super::{Error, Result}; use comrak::ComrakOptions; use futures::{future, future::Either, Future, Stream}; use http::{Request, Response, StatusCode}; use hyper::{header, Body}; use percent_encoding::{utf8_percent_encode, AsciiSet, CONTROLS...
/// /// /// use std; use gtk; pub trait ComponentStoreTrait { fn add_component(&mut self, name: String, component: Box<gtk::WidgetTrait>) -> (); fn remove_component(&mut self, name: &String) -> (); fn get_component(&self, name: &String) -> Option<&Box<gtk::WidgetTrait>>; }
use super::*; mod with_atom_destination; mod with_local_pid_destination; #[test] fn without_atom_or_pid_destination_errors_badarg() { run!( |arc_process| { ( Just(arc_process.clone()), milliseconds(), strategy::term::is_not_send_after_destination...
use std::fs; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::sync::atomic::Ordering; use std::sync::Arc; use std::thread; use std::time::Duration; type Counter = std::sync::atomic::AtomicUsize; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let c...
extern crate rustc_serialize; extern crate walkdir; extern crate pulldown_cmark; extern crate mustache; extern crate yaml_rust; extern crate core; extern crate frontmatter; pub mod builders { use walkdir::DirEntry; use std::path::Path; use yaml_rust::Yaml; fn is_markdown(entry: &DirEntry) -> bool { ...
// Copyright 2012-2013 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-MI...
use crate::math::{Color, Point}; use super::{SolidColor, Texture}; pub struct CheckerTexture { even: Box<dyn Texture>, odd: Box<dyn Texture>, } impl CheckerTexture { pub fn new(even: Box<dyn Texture>, odd: Box<dyn Texture>) -> Self { CheckerTexture { even, odd, } ...
use std::io::{self, BufRead}; fn main() { let stdin = io::stdin(); let mut iterator = stdin.lock().lines(); let mut cases: i32 = iterator.next().unwrap().unwrap().parse().unwrap(); while cases > 0 { cases -= 1; let mut nums = iterator.next().unwrap().unwrap(); let values: Vec<i...
use arrow::record_batch::RecordBatch; use clap::ValueEnum; use futures::TryStreamExt; use influxdb_iox_client::format::influxql::{write_columnar, Options}; use influxdb_iox_client::{connection::Connection, flight, format::QueryOutputFormat}; use thiserror::Error; #[derive(Debug, Error)] pub enum Error { #[error("E...
// 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. use carnelian::{make_message, set_node_color, Color, Point, Rect, ViewAssistantContext}; use failure::Error; use fidl_fuchsia_ui_input::{PointerEvent, Poin...
// 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 ...
pub struct SimpleLinkedList<T> { head: Option<Box<Node<T>>>, len: usize, } struct Node<T> { data: T, next: Option<Box<Node<T>>>, } impl<T> SimpleLinkedList<T> { pub fn new() -> Self { SimpleLinkedList { head: None, len: 0 } } pub fn len(&self) -> usize { self.len } ...
use crate::{ event::merge_state::LogEventMergeState, event::{self, Event, LogEvent, Value}, shutdown::ShutdownSignal, topology::config::{DataType, GlobalOptions, SourceConfig, SourceDescription}, }; use bollard::{ container::{InspectContainerOptions, ListContainersOptions, LogOutput, LogsOptions}, ...
//! Contains the ffi-safe equivalent of `std::collections::HashMap`, and related items. #![allow(clippy::missing_const_for_fn)] use std::{ borrow::Borrow, cmp::{Eq, PartialEq}, collections::{hash_map::RandomState, HashMap}, fmt::{self, Debug}, hash::{BuildHasher, Hash, Hasher}, iter::FromIterat...
//! Handles talking to local data store. use chrono; use futures::future::LocalBoxFuture; use linear_map::LinearMap; use r2d2; use rusqlite; use serde; use serde::Serialize; use snafu::{Backtrace, Snafu}; // mod postgres; mod sqlite; // pub use self::postgres::PostgresDatabase; pub use self::sqlite::SqliteDatabase;...
// Copyright 2018 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, await_macro, futures_api)] #![deny(warnings)] #![recursion_limit="256"] use { failure::{Error, ResultExt}, fdio, fidl:...
// 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. use crate::{AccessibilityOptions, CaptionCommands}; use failure::Error; use fidl_fuchsia_settings::{ AccessibilityProxy, AccessibilitySettings, Caption...
use rand::prelude::*; use std::fmt; /* Number of students to assign */ // const NSTUDENT: usize = 25; const NSTUDENT: usize = 27; /* Number of sets to assign to */ const NSET: usize = 13; /* Number of choices of set per student */ const NCHOICE: usize = 5; /* Default rank for unclassified sets */ const UNCLASSIFIED_RA...
use crate::impl_pnext; use crate::prelude::*; use std::os::raw::c_void; use std::ptr; #[repr(C)] #[derive(Debug)] pub struct VkDescriptorSetLayoutCreateInfo { pub sType: VkStructureType, pub pNext: *const c_void, pub flags: VkDescriptorSetLayoutCreateFlagBits, pub bindingCount: u32, pub pBindings:...
use diesel::prelude::*; use super::Context; use super::QueryRoot; use crate::graphql_schema::resolver::Team; impl QueryRoot { pub(crate) fn teams_impl(context: &Context) -> Vec<Team> { use crate::schema::teams::dsl::*; let connection = context.db.get().unwrap(); teams .limit(10...
#[cfg(target_arch = "x86")] use core::arch::aarch64::*; use core::mem::transmute; // ๅ‚่€ƒ: https://github.com/noloader/AES-Intrinsics/blob/master/clmul-arm.c pub unsafe fn pmull(a: uint8x16_t, b: uint8x16_t) -> uint8x16_t { // Low let a: poly64_t = transmute(vgetq_lane_u64(vreinterpretq_u64_u8(a), 0)); le...
// Copyright 2018-2021 Parity Technologies (UK) Ltd. // // 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 applicab...
//! A pure rust replacement for the [miniz](https://github.com/richgel999/miniz) //! DEFLATE/zlib encoder/decoder. //! The plan for this crate is to be used as a back-end for the //! [flate2](https://github.com/alexcrichton/flate2-rs) crate and eventually remove the //! need to depend on a C library. //! //! # Usage //...
//! File access and modification use types::{char_t, int_t, timeval, utimbuf}; use syscalls::sys_utimes; use rust::prelude::*; /// Change file last access and modification times. #[no_mangle] pub unsafe extern fn utime(path: *const char_t, times: *const utimbuf) -> int_t { if times.is_null() { let mut tv ...
use crate::base::crypto::sha256::JSha256; use crate::base::xcodec::util::{is_set, concat_args, seq_equal}; use crate::base::data::base_data::{BaseDataI}; use basex_rs::{BaseX, SKYWELL, Decode, Encode}; use hex; pub trait XCodeI { fn encode(bytes: &mut Vec<u8>, arg: Box<dyn BaseDataI>) -> String; fn decode(str...
use crate::logic::schema::ground_tiles_with_deleted; #[derive(Insertable)] #[table_name = "ground_tiles_with_deleted"] pub struct GroundTileInput { type_: String, // deleted_at: Option<i64> } impl GroundTileInput { pub fn new(types: String) -> GroundTileInput { GroundTileInput { type_:...
//! Handle packet encoding and peer ACK use std::net::SocketAddr; use std::mem; use std::fmt::Debug; use std::io::ErrorKind; use std::collections::HashMap; use futures::task::Task; use futures::sync::mpsc::Sender; use futures::stream::{futures_unordered, FuturesUnordered}; use tokio::prelude::*; use tokio::{self, io,...
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ...
pub struct Solution; #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: List, } type List = Option<Box<ListNode>>; impl Solution { pub fn reverse_k_group(head: List, k: i32) -> List { let mut head = head; let mut current = &mut head; while has_k_n...
use crate::prelude::*; use presentation::wsi::windowsystemintegration::WindowSystemIntegration; use std::path::Path; pub struct WindowConfig<'a> { wsi: &'a WindowSystemIntegration, } impl<'a> WindowConfig<'a> { pub(crate) fn new(wsi: &'a WindowSystemIntegration) -> Self { WindowConfig { wsi } } ...
pub fn maximum69_number(num: i32) -> i32 { num.to_string().replacen("6", "9", 1).parse().unwrap() } #[cfg(test)] mod maximum69_number_tests { use super::*; #[test] fn maximum69_number_test_one() { // arrange let test = 9669; // act let result = maximum69_number(test); ...