text
stringlengths
8
4.13M
use std::error::Error; use std::fs::File; use std::io::Write; use flate2::read::GzDecoder; use log::error; pub use analysis::execute_analysis; pub use query::execute_query; pub use statistics::execute_statistics; use crate::csv::csv_data::{CsvData, CsvStream}; use crate::db::Rows; mod analysis; mod query; mod stati...
use std::error::Error; use std::fmt::Display; use std::fmt; use std::io::Write; use termcolor::BufferWriter; use termcolor::ColorChoice; use termcolor::ColorSpec; use termcolor::Color; use termcolor::WriteColor; #[derive(Debug)] pub struct HttpError { pub code: u16, pub url: String, } impl HttpError { pub...
fn unannotated_literals() -> u8 { let _x: i64 = 123; let _x: u32 = 88; 42 }
//! Implementation of Hybrid Logical Clocks //! //! HLC timestamps blend the best attributes of traditional wall-clock timestamps and //! vector clocks. They are close to traditional wall-clock timestamps but the sub-millisecond //! bits of the timestamp are dropped in favor of a logical clock that provides happened-...
//! Module for [`MonotonicMap`]. use super::clear::Clear; /// A map-like interface which in reality only stores one value at a time. The keys must be /// monotonically increasing (i.e. timestamps). For Hydroflow, this allows state to be stored which /// resets each tick by using the tick counter as the key. In the ge...
pub const P_KEY_FILE: &str = "/.lockbox/public_key"; pub const S_KEY_FILE: &str = "/.lockbox/secret_key"; pub const NONCE_FILE: &str = "/.lockbox/nonce"; pub const DATABASE_FILE: &str = "/.lockbox/passwords.db";
use anyhow::{anyhow, Result}; use hwloc::{ObjectType, Topology, TopologyObject}; /// Bind the current thread to a single CPU core. pub fn bind_to_single_core() -> Result<()> { let mut topo = Topology::new(); let mut cpuset = last_core(&mut topo)? .cpuset() .ok_or(anyhow!("empty CPU set"))?; ...
/// # Panics /// /// If string is empty. fn first_char(string: &str) -> char { string.chars().next().unwrap() } /// # Panics /// /// If string is empty. fn first_and_last_char(string: &str) -> (char, char) { ( first_char(string), first_char(string.rmatches(|_: char| true).next().unwrap()), ...
use super::core::*; use assembly_core::nom::{ combinator::{cond, map_opt, map_res}, multi::{fold_many_m_n, length_count}, number::complete::{le_f32, le_u32, le_u8}, sequence::tuple, IResult, }; use assembly_core::parser::{ parse_object_id, parse_object_template, parse_quat, parse_quat_wxyz, pars...
// This file is part of Substrate. // Copyright (C) 2020-2021 Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the F...
// Vicfred // https://atcoder.jp/contests/abc128/tasks/abc128_b // implementation, sorting use std::io; use std::cmp::Ordering; #[derive(Eq,PartialEq)] struct Restaurant { name: String, score: i64, index: i64, } impl PartialOrd for Restaurant { fn partial_cmp(&self, other: &Self) -> Option<Ordering> {...
#[doc = "Register `RCC_APB4RSTCLRR` reader"] pub type R = crate::R<RCC_APB4RSTCLRR_SPEC>; #[doc = "Register `RCC_APB4RSTCLRR` writer"] pub type W = crate::W<RCC_APB4RSTCLRR_SPEC>; #[doc = "Field `LTDCRST` reader - LTDCRST"] pub type LTDCRST_R = crate::BitReader; #[doc = "Field `LTDCRST` writer - LTDCRST"] pub type LTDC...
#[derive(VulkanoShader)] #[ty = "vertex"] #[src = " #version 450 layout(set = 0, binding = 0) uniform Matrix { mat4 matrix; } matrix; layout(location = 0) in vec2 pos; layout(location = 1) in vec2 uv; layout(location = 2) in vec4 col; layout(location = 0) out vec2 f_uv; layout(location = 1) out vec4 f_color; v...
use crate::vmcmd::*; use std::io::Write; use std::fs::File; pub struct Assembler { filename : String, label_index : u32, assembly : String, label_counter: usize, no_comment : bool, current_fnc : String, } impl Assembler { pub fn new(filename: String, no_comment: bool) -> Assemb...
use crate::arch::read_clock_counter; pub struct StopWatch { current: u64, } impl StopWatch { pub fn start() -> StopWatch { let current = read_clock_counter(); StopWatch { current } } pub fn lap_time(&mut self, title: &'static str) { let current = read_clock_counter(); ...
use std::fmt; /// paramType represents a SCTP INIT/INITACK parameter #[derive(Debug, Copy, Clone, PartialEq)] #[repr(C)] pub(crate) enum ParamType { HeartbeatInfo = 1, /// Heartbeat Info [RFCRFC4960] Ipv4Addr = 5, /// IPv4 IP [RFCRFC4960] Ipv6Addr = 6, /// IPv6 IP [RFCRFC4960] StateCookie =...
#![allow(dead_code)] #![allow(unused_variables)] mod basis; use crate::basis::stack_heap; use crate::basis::control_flow; use crate::basis::data_structure; use crate::basis::std_collections; use crate::basis::characters; use crate::basis::functions; use crate::basis::traits; use crate::basis::variable_access; use crat...
use super::*; use crate::gc::Address; use std::collections::HashSet; pub struct HeapBlock { cell_size: usize, free_list: *mut FreeListEntry, bitset: HashSet<Address>, cursor: Address, pub next: Address, pub prev: Address, storage: u8, } impl HeapBlock { pub fn sweep(&mut self) -> bool {...
//! A vector that supports efficient deletion without reordering all subsequent items. use std::collections::HashMap; use std::hash::Hash; use std::iter::FusedIterator; /// A vector that supports efficient deletion without reordering all subsequent items. pub struct SparseVec<T> { items: Vec<Option<T>>, item_l...
use crate::ctypes::*; //use crate::shared::ntdef::CHAR; use crate::shared::minwindef::{BYTE, DWORD, WORD}; use crate::shared::basetsd::{ULONG_PTR}; pub use crate::shared::ntdef::LARGE_INTEGER; pub use crate::shared::ntdef::LUID; pub use crate::shared::ntdef::ULARGE_INTEGER; pub type PVOID = *mut c_void; pub type HRE...
#![feature(associated_type_defaults)] #![feature(min_type_alias_impl_trait)] #![allow(unused_imports)] #![allow(clippy::ptr_arg)] pub mod system { include!(concat!(env!("OUT_DIR"), "/system.rs")); }
use super::{operator, url}; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{Category, Example, PipelineData, Signature, Span, SyntaxShape, Value}; #[derive(Clone)] pub struct SubCommand; impl Command for SubCommand { fn name(&self) -> &str { "url path"...
//! Matrix-spec compliant server names. use crate::error::Error; /// A Matrix-spec compliant server name. /// /// It is discouraged to use this type directly – instead use one of the aliases ([`ServerName`](../type.ServerName.html) and /// [`ServerNameRef`](../type.ServerNameRef.html)) in the crate root. #[derive(Clo...
use super::*; use Result; use http::HttpClient; use requests::*; use types::*; use serde::{Deserialize, Serialize}; /// A telegram client using an HTTP client to send requests to the telegram /// bot API. pub struct HttpTelegramClient<T: HttpClient> { token: String, http_client: T, } impl<T: HttpClient> HttpT...
pub mod statemachine; pub mod linkedlist; pub mod algorithms;
use crate::{ import::*, Broadcast, node::NodeController, node::FromNode, node::NodeConfig, node::NodeStatus, proto::Meta, proto::Net, proto::Request, proto::Response, proto::PingPong, process::registry::ProcessRegistry, global::Global, global::Get, util::RpcMe...
fn check_password(p: i32) -> bool { let mut m = 10; let mut repeat_count = 1; let mut has_twins = false; let mut non_decreasing = true; for _ in 1..6 { let d1 = p % m / (m / 10); let d2 = p % (m * 10) / m; m *= 10; if d1 == d2 { repeat_count += 1; ...
use crate::commands::wallet::wallet_update; use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use clap::Clap; use ic_types::Principal; /// Authorize a wallet custodian. #[derive(Clap)] pub struct AuthorizeOpts { /// Principal of the custodian to authorize. custodian: String, } pub a...
use opencv::prelude::Vector; //pub mod cam; pub mod colors; pub mod contour; pub mod error; pub mod gui; pub mod imageio; pub mod mat; pub mod point; pub mod rect; pub mod videoio; pub mod prelude { pub use crate::gui::{MouseEvent, MouseEvents}; pub use crate::mat::convert_color::ConvertColor; pub use cra...
#[cfg(test)] mod test { #![allow(unused_imports)] //adds itetools methods and tooling to all iterators in scope use itertools::Itertools; #[test] fn test_step_by() { let v: i32 = (0..10).step_by(3).sum(); assert_eq!(18, v); } }
use ress::prelude::*; lazy_static! { pub static ref TOKENS: Vec<Token<&'static str>> = vec![ Token::Comment(Comment::new_multi_line( " this file contains all grammatical productions in ECMA-262 edition 5.1 ** * *" )), Token::Comment(Comment::new_html(" HTML-style comments...
use crate::{BoxFuture, Entity, Result}; pub trait Upsert<E: Entity>: Send + Sync { fn upsert<'a>(&'a self, k: &'a E::Key, v: &'a E) -> BoxFuture<'a, Result<()>>; } impl<E, PROVIDER> Upsert<E> for &PROVIDER where E: Entity + Sync, E::Key: Sync, PROVIDER: Upsert<E> + Send + Sync, { fn upsert<'a>(&'a...
//! Networking library for client/server multiplayer games. //! //! Sumi provides a high level API for building networked games. It is built on top of [tokio], //! and provides an async, futures-based API. //! //! [tokio]: https://tokio.rs/ extern crate bincode; extern crate byteorder; extern crate crc; extern crate f...
use std::process::Command; use std::env; const ASM_DIR: &str = "src/arch/x64"; const ASM_INCL_DIR: &str = "src/arch/x64/include"; #[cfg(not(target_arch = "x86_64"))] fn asm_file(file: &str, out_dir: &str) {} #[cfg(not(target_arch = "x86_64"))] fn asm(out_dir: &str) {} #[cfg(target_arch = "x86_64")] fn asm_file(file...
use std::error; use std::io; use std::io::BufRead; use crate::day; pub type BoxResult<T> = Result<T, Box<dyn error::Error>>; pub struct Day01 {} impl day::Day for Day01 { fn tag(&self) -> &str { "01" } fn part1(&self, input: &dyn Fn() -> Box<dyn io::Read>) { println!("{:?}", self.part1_impl(&mut *in...
//! # 61. 旋转链表 //! https://leetcode-cn.com/problems/rotate-list/ //!给定一个链表,旋转链表,将链表每个节点向右移动 k 个位置,其中 k 是非负数。 //! # 解题思路 //!算出链表的长度L,对k求模,获取新的右移位置,循环找到新的头结点,断链,把原始头拼到链表最后 // Definition for singly-linked list. #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNo...
//! A lightweight, self-contained s-expression parser and data format. //! Use `parse` to get an s-expression from its string representation, and the //! `Display` trait to serialize it, potentially by doing `sexp.to_string()`. //! //! **Atoms** is a basic S-expression parser. It parses strings and produces //! a tree ...
#![macro_use] #[cfg_attr(spi_v1, path = "v1.rs")] #[cfg_attr(spi_v2, path = "v2.rs")] #[cfg_attr(spi_v3, path = "v3.rs")] mod _version; use crate::{peripherals, rcc::RccPeripheral}; pub use _version::*; use crate::gpio::Pin; #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum Error { Framing, Crc,...
use chat_room::*; use std::collections::HashMap; pub struct Manager { rooms: HashMap<ChatRoomId, ChatRoom> } impl Manager { pub fn new() -> Manager { Manager { rooms: HashMap::new() } } pub fn create_or_find(&mut self, chat_room_id: ChatRoomId) -> &mut ChatRoom { ...
#[doc = "Register `RXF1A` reader"] pub type R = crate::R<RXF1A_SPEC>; #[doc = "Register `RXF1A` writer"] pub type W = crate::W<RXF1A_SPEC>; #[doc = "Field `F1AI` reader - Rx FIFO 1 acknowledge index After the Host has read a message or a sequence of messages from Rx FIFO 1 it has to write the buffer index of the last e...
// SPDX-FileCopyrightText: 2017-2022 Joonas Javanainen <joonas.javanainen@gmail.com> // // SPDX-License-Identifier: MIT use axum::{http::StatusCode, response::IntoResponse, routing::get_service, Router}; use std::net::SocketAddr; use tokio::io; use tower_http::services::ServeDir; #[tokio::main] async fn main() { ...
use alloc::arc::{Arc, Weak}; use alloc::boxed::Box; use collections::String; use collections::borrow::ToOwned; use core::cell::Cell; use core::mem::size_of; use core::ops::DerefMut; use core::{ptr, slice}; use arch::context::Context; use sync::{WaitMap, WaitQueue}; use system::error::{Error, Result, EFAULT, EINVAL...
// 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 // 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? // 注意:给定 n 是一个正整数。 // 示例 1: // 输入: 2 // 输出: 2 // 解释: 有两种方法可以爬到楼顶。 // 1. 1 阶 + 1 阶 // 2. 2 阶 // 示例 2: // 输入: 3 // 输出: 3 // 解释: 有三种方法可以爬到楼顶。 // 1. 1 阶 + 1 阶 + 1 阶 // 2. 1 阶 + 2 阶 // 3. 2 阶 + 1 阶 struct Solution{} impl Solution { pub fn clim...
use std::collections::HashSet; use std::error::Error; use std::io::{self, Read, Write}; use std::result; type Result<T> = result::Result<T, Box<Error>>; fn main() -> Result<()> { let mut input = String::new(); io::stdin().read_to_string(&mut input)?; let final_freq = one(&input)?; writeln!(io::stdout...
extern crate sync; use sync::{Arc, Mutex}; fn main() { let x1 = Arc::new(Mutex::new(0)); let y1 = Arc::new(Mutex::new(0)); let x2 = x1.clone(); let y2 = y1.clone(); spawn(proc() { for _ in range(0u, 100) { let i = x2.lock(); let j = y2.lock(); let _ = ...
use std::error::Error; #[derive(Debug)] pub struct World { blocks: Vec<Vec<bool>>, // access as blocks[y][x] width: usize, height: usize, user_x: f64, user_y: f64, user_angle: f64, } impl World { pub fn new(width: usize, height: usize) -> Self { Self { blocks: vec![vec!...
#![allow(non_snake_case)] #[macro_use] extern crate lazy_static; extern crate serde_json; extern crate vmtests; use serde_json::Value; use std::collections::HashMap; use vmtests::{load_tests, run_test}; lazy_static! { static ref TESTS: HashMap<String, Value> = load_tests("tests/vmPushDupSwapTest/"); } #[test] f...
//! An `Instruction` holds an `Operation`. //! //! An `instruction` gives location to an `Operation`. //! //! An `Instruction` is created automatically when calling various `Operation`-type functions //! over a `Block`, such as `Block::assign`. use il::*; use std::fmt; /// An `Instruction` represents location, and no...
use std::io::{Read, Write}; const PROJECT_NAME: &str = "ynab"; // XXX is this fixed? or is it specific to my account? const SPLIT_CATEGORY_ID: &str = "4f42d139-ded2-4782-b16e-e944868fbf62"; const SCHEMA: &str = include_str!("../data/schema.sql"); pub fn api_key() -> std::path::PathBuf { directories::ProjectDirs:...
// A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. // // Find the largest palindrome made from the product of two 3-digit numbers. fn main() { let mut max = 0; for i in 100..1000 { for j in 100..1000 { let...
use std::io; use dns_resolver::Resolver; use slings::runtime::Runtime; #[cfg(feature = "slings-runtime")] fn main() -> io::Result<()> { let runtime = Runtime::new()?; let resolver = Resolver::new(); runtime.block_on(async { let ips = resolver.lookup_host("baidu.com").await?; println!("ips...
use crate::dns::answer::Answer; use crate::dns::header::Header; use crate::dns::question::Question; pub struct Message { pub header: Header, pub questions: Vec<Question>, pub answers: Vec<Answer>, } impl Message { pub fn unpack(buffer: &[u8]) -> Message { let offset: usize = 0; let (...
// Copyright (c) 2020 kprotty // // 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 in wri...
use std::fs::read_to_string; fn main() { let input = read_to_string("d10-input").expect("something went wrong reading file"); let mut data: Vec<i32> = input.lines().map(|n| n.parse().unwrap()).collect(); data.sort_unstable(); let (ones, twos, threes) = data .windows(2) .fold((1, 0, 1), |(ones, twos, threes),...
/// An enum to represent all characters in the Kanbun block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum Kanbun { /// \u{3190}: '㆐' IdeographicAnnotationLinkingMark, /// \u{3191}: '㆑' IdeographicAnnotationReverseMark, /// \u{3192}: '㆒' IdeographicAnnotationOneMark, /// \u{31...
use universe::Universe; pub fn check_area(ch_area: (i32, i32), universe: &mut Universe){ let (area_old, area) = match universe.player{ Some(ref mut x) => { let old = x.area; x.area.0 += ch_area.0; x.area.1 += ch_area.1; let new = x.area; (old, new...
#[macro_export] macro_rules! image_assets { ($($texcoords_name:ident $name:ident: $sprite_type:ident [$texcoords:expr][$w:expr;$h:expr] $path:expr),+) => { pub struct Images { $( pub $name: ImageAsset, pub $texcoords_name: [Texcoords; $texcoords] // concat_idents!($name, _texco...
use crate::translations::translations::{ bytes_report_translation, packets_report_translation, recent_report_translation, }; use crate::Language; /// Enum representing the possible kinds of displayed relevant connections. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] #[allow(clippy::enum_variant_names)] pub e...
//! Type definitions for `<metal_geometric>`. //! //! All methods are already declared in `vek` for any `Vec`: //! - `cross` //! - `distance` //! - `distance_squared` //! - `dot` //! - `face_forward` (`faceforward`) //! - `magnitude` (`length`) //! - `magnitude_squared` (`length_squared`) //! - `normalize` //! - `refle...
use std::ops::Deref; use std::ptr; use winapi::um::{d3d11, d3dcommon}; use wio::com::ComPtr; pub type DeviceRaw = ComPtr<d3d11::ID3D11Device>; pub struct Device(DeviceRaw); pub type DeviceContextRaw = ComPtr<d3d11::ID3D11DeviceContext>; pub struct DeviceContext(DeviceContextRaw); impl Device { pub fn new() -> (D...
use std::io::Cursor; use crate::{Field, ParseError, ReadExt, WriteExt}; pub fn encode_inputdata(data: &[u8], w: &mut Vec<u8>) { let length = data.len(); assert!(length <= std::u8::MAX as usize); w.write_byte(length as u8); w.write_bytes(data); } pub fn decode_inputdata<'a>(cursor: &mut Cursor<&[u8]...
use client::*; use result::BestbuyResult; mod types; pub use self::types::*; #[derive(Serialize)] pub enum OfferSort { #[serde(rename = "totalPrice")] TotalPrice, #[serde(rename = "price")] Price, #[serde(rename = "productTitle")] ProductTitle, } use types::{Pagination, Sort}; pub type ListOffersSort =...
use super::cgmath; use super::cgmath::perspective; use super::cgmath::SquareMatrix; use super::cgmath::Matrix4; pub struct Camera { pub view_from_world: cgmath::Matrix4<f32>, pub proj_from_view: cgmath::Matrix4<f32>, pub position: cgmath::Point3<f32>, pub angle_yaw: f32, pub angle_pitch: f32 } im...
use std::time::SystemTime; fn main() { let time_now = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap(); println!("Finally the time stamp::{:?} ",time_now); }
//! All the traits exposed to be used in other custom pallets use crate::utils::keys::{Commitment, ScalarData}; use bulletproofs::PedersenGens; pub use frame_support::dispatch; use sp_std::vec::Vec; /// Tree trait definition to be used in other pallets pub trait Tree<AccountId, BlockNumber, TreeId> { /// Check if nu...
pub mod font; mod inline; pub mod text; use crate::cssom::{Unit, Value}; use crate::dom::NodeType; use crate::style::*; use font::{with_thread_local_font_context, FontContext}; use inline::InlineBox; use std::cell::RefCell; use std::mem; use std::rc::Rc; use text::{LineBreakLeafIter, TextNode, TextRun}; // CSS box mo...
//! The `server` module hosts all the server microservices. use bank::Bank; use crdt::{Crdt, ReplicatedData}; use ncp::Ncp; use packet; use rpu::Rpu; use std::io::Write; use std::net::UdpSocket; use std::sync::atomic::AtomicBool; use std::sync::{Arc, RwLock}; use std::thread::JoinHandle; use std::time::Duration; use s...
#![feature(associated_type_defaults)] pub mod error; pub mod value; pub mod domain; pub mod condition; pub mod expression; mod testproperty;
#[doc = "Register `GTZC1_TZSC_PRIVCFGR1` reader"] pub type R = crate::R<GTZC1_TZSC_PRIVCFGR1_SPEC>; #[doc = "Register `GTZC1_TZSC_PRIVCFGR1` writer"] pub type W = crate::W<GTZC1_TZSC_PRIVCFGR1_SPEC>; #[doc = "Field `TIM2PRIV` reader - privileged access mode for TIM2"] pub type TIM2PRIV_R = crate::BitReader; #[doc = "Fi...
use super::u512; // Constructors from standard integer types impl From<u128> for u512 { fn from(value: u128) -> u512 { return u512 { data: [value as u64, (value >> 64) as u64, 0, 0, 0, 0, 0, 0] }; } } impl From<u8> for u512 { fn from(value: u8) -> u512 { u512::from(value as u128) } } impl From<&...
use bindings::{ Windows::Data::Xml::Dom::XmlDocument, Windows::Foundation::TypedEventHandler, Windows::Win32::Foundation::{CloseHandle, HANDLE, HINSTANCE, MAX_PATH, PWSTR}, Windows::Win32::Security::{ GetTokenInformation, TokenElevation, TOKEN_ELEVATION, TOKEN_QUERY, TOKEN_ADJUST_PRIVILEGES, ...
pub mod test { pub struct xte { } }
use actix_web::{HttpRequest, HttpResponse}; use super::super::app::AppEnvironment; pub async fn dispatch_default_index(app: AppEnvironment, _: HttpRequest) -> HttpResponse { let output = format!( "<!DOCTYPE html> <html><head> <meta charset=\"utf-8\" /> <style type=\"text/css\"> table {{ border-collapse: c...
//! [Worldedit](https://github.com/EngineHub/WorldEdit) and [RedstoneTools](https://github.com/paulikauro/RedstoneTools) implementation mod schematic; use super::{Plot, PlotWorld}; use crate::blocks::{ Block, BlockEntity, BlockFace, BlockFacing, BlockPos, FlipDirection, RotateAmt, }; use crate::chat::{ChatCompone...
//! tests/health_check.rs use std::{net::TcpListener}; fn spawn_app() -> String { // let server = zero2prod::run("127.0.0.1:0").expect("Failed to bind address"); // let _ = tokio::spawn(server); let listener = TcpListener::bind("127.0.0.1:0").expect("Failed to bind random port"); // we retrieve the po...
use crate::{BoxFuture, Result}; pub trait AsyncTryFrom<'a, T>: Sized { fn async_try_from(t: T) -> BoxFuture<'a, Result<Self>>; }
use byteorder::{LittleEndian, WriteBytesExt}; use failure::{format_err, Error}; use crate::model::{owned::OwnedBuf, TableType}; mod configuration; mod entry; pub use self::{ configuration::ConfigurationBuf, entry::{ComplexEntry, Entry, EntryHeader, SimpleEntry}, }; #[derive(Debug)] pub struct TableTypeBuf {...
extern crate clap; #[macro_use] extern crate lazy_static; mod lexer; use clap::{App, Arg}; use lexer::Scanner; use std::fs::File; use std::io::prelude::*; use std::io::{self, Read}; fn main() { let matches = App::new("Lox") .version("0.1") .about("A programming language") .arg( ...
use std::io::Error; use std::net::{SocketAddr, ToSocketAddrs, TcpStream}; use std::time::{Duration, Instant}; use rayon::prelude::*; use sealpir::client::PirClient; use sealpir::PirReply; use raidpir::client::RaidPirClient; use raidpir::types::RaidPirData; use hybridpir::client::HybridPirClient; use hybridpir::types::...
// error-pattern:squirrelcupcake fn cmp() -> int { alt(option::some('a'), option::none::<char>) { (option::some(_), _) { fail "squirrelcupcake"; } (_, option::some(_)) { fail; } } } fn main() { log(error, cmp()); }
//! All the logic behind the editor UI is contained within this module. //! //! Fundamentally, the UI is split into graphics rendering and state management in response to //! input events, both of which are managed within the `EditorInterface` type. use std::sync::mpsc::Receiver; use vst_window::{EditorWindow, EventS...
mod common; use crate::common::{destroy, new, BitFlags as BF, Register, BASE_ADDR}; use embedded_hal_mock::i2c::Transaction as I2cTrans; use hdc20xx::MeasurementMode; #[test] fn can_create_and_destroy() { let sensor = new(&[]); destroy(sensor); } #[test] fn can_get_device_id() { let dev_id = 0xABCD; l...
mod yahoo; use clap::{App, Arg}; use colored::*; fn main() { let matches = App::new("Quoter") .about("Stock quotes on the CLI") .arg( Arg::with_name("symbols") .long("symbols") .short("s") .multiple(true) .takes_value(true)...
use imgui::{ImGuiStyle, ImVec2, ImVec4}; use rand::distributions::{IndependentSample, Range}; use rand; use std::fs::File; use std::io::Cursor; use std::io::Read; use show_message::UnwrapOrShow; const FILENAME: &str = "assets/config.ron"; lazy_static! { pub static ref CONFIG: Config = { let file = if cfg...
// 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 skulpin::skia_safe::*; use crate::ui::*; pub struct Button; pub struct ButtonColors { pub outline: Color, pub text: Color, pub hover: Color, pub pressed: Color, } #[derive(Clone, Copy)] pub struct ButtonArgs<'a> { pub height: f32, pub colors: &'a ButtonColors, } pub struct ButtonProcess...
mod gameplugin; pub use gameplugin::GamePlugin;
use serde::Deserialize; /// Basic structure of a Reddit response. /// See: https://github.com/reddit-archive/reddit/wiki/JSON #[derive(Deserialize, Debug)] pub struct BasicThing<T> { /// An identifier that specifies the type of object that this is. pub kind: String, /// The data contained by this struct. T...
$NetBSD: patch-vendor_rustc-ap-rustc__target_src_spec_mod.rs,v 1.1 2021/05/26 09:21:39 he Exp $ Add aarch64_be NetBSD target. --- vendor/rustc-ap-rustc_target/src/spec/mod.rs.orig 2021-03-23 16:54:53.000000000 +0000 +++ vendor/rustc-ap-rustc_target/src/spec/mod.rs @@ -695,6 +695,7 @@ supported_targets! { ("x86_6...
use std::fs::OpenOptions; use std::io::prelude::*; use std::error::Error; use std::sync::{Arc, Mutex}; #[derive(Clone)] pub struct Logger { out: Arc<Mutex<String>>, } impl Logger { pub fn log(&self, msg: &str, level: Level) -> Result<(), Box<dyn Error>> { let level = match level { Level::...
//! `git.rs` serves as a demonstration of how to use subcommands, //! as well as a demonstration of adding documentation to subcommands. //! Documentation can be added either through doc comments or //! `help`/`about` attributes. //! //! Running this example with --help prints this message: //! ------------------------...
use crate::errors::{ErrorKind, Result, ResultExt}; use crate::message::{ Message, MessagePacket, VerackMessage, PongMessage, PingMessage }; use async_std::{ prelude::*, }; use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender}; pub async fn start() { }
fn main() { if time::now().tm_wday == 2 { println!("cargo:rustc-cfg=tuesday"); } }
use clap::{crate_description, crate_version, App, AppSettings, Arg, SubCommand}; fn main() -> Result<(), rasar::Error> { let args = App::new("Rasar") .version(crate_version!()) .about(crate_description!()) .settings(&[ AppSettings::ArgRequiredElseHelp, AppSettings::VersionlessSubcommands, ]) .subcomma...
use crate::{components, components::player::PlayerType, config, resources, utils}; use amethyst::{ animation::AnimationSetPrefab, assets::{AssetStorage, Loader, PrefabData, PrefabLoader, ProgressCounter, RonFormat}, core::transform::Transform, derive::PrefabData, ecs::{Entity, Read, ReadExpect}, ...
fn main() { let s = { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim_end().to_owned() }; let mut count = 0; for c in s.chars() { if c == '1' { count = count + 1; } } println!("{}", count); }
use std::env; use regex::Regex; use std::io; use std::fs::File; use std::io::prelude::*; use std::path; // use std::io::Read; fn adjust_x(x:usize, big_r:f64) -> f64 { let _x = if x % 2 == 1 { // x is odd big_r * 2.5 }else{ big_r }; _x + x as f64 * 3.0 * big_r } fn adjust_y(y:usize, r:f64) -> f64 { ...
use std::collections::{VecDeque}; use crate::sudoku; use crate::sudoku::{Sudoku}; type CellCollection = [sudoku::Index; sudoku::SIZE as usize]; fn box_indexes(n : u32) -> CellCollection { let x0 = sudoku::ORDER * (n % sudoku::ORDER); let y0 = sudoku::ORDER * (n / sudoku::ORDER); let mut indexes : CellCo...
/** --- Day 1: Chronal Calibration --- "We've detected some temporal anomalies," one of Santa's Elves at the Temporal Anomaly Research and Detection Instrument Station tells you. She sounded pretty worried when she called you down here. "At 500-year intervals into the past, someone has been changing Santa's his...
use std::env; use std::fs::File; use std::io::{BufRead, BufReader}; use std::str::FromStr; use failure::{format_err, Error}; use regex::Regex; #[derive(Debug, Copy, Clone, PartialEq, Eq)] enum Opcode { Addr, Addi, Mulr, Muli, Banr, Bani, Borr, Bori, Setr, Seti, Gtir, Gt...