text
stringlengths
8
4.13M
/// ValidatorSigningInfo defines a validator's signing info for monitoring their /// liveness activity. #[derive(Clone, PartialEq, ::prost::Message)] pub struct ValidatorSigningInfo { #[prost(string, tag = "1")] pub address: std::string::String, /// height at which validator was first a candidate OR was unj...
#[doc = "Reader of register COMP6_CSR"] pub type R = crate::R<u32, super::COMP6_CSR>; #[doc = "Writer for register COMP6_CSR"] pub type W = crate::W<u32, super::COMP6_CSR>; #[doc = "Register COMP6_CSR `reset()`'s with value 0"] impl crate::ResetValue for super::COMP6_CSR { type Type = u32; #[inline(always)] ...
use winapi::um::{ winuser::{WS_VISIBLE, WS_DISABLED, WS_GROUP, WS_TABSTOP}, wingdi::DeleteObject }; use winapi::shared::windef::HBRUSH; use crate::win32::window_helper as wh; use crate::win32::base_helper::check_hwnd; use crate::{Font, NwgError, RawEventHandler, unbind_raw_event_handler}; use super::{ControlBas...
test_stdout!( without_binary_returns_false, "false\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\nfalse\n" ); test_stdout!(with_binary_returns_true, "true\n");
use std::error::Error; use wayland_client::{ protocol::{wl_compositor::WlCompositor, wl_seat::WlSeat, wl_shm::WlShm}, Display, GlobalManager, }; use wayland_protocols::xdg_shell::client::xdg_wm_base; mod debug_callbacks; mod painter; mod seat; mod shared_memory; mod surface; mod buffer; fn main() -> Result<...
extern crate failure; #[macro_use] extern crate log; extern crate env_logger; extern crate dotenv; #[macro_use] extern crate clap; #[macro_use] extern crate serde_derive; extern crate toml; mod config; use std::path::Path; use failure::Error; use clap::{App, Arg, AppSettings, SubCommand}; use self::config::Config; c...
#[doc = "Reader of register DMAMUX_HWCFGR1"] pub type R = crate::R<u32, super::DMAMUX_HWCFGR1>; #[doc = "Reader of field `NUM_DMA_STREAMS`"] pub type NUM_DMA_STREAMS_R = crate::R<u8, u8>; #[doc = "Reader of field `NUM_DMA_PERIPH_REQ`"] pub type NUM_DMA_PERIPH_REQ_R = crate::R<u8, u8>; #[doc = "Reader of field `NUM_DMA_...
#[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::TPIO { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w...
use fileutil; use std::collections::HashMap; #[derive(Debug)] enum EventType { BeginShift(i32), FallAsleep(i32), WakeUp(i32) } #[derive(Debug)] struct Event<'a> { timestamp: &'a str, event_type: EventType } fn parse_line(line: &str) -> Event { let timestamp: &str = &line[1..17]; let mins:...
use std::borrow::{Borrow, BorrowMut}; fn main() { let mut vec0 = Vec::new(); let vec_0 = &mut vec0; let mut vec1 = fill_vec(vec_0 /*and put it here*/); // Do not change the following line! println!("{} has length {} content `{:?}`", "vec0", vec0.len(), vec0); vec1.push(88); println!("{...
extern crate core; use self::core::ptr; use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; use super::buffer::{Buffer, value_ptr}; use super::concurrent_queue::ConcurrentQueue; /// A bounded queue allowing a single producer and multiple consumers. pub struct SpmcConcurrentQueue<T> { buffer: Buff...
extern crate diesel; extern crate serde; extern crate serde_json; use serde_json::Value; pub mod datasource; pub mod deserializers; pub mod modules; pub mod nodes; pub mod operations; pub mod results; pub mod rules; pub mod schema; pub mod visitor; use decisionengine::datasource::DecisionDataset; use decisionengine:...
//! LEGO EV3 color sensor. use super::{Sensor, SensorPort}; use crate::{sensor_mode, Attribute, Device, Driver, Ev3Error, Ev3Result}; /// LEGO EV3 color sensor. #[derive(Debug, Clone, Device, Sensor)] pub struct ColorSensor { driver: Driver, } impl ColorSensor { fn new(driver: Driver) -> Self { Self ...
/* * Copyright 2020 Fluence Labs Limited * * 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 a...
use crate::error::Error; use crate::player::PlayerName; use serde::Serialize; #[derive(Serialize)] pub struct Response { #[serde(flatten)] resp: ResponseE, } impl Response { pub fn message(src: Option<PlayerName>, text: String) -> Self { Response { resp: ResponseE::Message { from: src,...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy, :: core :: fmt :: Debug, :: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] #[repr(transparent)] pub struct HCS_CALLBACK(pub is...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtWidgets/qmenu.h // dst-file: /src/widgets/qmenu.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin => // <=...
use crate::models::TodoList; use deadpool_postgres::Client; use std::io; use tokio_pg_mapper::FromTokioPostgresRow; pub async fn get_todos(db: &Client) -> Result<Vec<TodoList>, io::Error> { let stmt = db.prepare("SELECT * FROM todo_list").await.unwrap(); let todos = db .query(&stmt, &[]) .await...
/* * Copyright 2020 Google LLC * * 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 i...
//! [<img alt="github" src="https://img.shields.io/badge/github-udoprog/unicycle-8da0cb?style=for-the-badge&logo=github" height="20">](https://github.com/udoprog/unicycle) //! [<img alt="crates.io" src="https://img.shields.io/crates/v/unicycle.svg?style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates...
use chrono::prelude::*; use std::collections::HashSet; use std::hash::{Hash, Hasher}; #[derive(Hash, Debug, PartialEq)] struct MuseumNumber { value: u32, } #[derive(Debug)] struct Artifact { id: MuseumNumber, name: String, date: DateTime<Utc>, } impl PartialEq for Artifact { fn eq(&self, other: &...
//! Private module for selective re-export. use crate::actor::{Actor, Id, Network}; use crate::{Representative, Rewrite, RewritePlan}; use std::fmt::Debug; use std::hash::{Hash, Hasher}; use std::sync::Arc; use super::timers::Timers; /// Represents a snapshot in time for the entire actor system. pub struct ActorMode...
//! https://github.com/lumen/otp/tree/lumen/lib/snmp/src/app use super::*; test_compiles_lumen_otp!(snmp); test_compiles_lumen_otp!(snmp_app imports "lib/kernel/src/application", "lib/snmp/src/app/snmp_app_sup", "lib/kernel/src/error_logger", "lib/stdlib/src/lists"); test_compiles_lumen_otp!(snmp_app_sup); fn includ...
// 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 agreed to ...
use x86_64::{instructions::port::Port, structures::idt::InterruptStackFrame}; struct Driver { data_port: Port<u8>, status_command_port: Port<u8>, } impl Driver { const fn new() -> Self { Self { data_port: Port::new(0x60), status_command_port: Port::new(0x64), } } /// Follows the initialization sequenc...
use kv::Error as KVError; use magic_crypt::MagicCryptError as MagicError; use otp::Error as OTPStringError; use std::error::Error as StdError; use std::fmt::{ Display, Formatter, Result as FmtResult, }; use std::io::Error as IoError; use std::result::Result as StdResult; /// Error type of the Notp project....
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "Security_Cryptography_Certificates")] pub mod Certificates; #[cfg(feature = "Security_Cryptography_Core")] pub mod Core; #[cfg(feature = "Security_Cryptography_DataProtection...
use tokio::io::AsyncRead; // Import multer types. use multer::Multipart; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { // Generate an `AsyncRead` and the boundary from somewhere e.g. server request body. let (reader, boundary) = get_async_reader_from_somewhere().await; // Crea...
//! <https://github.com/EOSIO/eosio.cdt/blob/796ff8bee9a0fc864f665a0a4d018e0ff18ac383/libraries/eosiolib/contracts/eosio/producer_schedule.hpp#L54-L69> use crate::{AccountName, NumBytes, PublicKey, Read, Write}; use alloc::vec::Vec; /// Maps producer with its signing key, used for producer schedule /// <https://github...
use coi::{container, Inject}; #[derive(Inject)] #[coi(provides Impl1 with Impl1::new())] struct Impl1 { num: usize, } impl Impl1 { fn new() -> Self { Self { num: 0 } } } #[test] fn can_inject_struct_with_non_inject_non_arc_field() { let container = container! { impl1 => Impl1Provider,...
use rocket; use rocket_cors; use crate::connection; use crate::authorize; use crate::conditions; //use rocket::{Request, State, Data, Response}; use rocket::http::Method; //use rocket::{get, routes}; use rocket::routes; use rocket_cors::{AllowedHeaders, AllowedOrigins, Error}; pub fn create_routes() -> Result<(), Er...
// 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...
// 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 crate::ast; use crate::parsing::{LexerMode, ResolveError, ResolveErrorKind}; use crate::shared::Description; use crate::Spanned; use runestick::SpannedError; use thiserror::Error; error! { /// An error raised during parsing. #[derive(Debug, Clone)] pub struct ParseError { kind: ParseErrorKind,...
use procon_reader::ProconReader; fn main() { let stdin = std::io::stdin(); let mut rd = ProconReader::new(stdin.lock()); let a: f64 = rd.get(); let b: f64 = rd.get(); let ans = (a * b) / 100.0; println!("{}", ans); }
use crate::{ core::{ channel_list::{Channel, CHANNEL_HALF}, error::Error, frame_buffer::Slice, refptr::{OpaquePtr, Ref, RefMut}, }, deep::deep_image_level::{DeepImageLevelRef, DeepImageLevelRefMut}, }; use openexr_sys as sys; type Result<T, E = Error> = std::result::Result<T...
use config::Config; use errors::*; use clap::{App, Arg, ArgMatches, SubCommand}; pub fn setup<'a, 'b>() -> App<'a, 'b> { SubCommand::with_name("http") .about("Makes changes to the HTTP configuration") .arg( Arg::with_name("socket") .long("socket") .valu...
// 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. //! WatcherConnection handles interaction with directory watchers as described in io.fidl. use { fidl_fuchsia_io::{ WatchedEvent, MAX_FILENAME...
use std::collections::HashSet; pub fn anagrams_for<'a>(word: &'a str, possible_anagrams: &'a [&str]) -> HashSet<&'a str> { let sorted_word = sort_str(&word); let lowercased_word = word.to_lowercase(); possible_anagrams .iter() .filter(|x| word.len() == x.len() && ...
use chan; use clap::ArgMatches; use std::cmp; use std::convert::From; use std::fs::File; use std::io; use std::io::BufRead; use std::io::BufReader; use std::io::Read; use std::path::PathBuf; use std::thread; use tantivy; use tantivy::merge_policy::NoMergePolicy; use tantivy::Index; use time::PreciseTime; pub fn run_re...
use crate::engine::Result; use crate::thread_pool::ThreadPool; /// Using thre `ThreadPool` type from the [`rayon`](https://docs.rs/rayon/1.5.0/rayon/) crate. pub struct RayonThreadPool { pool: rayon::ThreadPool, } impl ThreadPool for RayonThreadPool { fn new(threads: u32) -> Result<Self> where Sel...
use std::collections::{HashMap, HashSet}; use std::env; use std::fs; use std::io::{self, BufReader, Write}; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::sync::OnceLock; use anyhow::bail; use cargo_metadata::{Message, MetadataCommand}; use clap::Args; use serde::Deserialize; use walkdir:...
use crate::fd::{AsFd, BorrowedFd}; use bitflags::bitflags; bitflags! { /// `POLL*` flags for use with [`poll`]. /// /// [`poll`]: crate::io::poll #[repr(transparent)] #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct PollFlags: u16 { /// `POLLIN` const IN = linux_raw...
use crate::net::MacAddr; use crate::packets::{CondRc, Header, Packet}; use crate::{Mbuf, Result, SizeOf}; use std::fmt; use std::ptr::NonNull; /* Ethernet Type II Frame +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Dst MAC | Src MAC |Typ| Payload | +-+-+-+-...
use super::diacritics; use geocoder_abbreviations::{Token, TokenType}; use neon::prelude::*; use regex::Regex; use std::collections::HashMap; #[derive(Debug, PartialEq, Clone)] pub struct Tokens { tokens: HashMap<String, ParsedToken>, regex_tokens: HashMap<String, ParsedToken>, multi_tokens: HashMap<String...
extern crate num; use num::complex::Complex64; extern crate piston_window; use piston_window::*; extern crate structopt; #[macro_use] extern crate structopt_derive; use structopt::StructOpt; extern crate image; use image::{LumaA, Rgba}; extern crate imageproc; use imageproc::drawing::draw_text_mut; extern crate ru...
pub static ERROR_COLOR: u32 = 0xff0033; pub static WARN_COLOR: u32 = 0xffe148; pub static SUCCESS_COLOR: u32 = 0x28a745;
use wabt; use wasmi::*; fn main() { let wasm_binary_import = wabt::wat2wasm( r#" (module (memory (import "env" "memory") 17) (func (export "get_first_i32") (result i32) (i32.load (i32.const 0)) ) ) "#, ) .expect("failed to...
use std::ops::{Index, IndexMut}; #[derive(Debug)] pub struct Registers { regs: [u8; 16], } pub enum Position { ///Second 4 bits (0X00) X, ///Third 4 bits (00Y0) Y, } impl Registers { pub fn new() -> Registers { Registers { regs: [0; 16] } } pub fn add_immed...
pub struct Solution; impl Solution { pub fn max_rotate_function(a: Vec<i32>) -> i32 { let n = a.len(); let mut x = 0; let mut y = 0; for i in 0..n { x += a[i]; y += (i as i32) * a[i]; } let mut max = y; let mut z = 0; for i in ...
use std::ffi::c_void; use std::ops::Deref; use std::sync::atomic::AtomicBool; use std::sync::Arc; use ash::extensions::khr; use ash::vk; use parking_lot::{ ReentrantMutex, ReentrantMutexGuard, }; use crate::queue::VkQueueInfo; use crate::raw::RawVkInstance; bitflags! { #[derive(Clone, Copy, Debug, PartialE...
use crate::FileDialog; use std::path::Path; use std::{ops::DerefMut, path::PathBuf}; use objc::{class, msg_send, sel, sel_impl}; use objc_id::Id; use super::super::utils::{INSURL, NSURL}; use objc::runtime::{Object, YES}; use objc::runtime::{BOOL, NO}; use objc_foundation::{INSArray, INSString, NSArray, NSString}; ...
use crate::plan::ir::TagSet; use crate::plan::var_ref::{field_type_to_var_ref_data_type, influx_type_to_var_ref_data_type}; use crate::plan::SchemaProvider; use influxdb_influxql_parser::expression::VarRefDataType; use schema::InfluxColumnType; use std::collections::HashMap; pub(crate) type FieldTypeMap = HashMap<Stri...
// Copyright (c) 2018-2022 Ministerio de Fomento // Instituto de Ciencias de la Construcción Eduardo Torroja (IETcc-CSIC) // 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 ...
//! Encode a BinJS, then decode it, ensure that we obtain the same AST. #[macro_use] extern crate bencher; extern crate binjs; extern crate env_logger; extern crate glob; extern crate itertools; use binjs::generic::*; use binjs::source::*; use itertools::Itertools; const PATHS: [&'static str; 1] = ["benches/test.js...
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 pub mod account; mod chain_state; pub mod common_transactions; mod gas; pub mod genesis; pub mod mock_vm; pub mod starcoin_vm; pub mod system_module_names; pub mod transaction_scripts; pub mod type_tag_parser;
pub use rand::random; use rand::Rng; /// Random number within an inclusive [min:max] range pub fn within(min: i32, max: i32) -> i32 { rand::thread_rng().gen_range(min, max + 1) } /// Return true with probability p pub fn chance(p: f32) -> bool { rand::thread_rng().next_f32() <= p } /// Choose a random value ...
use std::sync::Arc; use nalgebra::Vector3; use smallvec::SmallVec; use sourcerenderer_core::graphics::{ Backend, Barrier, BarrierAccess, BarrierSync, BarrierTextureRange, BindingFrequency, BufferInfo, BufferUsage, CommandBuffer, Device, MemoryUsage, Queue, Swapchain,...
//! Traits for types wrapped in `DynTrait<_>` use crate::std_types::RBoxError; #[allow(unused_imports)] use crate::type_level::{ bools::{False, True}, impl_enum::{Implementability, Implemented, Unimplemented}, trait_marker, }; macro_rules! declare_InterfaceType { ( $(#[$attrs:meta])* ...
// SPDX-License-Identifier: Apache-2.0 AND MIT //! `ConsumerBuilder` and `Consumer` structs use futures::stream::{Stream, StreamExt}; use std::pin::Pin; use std::task::{Context, Poll}; /// A [non-consuming] [Consumer] builder. /// /// [Consumer]: struct.Consumer.html /// [non-consuming]: https://doc.rust-lang.org/1.0....
// 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. #![recursion_limit = "512"] mod proxies; mod services; #[cfg(test)] mod test; use failure::Error; use fuchsia_async as fasync; use fuchsia_component::ser...
use std::vec; mod katapiller; mod random_polygon; mod random_polygonbox; mod poly_grid; mod grid; use super::util::{Point, Polygon}; use super::util; fn count_point_orcurences (pol: &Polygon) -> Vec<Vec<(usize,usize)>>{ let len = pol.points.len(); let mut edges_on_point: Vec<Vec<(usize,usize)>> = Vec::new()...
extern crate log; use leetcode_rust::init_logger; use log::*; struct Solution {} impl Solution { #[inline] fn get_row_col(n: usize) -> (usize, usize) { let row = n / 9; let col = n % 9; return (row, col); } fn check_num(c: char, n: usize, board: &mut Vec<Vec<char>>) -> bool {...
use crate::util::color; use crate::{config, err}; use anyhow::Result; use regex::Regex; use std::collections::HashMap; use std::fs::File; use std::path::Path; /// Render a template to its location given the replacement variables. fn render_template<P: AsRef<Path>, Q: AsRef<Path>>( template: P, render_to: Q, var...
// error-pattern:assigning to immutable obj field obj objy(x: int) { fn foo() { x = 5; } } fn main() { }
use std::io::{self, Read}; use std::str::{self, FromStr}; use bytes::Bytes; use thiserror::Error; use crate::object::{ Blob, Commit, ObjectData, ObjectHeader, ObjectKind, ParseBlobError, ParseCommitError, ParseTagError, ParseTreeError, Tag, Tree, }; use crate::parse::{self, Buffer, Parser}; #[derive(Debug, E...
//! State management for a selection in the grid. //! //! A selection should start when the mouse is clicked, and it should be //! finalized when the button is released. The selection should be cleared //! when text is added/removed/scrolled on the screen. The selection should //! also be cleared if the user clicks off...
use crate::get_txns_handler::GetTxnsHandler; use crate::helper::{ do_accumulator_node, do_get_block_by_hash, do_get_hash_by_number, do_state_node, }; use actix::prelude::*; use actix::{Actor, Addr, AsyncContext, Context, Handler}; use anyhow::Result; use bus::{BusActor, Subscription}; use chain::ChainActorRef; use ...
use ic_cdk::export::candid::export_service; use ic_cdk::{caller, trap}; use ic_cdk_macros::{init, query, update}; use ic_event_hub_macros::{ implement_add_event_listeners, implement_event_emitter, implement_get_event_listeners, implement_remove_event_listeners, }; use union_utils::log; use membership_token_cli...
use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{position_before_rarrow, snippet_opt}; use if_chain::if_chain; use rustc_ast::ast; use rustc_ast::visit::FnKind; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_lint_pass, declare_too...
// Copyright (c) 2020 Sam Blenny // SPDX-License-Identifier: Apache-2.0 OR MIT // #![forbid(unsafe_code)] //! Export v1 api names. The point of using re-exports is to allow for splitting //! the crate implementation into relatively small modules that are easy to //! refactor without breaking the public api. // Re-exp...
use criterion::{black_box, criterion_group, criterion_main, Criterion}; use day_04::{self, INPUT}; fn criterion_benchmark(c: &mut Criterion) { let pairs = day_04::parse_input(INPUT).unwrap(); c.bench_function("day_04::parse_input", |b| { b.iter(|| day_04::parse_input(black_box(INPUT))); }); c...
// Copyright 2019 CoreOS, Inc. // // 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...
use super::{InlineObject, InlineObjectTrait}; use crate::{ channel::ChannelId, heap::{object_heap::HeapObject, symbol_table::impl_ord_with_symbol_table_via_ord, Heap}, utils::{impl_debug_display_via_debugdisplay, DebugDisplay}, }; use candy_frontend::id::CountableId; use derive_more::Deref; use rustc_hash::...
pub mod node; pub mod pipeline; mod entity; mod graph; mod material; mod mesh; pub use entity::*; pub use graph::*; pub use material::*; pub use mesh::*; pub use node::*;
use cql_bindgen::CassIterator as _CassIterator; use cql_bindgen::cass_iterator_free; use cql_bindgen::cass_iterator_next; use cql_bindgen::cass_iterator_get_column; use cql_bindgen::CassRow as _CassRow; use cql_bindgen::cass_row_get_column; use cql_bindgen::cass_row_get_column_by_name; use cql_bindgen::cass_iterator_fr...
// Copyright (c) Calibra Research // SPDX-License-Identifier: Apache-2.0 use crate::Author; #[cfg(test)] #[path = "unit_tests/base_type_tests.rs"] mod base_type_tests; #[derive(Eq, PartialEq, Ord, PartialOrd, Copy, Clone, Hash, Debug)] pub struct EpochId(pub usize); // The following types are simplified for simulat...
use std::iter::FromIterator; use crate::{Alignment, AlignmentPositionIterator, AlignmentSequenceIterator}; impl<'a, T> Iterator for AlignmentPositionIterator<'a, T> where T: Clone, { type Item = Vec<&'a T>; fn next(&mut self) -> Option<Vec<&'a T>> { if self.index >= self.alignment.length { ...
use serde_derive::Deserialize; use std::collections::{hash_map::Entry, HashMap}; use std::process::exit; use super::{parse_to_config_file, ConfigStructure, Flattenable}; use crate::commands::{self, CommandKeybind, LllCommand}; use crate::KEYMAP_FILE; pub const ESCAPE: i32 = 0x1B; const fn default_up() -> i32 { n...
#[doc = "Reader of register OR"] pub type R = crate::R<u32, super::OR>; #[doc = "Writer for register OR"] pub type W = crate::W<u32, super::OR>; #[doc = "Register OR `reset()`'s with value 0"] impl crate::ResetValue for super::OR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { ...
// Copyright 2016 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 ...
// 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 ...
mod hash; pub use hash::Hash; use uint::construct_uint; construct_uint! { /// 256-bit unsigned integer. pub struct U256(4); }
use crate::Msg; use anyhow::{Context, Error}; use arcs::{ components::{Dimension, DrawingObject, Geometry, Layer, Name, PointStyle}, primitives::Point, render::{Renderer, Viewport}, Vector, }; use js_sys::Function; use kurbo::Size; use piet::Color; use piet_web::WebRenderContext; use specs::prelude::*; ...
use eyeliner::servo_embedder_traits::resources::{Resource, ResourceReaderMethods}; use std::{fs::File, io::Read, path::PathBuf}; pub struct ResourceReader { pub prefs: PathBuf, } impl ResourceReaderMethods for ResourceReader { fn sandbox_access_files(&self) -> Vec<PathBuf> { vec![] } fn sandbo...
use std::fmt; use crate::constants::*; #[derive(Debug, Clone, Copy, PartialEq)] pub struct Outcome { pub histogram: [u8; SIDES], } pub struct OutcomePredecessorIterator<'a> { outcome: &'a Outcome, next: usize, } pub struct OutcomeSuccessorIterator<'a> { outcome: &'a Outcome, next: usize, } impl...
use super::*; #[test] fn test_manhattan_distance() { let reference_point = Location::new(0, 0, 0); let good_cases: Vec<(Location, usize)> = vec![ (Location::new(0, 3, 0), 3), (Location::new(3, 0, 0), 3), (Location::new(-6, -6, 0), 12), (Location::new(-3, 6, 0), 9), ]; ...
use jsonrpc_core::IoHandler; use jsonrpc_http_server::{AccessControlAllowOrigin, DomainsValidation, ServerBuilder}; use tendermint_light_client::supervisor::Handle; use crate::error; pub use sealed::{Client, Rpc, Server}; /// Run the given [`Server`] on the given address and blocks until closed. /// /// n.b. The un...
use super::CtagsCommonArgs; use crate::app::Args; use crate::{send_response_from_cache, SendResponse}; use anyhow::Result; use clap::Parser; use filter::{FilterContext, SequentialSource}; use itertools::Itertools; use maple_core::process::ShellCommand; use maple_core::tools::ctags::{ProjectCtagsCommand, CTAGS_HAS_JSON_...
// Decoding metadata from a single crate's metadata import std::ebmlivec; import std::ivec; import std::option; import std::str; import std::ioivec; import std::map::hashmap; import syntax::ast; import front::attr; import middle::ty; import common::*; import tydecode::parse_def_id; import tydecode::parse_ty_data; impo...
fn main() { read::<u32>(); let arr: Vec<u32> = read_as_vec(); read::<u32>(); let keys: Vec<u32> = read_as_vec(); let mut result: u32 = 0; for key in keys { result += if search(&arr, key) { 1 } else { 0 }; } println!("{}", result); } fn search(arr: &[u32], key: u32) -> bool { ...
use zxcvbn::{zxcvbn, ZxcvbnError}; use crate::{InputType, InputValueError}; pub fn min_password_strength<T: AsRef<str> + InputType>( value: &T, min_score: u8, ) -> Result<(), InputValueError<T>> { match zxcvbn(value.as_ref(), &[]) { Ok(password_strength) => { if password_strength.score...
use std::fmt::Debug; trait DoSomething<T> { fn do_sth(&self, value: T); } impl<'a, T: Debug> DoSomething<T> for &'a usize { fn do_sth(&self, value: T) { println!("{:?}", value) } } fn foo(b: Box<dyn for<'f> DoSomething<&'f usize>>) { let s: usize = 10; b.do_sth(&s); } #[test] fn test_foo...
mod map_head; mod map_type; mod test; mod rlew_reader; mod map_builder; mod plane; mod map; extern crate byteorder;
/* Project Euler Problem 12: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ... Let us list the factors of the first seven triangle numbers: 1: 1 3: 1,...
use std::fs; use std::io; use std::io::Write as _; use std::process; fn main() -> io::Result<()> { let tokens = windows_macros::generate!( Windows::Win32::Audio::*, Windows::Win32::CoreAudio::*, Windows::Win32::Multimedia::{ WAVEFORMATEX, WAVEFORMATEXTENSIBLE, ...
// Copyright 2023 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 juniper::GraphQLObject; #[derive(GraphQLObject)] struct Obj {} fn main() {}
use serenity::framework::standard::macros::command; use serenity::framework::standard::CommandResult; use serenity::model::prelude::Message; use serenity::prelude::Context; #[command] #[required_permissions(ADMINISTRATOR)] async fn leave(ctx: &Context, msg: &Message) -> CommandResult { match msg.guild_id { ...
use std::borrow::BorrowMut; use std::mem::swap; use std::mem::replace; pub struct SequencedList<T> { length: usize, head: Link<T>, tail: Option<*mut Node<T>>, } type Link<T> = Option<Box<Node<T>>>; struct Node<T> { value: T, next: Link<T>, prev: Option<*mut Node<T>>, } pub struct Iter<'a, T:...