text
stringlengths
8
4.13M
/*! Miscellaneous utility code. */ use std::ffi::CString; use std::fs; use std::io; use std::mem::size_of; use std::path::{Path, PathBuf}; pub trait BoolUtil { fn as_either<T>(&self, if_true: T, if_false: T) -> T; } impl BoolUtil for bool { fn as_either<T>(&self, if_true: T, if_false: T) -> T { if *se...
// Copyright 2019, 2020 Wingchain // // 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...
#[doc = "Register `ESR` reader"] pub type R = crate::R<ESR_SPEC>; #[doc = "Field `BTE` reader - Bit timing error"] pub type BTE_R = crate::BitReader; #[doc = "Field `BPE` reader - Bit period error"] pub type BPE_R = crate::BitReader; #[doc = "Field `RBTFE` reader - Rx block transfer finished error"] pub type RBTFE_R = ...
use std::sync::Once; use gristmill::init_logging; use gristmill::asset::{Asset, AssetExt, AssetResult, AssetError, category, Resources, resource::AssetList}; // ------------------------------------------------------------------------------------------------- // Font objects more or less need a static lifetime. To la...
extern crate dmbc; extern crate exonum; extern crate exonum_testkit; extern crate hyper; extern crate iron; extern crate iron_test; extern crate mount; extern crate serde_json; pub mod dmbc_testkit; use dmbc_testkit::{DmbcTestApiBuilder, DmbcTestKitApi}; use exonum::crypto; use exonum::messages::Message; use hyper::s...
#[allow(unused_assignments, unused_mut, unused_variables)] pub const STD: &str = { let mut flags = ["-std=c++11", "/std:c++11"]; #[cfg(feature = "c++14")] (flags = ["-std=c++14", "/std:c++14"]); #[cfg(feature = "c++17")] (flags = ["-std=c++17", "/std:c++17"]); #[cfg(feature = "c++20")] (f...
use super::helpers::{ allocations, edits::invert_edit, edits::ReadRecorder, fixtures::{get_language, get_test_grammar, get_test_language}, }; use crate::{ generate::generate_parser_for_grammar, parse::{perform_edit, Edit}, }; use std::{ sync::atomic::{AtomicUsize, Ordering}, thread, time...
extern crate dialoguer; use dialoguer::{theme::ColorfulTheme, Checkboxes, Confirmation, Editor, Input}; use std::fs::File; use std::io::prelude::*; use std::{env, fmt}; #[derive(Debug)] struct Link { text: String, url: String, } #[derive(Debug)] struct Commands { deps: String, build: String, test...
impl Solution { pub fn xor_operation(n: i32, start: i32) -> i32 { let mut res = 0; for i in 0..n{ let num = start + 2 * i; res ^= num; } res } }
/// These sizes determine the maximum number of tables, columns and rows, /// but also have a big impact on memory and disk usage. /// Changing any of these is a backward-incompatible, breaking change. /// Table pointer size (>=1) //noinspection RsTypeAliasNaming pub type uTab = u16; /// Column pointer size within ta...
pub use self::array1::Array1; pub use self::array2::Array2; pub mod ops; mod array1; mod array2;
use super::*; use nom::character::complete::anychar; use nom::multi::many_till; pub fn control_character(input: LexInput) -> IResult<LexInput, char> { // parse out control character after slash return alt(( map(char_parse('n'), |_| '\n'), map(char_parse('\\'), |_| '\\'), anychar, ))...
// run with `cargo test -- --nocapture` for the logs #[cfg(test)] mod tests { use force_a2dp::parser; #[test] fn test_actual_card() { let txt = r#" 3 card(s) available. index: 13 name: <bluez_card.1A_11_11_1A_11_11> driver: <module-bluez5-device.c> ...
/// # Mutation Queries /// /// Designed to reduce boilerplate when updating tables. /// The query does nothing special, just calls the provided methods on the tables /// obtained by `unsafe_view::<key, value>()`. /// /// ## Safety /// /// Updates on Storage are an unsafe operation. Be sure that no other threads have wr...
//! # duo-m3u //! duoのm3uを`~/Downloads`に書き出し、オープンします。 //! ### usage //! ```bash //! $ duo-m3u [Disc01|Disc02|Disc03|Disc04|Disc05|review] [skip num] [take num] //! ``` use glob::glob; use std::env; use std::process::Command; use std::process; extern crate my_lib; /// make m3u file and open. fn main() { // args ...
extern crate futures; extern crate hyper; extern crate rust_tags; mod pages; use futures::future::Future; use hyper::{Method, StatusCode}; use hyper::header::ContentType; use hyper::mime; use hyper::server::{Http, Request, Response, Service}; use pages::*; struct JasonLongshore; impl Service for JasonLongshore { ...
#![feature(test)] extern crate test; extern crate bit_vec; use bit_vec::BitVec; use std::collections::HashSet; // See: https://users.rust-lang.org/t/integer-square-root-algorithm/13529/14 fn isqrt(x: usize) -> usize { let r = (x as f64).sqrt() as usize; if r <= 4096 { return r } (x/r + r)/2 } fn pi(x: f6...
use crate::level9::Computer; use std::collections::VecDeque; use std::collections::HashMap; use std::error::Error; #[derive(Clone)] struct State { computer: Computer, tick: i32, screen: HashMap<(i64,i64), i64>, paddle: (i64, i64), ball: (i64, i64) } impl State { fn draw(&self) { draw(&s...
use super::super::prelude::CCINT; // WinUser.h:3839 => #define CW_USEDEFAULT ((int)0x80000000) pub static UseDefault : CCINT = 0x80000000;
//! The core game engine is in this crate. pub mod block; pub mod entity; pub mod maths; pub mod resource; pub mod side; pub mod util; pub mod timing; pub mod vertexattrib;
#[derive(Default)] pub struct FlexArrayField<T>([T; 0]); pub trait FlexArray<T> { fn len(&self) -> usize; fn flex_element<'r>(&'r self) -> &'r FlexArrayField<T>; fn as_slice<'r>(&'r self) -> &'r [T] { use std::mem::transmute; unsafe { transmute::<&[T], _>(std::slice::from_raw_parts(transmute(self.flex_element...
use regex::Regex; use lazy_static::*; use crate::fraction::*; // This ensures the regexes are compiled only once lazy_static! { static ref MIXED_NUMBER_RE: Regex = Regex::new(r"^(\-?\d+)_(\d+/\d+)$").unwrap(); static ref NUMBER_RE: Regex = Regex::new(r"^(\-?\d+)$").unwrap(); } /// Parses the given expression ...
use std::time::Instant; use rand::distributions::{Distribution}; pub fn roll_dices (how_many_sixes_roll: i32) -> i32 { let mut rng = rand::thread_rng(); let die = rand::distributions::Uniform::from(1..7); let mut found = 0; let mut tries = 0; loop { tries += 1; let throw = die.samp...
use ethereum_types::{H160, U256}; use std::fmt::Display; use std::fmt::Formatter; #[derive(Debug, Default, Deserialize, Clone, PartialEq, Serialize, Hash, Eq, PartialOrd, Ord)] pub struct Transaction { /// Nonce pub nonce: U256, /// Gas Price pub gas_price: U256, /// Start Gas pub start_gas: U2...
#![no_std] pub use blake::{Blake224, Blake256, Blake28, Blake32, Blake384, Blake48, Blake512, Blake64}; pub use blake2::{Blake2b, Blake2s}; pub use edonr::{EdonR224, EdonR256, EdonR384, EdonR512}; pub use keccak::{ Keccak224, Keccak256, Keccak384, Keccak512, KeccakF1600, KeccakF200, KeccakF400, KeccakF800, }; pub ...
fn main(){ // a list of nos let v = vec![10,20,30]; print_vector(v); println!("{}",v[0]); // this line gives error } fn print_vector(x:Vec<i32>){ println!("Inside print_vector function {:?}",x); }
pub mod zmq;
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ use reqwest; use crate::apis::ResponseContent; use super::{Error, configuration}; /// struct for typ...
use core::MatrixArray; use core::dimension::{U2, U3}; use geometry::RotationBase; /// A D-dimensional rotation matrix. pub type Rotation<N, D> = RotationBase<N, D, MatrixArray<N, D, D>>; /// A 2-dimensional rotation matrix. pub type Rotation2<N> = Rotation<N, U2>; /// A 3-dimensional rotation matrix. pub type Rotat...
// This file is part of Substrate. // Copyright (C) 2019-2020 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 // // ht...
use crate::irust::IRustError; use crossterm::{style::Color, terminal::ClearType}; mod raw; use raw::Raw; use std::{cell::RefCell, rc::Rc}; #[derive(Debug, Clone)] pub struct Writer<W: std::io::Write> { last_color: Option<Color>, pub raw: Raw<W>, } impl<W: std::io::Write> Writer<W> { pub fn new(raw: Rc<Ref...
use crate::completions::{ file_completions::file_path_completion, Completer, CompletionOptions, SortBy, }; use nu_parser::{trim_quotes, FlatShape}; use nu_protocol::{ engine::{EngineState, StateWorkingSet}, Span, }; use reedline::Suggestion; use std::sync::Arc; pub struct CommandCompletion { engine_sta...
use aoc::*; use itertools::Itertools; fn main() -> Result<()> { let input = input("22.txt")?; println!("{}", solve2(&input, 119315717514047, 101741582076661, 2020)); Ok(()) } fn solve(techniques: &str, cards: i128, times: i128, position: i128) -> i128 { let mut offset: i128 = 0; let mut increment...
/* types.rs: Holds the types of the Abstract-Syntax-Tree(AST) named RlType, the parser and evaluator work with. It also defines the Error-type and a ReturnType that is needed for Error-handling. */ // load needed sibling-modules use crate::env::RlEnv; use crate::types::RlErr::ErrString; // load needed Rust-...
use super::*; #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] #[repr(transparent)] pub struct DisplayControl(u16); impl DisplayControl { const_new!(); bitfield_int!(u16; 0..=2: u16, display_mode, with_display_mode, set_display_mode); bitfield_bool!(u16; 4, display_frame1, with_display_frame1, set_display_f...
use core::cmp; use core::marker::PhantomData; use embassy::util::Unborrow; use embassy_extras::unborrow; use embedded_hal::blocking::i2c::Read; use embedded_hal::blocking::i2c::Write; use embedded_hal::blocking::i2c::WriteRead; use crate::i2c::{Error, Instance, SclPin, SdaPin}; use crate::pac::gpio::vals::{Afr, Moder,...
#![no_std] #![no_main] #![feature(trait_alias)] #![feature(min_type_alias_impl_trait)] #![feature(impl_trait_in_bindings)] #![feature(type_alias_impl_trait)] #[path = "../example_common.rs"] mod example_common; use embassy_stm32::gpio::{Level, Output, Input, Pull, NoPin}; use embedded_hal::digital::v2::{OutputPin, In...
//! Methods for handling malformed HTML input. //! //! Methods are used by [Parser](crate::html::parse::Parser). //! //! See [ParseOptionsBuilder](crate::html::parse::parse_options::ParseOptionsBuilder) //! for details on how to select these handlers. use log::log; #[cfg(test)] use mockall::automock; use super::{Par...
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. use crate::utils::{are_equal, EvaluationResult}; use winterfell::math::{fields::f128::BaseElement, FieldElement}; /// The number of round...
use std::net::TcpListener; use options::Options; use threadpool::ThreadPool; use handler::ConnectionHandler; pub struct WebServer { addr: String, pool: ThreadPool, } impl WebServer { pub fn new(options: Options) -> WebServer { WebServer { addr: options.addr, pool: ThreadPo...
use crate::part::Part; use std::fs::File; use std::io::{BufRead, BufReader}; fn part1(earliest: i64, ids: &[i64]) -> i64 { let (id, departure) = ids .iter() .map(|id| (id, id * (earliest / id + 1))) .min_by(|(_, t1), (_, t2)| t1.cmp(t2)) .unwrap(); id * (departure - earliest) }...
pub mod revision; use super::apparent_pk::ApparentPrimaryKey; use apllodb_storage_engine_interface::ColumnName; use revision::Revision; use serde::{Deserialize, Serialize}; /// Primary key with revision. /// Used for Immutable DML. #[derive(Clone, PartialEq, Hash, Debug, Serialize, Deserialize, new)] pub struct FullP...
use tide::Request; use crate::state::State; pub(crate) async fn health_check(_req: Request<State>) -> tide::Result { Ok("".into()) }
//! A thin wrapper over [`rustc_hash`] with some extra helper functions. #![deny(missing_debug_implementations, missing_docs, rust_2018_idioms)] use std::hash::{BuildHasherDefault, Hash}; pub use rustc_hash::{FxHashMap, FxHashSet, FxHasher}; /// Returns a map with the given capacity. pub fn map_with_capacity<K, V>(...
/* * Datadog API V1 Collection * * Collection of all Datadog Public endpoints. * * The version of the OpenAPI document: 1.0 * Contact: support@datadoghq.com * Generated by: https://openapi-generator.tech */ /// SyntheticsDeletedTest : Object containing a deleted Synthetic test ID with the associated deletion t...
// Copyright (c) 2016, <daggerbot@gmail.com> // This software is available under the terms of the zlib license. // See COPYING.md for more information. #![feature(try_from)] mod aurum { pub extern crate aurum_linear as linear; #[cfg(windows)] pub extern crate aurum_winutil as winutil; } #[cfg(all(unix, n...
use crate::Error; use rustbus::{message_builder::MarshalledMessage, MessageType}; use std::cell::Cell; use std::rc::Rc; pub(crate) const POWER: &'static str = "Setting power"; pub(crate) const DISCOVERABLE: &'static str = "Setting discoverable"; pub(crate) fn set_power_cb( res: MarshalledMessage, (powered, on,...
#[macro_use] extern crate text_io; extern crate chrono; pub mod advent1; pub mod advent2; pub mod advent3; pub mod advent4; pub mod advent5; pub mod advent6; pub mod advent7; pub mod advent8; pub mod advent9; pub mod advent10; pub mod advent11; fn main() { // advent1::advent1a(); // advent1::advent1b(); // a...
extern crate hyperltl; #[macro_use] extern crate pest_derive; pub mod app; pub mod automata; pub(crate) mod encoding; pub mod logic; pub mod specification;
//! Implements iterative deepening, aspiration windows, multi-PV, //! "searchmoves". mod aspiration; mod multipv; use self::multipv::Multipv; use std::thread; use std::time::Duration; use std::cell::RefCell; use std::sync::Arc; use std::sync::mpsc::{channel, Sender, Receiver, TryRecvError}; use regex::Regex; use uci:...
fn main() { // Ownership Rules // 1. Each value in Rust has a variable that's called its owner. // 2. There can only be one owner at a time // 3. When the owner goes out of scope, the value will be dropped // let s = "hello"; { let ss = "hello"; // ss is valid from this point forw...
use std::fs; use std::fs::File; use std::os::unix::ffi::OsStrExt; use std::path::Path; use std::path::PathBuf; use std::sync::Arc; use std::sync::Mutex; use std::thread; use std::time::Duration; use errno; use libc; use output::Output; use rand; use rand::Rng; use ::misc::*; #[ derive (Clone) ] pub struct AtomicF...
use crate::service::{error::PostgresManagementServiceError, PostgresManagementService}; use async_trait::async_trait; use drogue_cloud_admin_service::apps::{AdminService, MemberEntry, Members, TransferOwnership}; use drogue_cloud_database_common::{ auth::ensure_with, error::ServiceError, models::{ a...
use super::{operate, BytesArgument}; use nu_engine::CallExt; use nu_protocol::{ ast::{Call, CellPath}, engine::{Command, EngineState, Stack}, Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value, }; struct Arguments { pattern: Vec<u8>, end: bool, column_path...
mod health_check; pub use health_check::*;
use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; use std::collections::HashMap; fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::BufReader<File>>> where P: AsRef<Path>, { let file = File::open(filename)?; Ok(io::BufReader::new(file).lines()) } fn main() { let filename = "/ho...
use super::utility; // use std::cell::RefCell; // use std::collections::VecDeque; // use std::rc::Rc; use terminal_size::{terminal_size, Height, Width}; pub mod template_engine; pub mod text_processing; pub mod printer; pub mod components; #[derive(Debug)] pub struct TerminalSize { pub x: u16, pub y: u16, } imp...
use std::collections::HashMap; use crate::common::Op2; use crate::lambdal::{Expr, Imm, Op}; type Closure = HashMap<String, Value>; #[derive(PartialEq, Eq, Debug, Clone)] pub enum Value { VInt(i64), VBool(bool), VClosure(Box<Closure>, String, Box<Expr>), VIntArray(Vec<i64>), } fn vint(v: Value) -> i6...
/* chapter 4 syntax and semantics out-of-bounds access */ fn main() { let a = vec![1, 2, 3]; match a.get(7) { Some(b) => println!("item 7 is {}", b), None => println!("sorry, this vector is too short.") } } // output should be: /* sorry, this vector is too short. */
pub mod prelude; pub mod block; pub mod blockchain;
/* chapter 4 syntax and semantics */ struct Point<T> { x: T, y: T, } fn main() { let int_origin = Point { x: 1, y: 2 }; let float_origin = Point { x: 0.1, y: 0.2 }; match int_origin { Point { x, y } => println!("({},{})", x, y), } match float_origin { Point { x, ...
use std::os::raw::c_void; use std::path::Path; use gl; use image; use image::DynamicImage::*; use image::GenericImage; #[derive(Default)] pub struct Material { // TODO!! name: Option<String>, } unsafe fn texture_from_file(path: &str, directory: &str) -> u32 { let filename = format!("{}/{}", directory, pa...
use token::{Token, TokenType, bad_token, tokenize}; use std::collections::HashMap; use std::sync::Mutex; lazy_static! { static ref DEFINED: Mutex<HashMap<String, Vec<Token>>> = Mutex::new(HashMap::new()); } pub fn preprocess(tokens: Vec<Token>) -> Vec<Token> { use self::TokenType::*; let mut v: Vec<Toke...
//! # 188. 买卖股票的最佳时机 IV //! https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iv/ pub struct Solution; impl Solution { pub fn max_profit(k: i32, prices: Vec<i32>) -> i32 { if prices.is_empty() { return 0; } let k = k.min((prices.len() / 2) as i32); let (mu...
#[doc = "Register `LCCR` reader"] pub type R = crate::R<LCCR_SPEC>; #[doc = "Register `LCCR` writer"] pub type W = crate::W<LCCR_SPEC>; #[doc = "Field `CMDSIZE` reader - CMDSIZE"] pub type CMDSIZE_R = crate::FieldReader<u16>; #[doc = "Field `CMDSIZE` writer - CMDSIZE"] pub type CMDSIZE_W<'a, REG, const O: u8> = crate::...
use plotters::prelude::*; use stats::{mean, stddev}; use std::env; use std::fs::File; use std::io::BufReader; mod bench_data; fn main() -> Result<(), Box<dyn std::error::Error>> { let args: Vec<_> = env::args().collect(); let plot_type = &args[1]; let plot_file = &args[2]; if plot_type == "p" { ...
/// To check if the widget's label matches the given string. /// /// Example: /// /// ``` /// extern crate gtk; /// #[macro_use] /// extern crate gtk_test; /// /// use gtk::{Button, ButtonExt, LabelExt}; /// /// # fn main() { /// gtk::init().expect("GTK init failed"); /// let but = Button::new(); /// but.set_label("tex...
mod util; use std::io::BufRead; use util::error_exit; fn get_fuel(mass: i64) -> i64 { util::clip_min(mass / 3 - 2, 0) } fn get_fuel_recursive(mass: i64) -> i64 { let fuel = get_fuel(mass); match fuel { 0 => fuel, _ => fuel + get_fuel_recursive(fuel), } } fn main() { let solver = ...
use super::statement::Statement; #[derive(Debug, Clone)] pub struct Job { pub statements: Vec<Statement>, pub total_duration: u64, pub total_cpu_duration: u64, pub total_io_duration: u64, pub is_io_bound: bool, } impl Job { pub fn cpu_bound(total_duration: u64) -> Self { Self { ...
#[cfg(any(target_os = "android"))] use backtrace::Backtrace; #[cfg(any(target_os = "android"))] use log::trace; use sdl2::filesystem::pref_path; use sdl2::keyboard::Keycode; use sdl2::mouse::MouseButton; use sdl2::rwops::RWops; use shrev::EventChannel; use specs::prelude::*; use specs::World as SpecsWorld; #[cfg(any(t...
use bellman::multicore::Worker; use bellman::SynthesisError; use bellman::domain::{EvaluationDomain, Scalar}; use pairing::{Engine, Field}; use clear_on_drop::clear::Clear; pub fn add_polynomials<E: Engine>(a: &mut [E::Fr], b: &[E::Fr]) { assert_eq!(a.len(), b.len()); let worker = Worker::new(); worker.s...
// // Copyright 2019 The Project Oak Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law o...
fn hanoi(count: i32, current: i32, target: i32, other: i32) { if count == 0 { return; } hanoi(count-1, current, other, target); println!("{} -> {}", current, target); hanoi(count-1, other, target, current); } fn main() { hanoi(6, 1, 3, 2); }
use crate::sidebar::make_section; use crate::{ gui::{BuildContext, Ui, UiMessage, UiNode}, physics::Joint, scene::commands::{ physics::{ SetPrismaticJointAnchor1Command, SetPrismaticJointAnchor2Command, SetPrismaticJointAxis1Command, SetPrismaticJointAxis2Command, }, ...
impl Solution { pub fn total_hamming_distance(nums: Vec<i32>) -> i32 { let (mut res,n) = (0,nums.len() as i32); for i in 0..30{ let mut c = 0; for num in nums.iter(){ if num >> i & 1 == 0{ c += 1 } } ...
mod abort_transaction; mod aggregate; mod commit_transaction; mod count; mod count_documents; mod create; mod create_indexes; mod delete; mod distinct; mod drop_collection; mod drop_database; mod drop_indexes; mod find; mod find_and_modify; mod get_more; mod insert; mod list_collections; mod list_databases; mod list_in...
use crate::rtb_type_strict; rtb_type_strict! { CompanionAdRenderingMode, Concurrent=1; EndCard=2 }
// VIEWPORT pub const VIEWPORT_ZOOM_WHEEL_RATE: f64 = 1. / 600.; pub const VIEWPORT_ZOOM_MOUSE_RATE: f64 = 1. / 400.; pub const VIEWPORT_ZOOM_SCALE_MIN: f64 = 0.000_000_1; pub const VIEWPORT_ZOOM_SCALE_MAX: f64 = 10_000.; pub const VIEWPORT_ZOOM_LEVELS: [f64; 74] = [ 0.0001, 0.000125, 0.00016, 0.0002, 0.00025, 0.00032...
// Copyright 2019 Contributors to the Parsec project. // SPDX-License-Identifier: Apache-2.0 #![deny( nonstandard_style, const_err, dead_code, improper_ctypes, non_shorthand_field_patterns, no_mangle_generic_items, overflowing_literals, path_statements, patterns_in_fns_without_body,...
#[doc = "Reader of register INTR_USBHOST_SET"] pub type R = crate::R<u32, super::INTR_USBHOST_SET>; #[doc = "Writer for register INTR_USBHOST_SET"] pub type W = crate::W<u32, super::INTR_USBHOST_SET>; #[doc = "Register INTR_USBHOST_SET `reset()`'s with value 0"] impl crate::ResetValue for super::INTR_USBHOST_SET { ...
/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT license. */ #![allow(dead_code)] // Todo: Remove this when the disk index query code is complete. use crate::common::ANNError; use platform::{FileHandle, IOCompletionPort}; // The IOContext struct for disk I/O. One for each thr...
use clap::{App, AppSettings, Arg, SubCommand}; use std::io::Write; mod commands; use self::commands::*; pub const TANINDEX: &str = "/tmp/tantivy/idxhn"; fn main() { let cli_options = App::new("Tantivy Hackernews") .setting(AppSettings::SubcommandRequiredElseHelp) .version(env!("CARGO_PKG_VERSION")...
pub mod attributes; pub mod events; pub use attributes::Attributes; pub use events::Events; use super::component::Component; use super::component::Composable; /// viritual html element pub enum Html<Msg> { Composable(Box<dyn Composable>), TextNode(String), ElementNode { tag_name: String, ...
use assert_cmd::prelude::CommandCargoExt; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use kvs::KvsClient; use rand::distributions::Alphanumeric; use rand::prelude::*; use rand::Rng; use std::{ fmt, process::Command, sync::mpsc, thread, time::{Duration, Instant}, }; use ...
// This file is part of Substrate. // Copyright (C) 2018-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...
use super::super::{components, resources}; use specs::{Builder, World, WorldExt}; pub fn create_in(world: &mut World, pos: components::Position) -> specs::Entity { let ent = world .create_entity() .with(pos) .with(components::Sprite { fg_r: 255, fg_g: 64, ...
fn main(){ struct Home { name: String, rooms: i32, sold: bool, } let mut home1 = Home { name: String::from("myhome"), rooms: 13, sold: false, }; home1.sold = true; let mut home2 = Home { sold: false, ..home1 }; println!("sold = {}", home2.sold); println!("rooms = {}", home2.ro...
#![allow(dead_code)] use async_trait::async_trait; fn main() { println!("codecovsample::main"); } enum Covered { Variant1, Variant2, } enum Uncovered { Variant1, Variant2, } enum PartiallyCovered { Variant1, Variant2, } fn fn_covered_enum(input: Covered) { match input { Cover...
use std::collections::hash_map::{Entry, HashMap}; use pdb::FallibleIterator; fn setup<F>(func: F) where F: FnOnce(&pdb::SymbolTable<'_>, bool), { let (file, is_fixture) = if let Ok(filename) = std::env::var("PDB_FILE") { (std::fs::File::open(filename).expect("opening file"), false) } else { ...
#![no_std] #![no_main] extern crate kernel; use kernel::{Signal}; use kernel::graphics::*; use core::*; // use kernel::graphics; // use kernel::graphics::{Framebuffer}; // use core::{slice}; use core::sync::atomic::{AtomicBool,Ordering}; static SHOULD_QUIT: AtomicBool = AtomicBool::new(false); #[no_mangle] pub exter...
#[doc = "Register `SECCFGR2` reader"] pub type R = crate::R<SECCFGR2_SPEC>; #[doc = "Register `SECCFGR2` writer"] pub type W = crate::W<SECCFGR2_SPEC>; #[doc = "Field `SEC32` reader - SEC32"] pub type SEC32_R = crate::BitReader; #[doc = "Field `SEC32` writer - SEC32"] pub type SEC32_W<'a, REG, const O: u8> = crate::Bit...
use std::fmt; use std::fmt::{Display, Formatter}; use std::ops::SubAssign; use crate::utils::plural; #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub enum Resource { Wood, Stone, Ore, Clay, Glass, Loom, Papyrus, } impl Display for Resource { fn fmt(&self, f: &mut Formatter<'_>) -> fm...
mod canvas; mod conditional; mod editor; mod modal; mod named; mod painter; mod radio; pub mod notif_bar; pub use conditional::Conditional; pub use editor::{Editor, Tool, ToolCtx, ToolKind}; pub use modal::{Modal, ModalContainer}; pub use named::Named; pub use painter::Painter; pub use radio::RadioGroup;
pub struct SimpleLinkedList<T> { head: Link<T>, } type Link<T> = Option<Box<Node<T>>>; pub struct Node<T> { data: T, next: Link<T>, } impl<T> SimpleLinkedList<T> { pub fn new() -> Self { SimpleLinkedList { head: None } } pub fn len(&self) -> usize { let mut length = 0; ...
use anyhow::Result; use std::fmt; use std::fs::File; use std::fs::OpenOptions; use std::io::prelude::*; use std::mem; use std::os::unix::io::AsRawFd; use std::slice; pub struct DmaBuffer { name: String, size: usize, phys_addr: usize, buffer: *mut libc::c_void, sync_mode: bool, debug_vma: bool, ...
use std::collections::HashMap; pub fn test() { demo_vec(); demo_string(); } fn demo_vec() { demo_vec_access(); demo_vec_iteration(); demo_vec_enum(); } fn demo_vec_access() { let v = vec![1, 2, 3, 4, 5]; let _first = v.get(0); let _third: &i32 = &v[2]; let v_index = 2; matc...
/* * Copyright Stalwart Labs Ltd. See the COPYING * file at the top-level directory of this distribution. * * Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or * https://www.apache.org/licenses/LICENSE-2.0> or the MIT license * <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your * optio...
pub struct Parameters { pub bot_name: String, pub pro_chat_id: teloxide::types::ChatId, pub pro_chat_username: String, pub supapro_chat_id: teloxide::types::ChatId, pub supapro_chat_username: String, pub is_webhook_mode_enabled: bool, } impl Parameters { pub fn new() -> Self { let b...
use crate::*; use axum::http::Uri; use miette::Result; use uuid::Uuid; #[derive(Debug, Clone)] pub(crate) struct GithubConfig { pub(crate) app_id: u64, pub(crate) client_id: String, pub(crate) client_secret: String, } impl GithubConfig { #[instrument] pub(crate) fn from_env() -> Result<Self> { ...
// ClientConfig #![forbid(unsafe_code)] #![deny(missing_docs)] use super::{ ClientMode, Region, }; #[cfg(feature = "s3")] use super::ObjectVersions; /// Client configuration. #[derive(Debug)] pub struct ClientConfig { /// The bucket name that the client should report the size of. /// /// If this i...