text
stringlengths
8
4.13M
// 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 { argh::FromArgs, failure::{format_err, Error}, fidl_fuchsia_session::{LauncherMarker, LauncherProxy, SessionConfiguration}, fuchsia_as...
use nalgebra::{Point2, Vector2}; use class::{ComponentClass, ComponentClassFactory, BackgroundAttributes}; use render::{Renderer}; use scripting::{ScriptRuntime}; use template::{Attributes, Color, EventHook}; use {EventSink, Error, ComponentAttributes, ComponentId}; /// A button component class, raises events on clic...
//! Noisey `Display` impls. use crate::ast::{Binop, Unop}; use crate::builtins::{Function, Variable}; use crate::cfg::{BasicBlock, Ident, PrimExpr, PrimStmt, PrimVal, Transition}; use crate::common::FileSpec; use crate::lexer; use std::fmt::{self, Display, Formatter}; use std::string::String; pub(crate) struct Wrap(pu...
struct S; // Concrete type `S` #[derive(Debug)] struct GenericVal<T>(T,); // Generic type `GenericVal` // impl of GenericVal where we explicitly specify type parameters: impl GenericVal<f32> {} // Specify `f32` impl GenericVal<S> {} // Specify `S` as defined above // `<T>` Must precede the type to remain generic imp...
#[cfg(not(feature = "lib"))] use std::{cell::RefCell, rc::Rc}; use std::collections::HashMap; use mold::Raster; #[cfg(not(feature = "lib"))] use crate::Context; use crate::styling::COMMANDS_LAYER_ID_MAX; #[derive(Debug)] pub struct Composition { #[cfg(not(feature = "lib"))] pub(crate) context: Rc<RefCell<Con...
pub fn run_demo() { let sentences = vec!["VADER is smart, handsome, and funny.", // positive sentence example "VADER is smart, handsome, and funny!", // punctuation emphasis handled correctly (sentiment intensity adjusted) "VADER is very sm...
use crate::{ geom::Vector, graphics::{ImageScaleStrategy, ResizeStrategy}, }; ///A builder that constructs a Window #[derive(Debug)] pub struct Settings { /// If the cursor should be visible over the application pub show_cursor: bool, /// The smallest size the user can resize the window t...
#[doc = "Reader of register CHMAP1"] pub type R = crate::R<u32, super::CHMAP1>; #[doc = "Writer for register CHMAP1"] pub type W = crate::W<u32, super::CHMAP1>; #[doc = "Register CHMAP1 `reset()`'s with value 0"] impl crate::ResetValue for super::CHMAP1 { type Type = u32; #[inline(always)] fn reset_value() ...
pub fn word_pattern(pattern: String, s: String) -> bool { use std::collections::HashMap; if pattern.len() != s.split_whitespace().count() { return false; } let pattern_word: HashMap<char, &str> = pattern.chars().zip(s.split_whitespace()).collect(); let word_pattern: HashMap<&str, char> = p...
//! Database elements for all tables #[cfg(feature="rusqlite")] use rusqlite::Row; #[cfg(feature="rusqlite")] use rusqlite::Result; use std::{mem, fmt}; use std::path::PathBuf; #[cfg(feature = "rusqlite")] use sha2::{Digest, Sha256}; #[cfg(feature = "hex-gossip")] use hex_gossip::PeerId; /// Peer id copy #[cfg(not...
pub use lapin_async::uri::*;
fn main() { println!("Hello, world!"); // Rust中的函数和变量名使用 snake case 规范风格 another_function(5, 6); let _y = 6; // statement // let x = (let y = 6); // let 语句不返回值,不能用来赋值给其他变量 // let y = 6; 中的 6 是一个表达式,它计算出的值是 6 // 函数调用是一个表达式,宏调用也是一个表达式, // 用来创建新作用域代码块的大括号 {},也是一个表达式 let y = { ...
#[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::SSCTL3 { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &...
use druid::{ text::{AttributesAdder, RichText, RichTextBuilder, TextStorage}, widget::prelude::*, Color, FontFamily, FontStyle, FontWeight, Point, Selector, TextLayout, }; use pulldown_cmark::{CodeBlockKind, Event as ParseEvent, Parser, Tag}; use syntect::{easy::HighlightLines, highlighting::Style, util::Li...
use rustler::types::atom::{ok, error}; use rustler::{Encoder, Env, NifResult, Term}; use std::{thread, time}; use rand::prelude::*; #[rustler::nif(schedule = "DirtyCpu")] fn do_work( env: Env ) -> NifResult<Term> { let thread = thread::Builder::new() .name("do_some_work".to_string()) .stack_s...
use proconio::input; use std::collections::HashMap; fn main() { input! { n: usize, }; let mut pes = Vec::new(); for _ in 0..n { input! { m: usize, pe: [(u32, u32); m], }; pes.push(pe); } let mut max_e = HashMap::new(); for pe in &pes...
#[cfg(all(not(target_arch = "wasm32"), test))] mod test; use liblumen_alloc::erts::exception; use liblumen_alloc::erts::process::alloc::TermAlloc; use liblumen_alloc::erts::process::Process; use liblumen_alloc::erts::term::prelude::*; #[native_implemented::function(erlang:tuple_to_list/1)] pub fn result(process: &Pro...
// Copyright 2017 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::sec_to_display; use ::amethyst::core::Time; use ::amethyst::ecs::{Read, System, Write}; /// Calculates in relative time using the internal engine clock. #[derive(Default, Serialize)] pub struct RelativeTimer { pub start: f64, pub current: f64, pub running: bool, } impl RelativeTimer { pub ...
/* Copyright 2020 Timo Saarinen 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 writing, software d...
#[cfg(test)] mod tests;
use sea_schema::migration::prelude::*; pub struct Migration; impl MigrationName for Migration { fn name(&self) -> &str { "m20220616_000001_create_peers_table" } } #[async_trait::async_trait] impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { ...
use std::path::Path; use std::env; mod image_rect; mod utils; pub enum SortKey{ Width, Height, Area, MaxDimension } fn main() { let path = env::args(); println!("path: {:?}", path.collect::<Vec<String>>()); let mut images = match image_rect::image::get_images(&Path::new("./img/.")){ ...
use std::io::Error; use std::io::Result; use std::io::ErrorKind::InvalidInput; use std::collections::HashMap; use irc::client::server::IrcServer; use irc::client::server::Server; use irc::client::prelude::ServerExt; pub struct CommandArg { pub required: bool, pub name: String, } impl CommandArg { pub fn new(name:...
use crate::{ database::Database, utils::{module_for_path, packages_path}, Exit, ProgramResult, }; use candy_frontend::{ast_to_hir::AstToHir, hir::CollectErrors}; use clap::{arg, Parser, ValueHint}; use std::path::PathBuf; use tracing::warn; /// Check a Candy program for obvious errors. /// /// This command...
use serde::{Deserialize, Serialize}; use crate::data::Position; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SaveData { pub position: Position, }
use ggez::{event, GameResult}; mod game_state; mod tetromino; use crate::tetromino::{GRID_CELL_SIZE, GRID_SIZE}; use game_state::*; const SCREEN_SIZE: (f32, f32) = ( (GRID_SIZE.0 as f32 + 6.5) * GRID_CELL_SIZE.0 as f32, GRID_SIZE.1 as f32 * GRID_CELL_SIZE.1 as f32, ); fn main() -> GameResult { let (ctx, ...
use serde::{Deserialize, Serialize}; use std::convert::TryFrom; use web3::types::{Bytes, Index, Transaction as Web3Transaction, H160, H256, U256, U64}; // source: https://github.com/tomusdrw/rust-web3/blob/9e80f896bb49605079202fa53b6dc1dfd2430c32/src/types/transaction.rs #[derive(Debug, Default, Clone, PartialEq, Dese...
use std::future::Future; use std::io; use std::sync::Arc; use futures_channel::mpsc; use futures_util::lock::{Mutex, MutexGuard}; use futures_util::{select, FutureExt as _, StreamExt as _}; use btknmle_input::event::DeviceEvent; use btknmle_input::event::Event as LibinputEvent; use btknmle_input::event::EventTrait as...
// 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 ...
#![feature(test)] #![warn(rust_2018_idioms)] extern crate test; #[macro_use] mod common; mod tokio { benchmark_suite!(runtime_tokio::Tokio); } mod tokio_current_thread { benchmark_suite!(runtime_tokio::TokioCurrentThread); }
// Copyright 2017 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 serde::{Deserialize, Serialize}; use crate::err; #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct ConanPackage { pub name: String, pub version: String, pub user: String, pub channel: String, } impl ConanPackage { pub fn new(reference: &str) -> err::Result<(Self)> { ...
use std::str::from_utf8; use std::io::Read; use byteorder::{ByteOrder, BigEndian}; use protobuf_iter::*; use blob::Blob; pub struct BlobReader<R> { read: R } impl<R: Read> BlobReader<R> { pub fn new(r: R) -> Self { BlobReader { read: r } } pub fn into_inner(self) -> R { ...
pub type DRendezvousSessionEvents = *mut ::core::ffi::c_void; pub type IRendezvousApplication = *mut ::core::ffi::c_void; pub type IRendezvousSession = *mut ::core::ffi::c_void; #[doc = "*Required features: `\"Win32_System_RemoteAssistance\"`*"] pub const DISPID_EVENT_ON_CONTEXT_DATA: u32 = 7u32; #[doc = "*Required fea...
//! A simple and fast random number generator. //! //! The implementation uses [Wyrand](https://github.com/wangyi-fudan/wyhash), a simple and fast //! generator but **not** cryptographically secure. //! //! # Examples //! //! Flip a coin: //! //! ``` //! if fastrand::bool() { //! println!("heads"); //! } else { //!...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IDisplayDeviceInterop(pub ::windows::core::IUn...
use gl; use nalgebra_glm::{Mat4, Vec2}; use std; use std::ffi::{CStr, CString}; pub struct Program { pub id: gl::types::GLuint, } impl Program { pub fn from_shaders(shaders: &[Shader]) -> Result<Program, String> { let program_id = unsafe { gl::CreateProgram() }; for shader in shaders { ...
use prettytable::Table; use prettytable::{cell, row}; use std::collections::HashMap; static NO_DATA_WARNING: &'static str = "No time track data found"; pub fn display(data: HashMap<String, u64>) { let output_rows = format(data); if output_rows.is_empty() { println!("{}", NO_DATA_WARNING); } else ...
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 // // Portions Copyright 2017 The Chromium OS Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the THIRD-PARTY file. //! Provides a wrappe...
use serde::Deserialize; #[derive(Deserialize, Debug)] struct Ip { origin: String } #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let client = reqwest::Client::builder() .build()?; let res = client .get("https://httpbin.org/ip") .send() .await?;...
use super::Square; pub const ALL_SQUARES: Square = Square(0); pub const UNDEFINED_SQUARE: Square = Square(0xFF); pub const A8: Square = Square(0); pub const B8: Square = Square(1); pub const C8: Square = Square(2); pub const D8: Square = Square(3); pub const E8: Square = Square(4); pub const F8: Square = Square(5); pu...
use proconio::input; fn main() { input! { mut x: i64, k: i64, }; for i in 0..k { let t = 10_i64.pow((i + 1) as u32); let (y1, y2) = (x / t * t, (x / t + 1) * t); if (y1 - x).abs() < (y2 - x).abs() { x = y1; } else { x = y2; } ...
use crate::models::event::Event; use crate::models::launch::Launch; pub trait Ctx: std::fmt::Display {} impl Ctx for str {} impl Ctx for String {} impl Ctx for i32 {} pub trait ResObject {} impl ResObject for Launch {} impl ResObject for Event {}
use crate::compiling::v1::assemble::prelude::*; /// Compile a continue expression. impl Assemble for ast::ExprContinue { fn assemble(&self, c: &mut Compiler<'_>, _: Needs) -> CompileResult<Asm> { let span = self.span(); log::trace!("ExprContinue => {:?}", c.source.source(span)); let curren...
//! The base collection of `Points` onto which Residue's //! can be broadcast. Beyond the creation of points (ie. //! using a Lattice or Poisson Disc generator) all transformations //! of the points belong in this module. use rand; use coord::Coord; /// A collection of points to broadcast residues onto. pub struct P...
use std::io::Read; pub fn build_dag_from_reader<R: Read>(reader: &mut R, ds:
use crate::Compat; use core::{ pin::Pin, task::{self, Poll}, }; use std::io; impl<T> tokio_io::AsyncRead for Compat<T> where T: futures_io::AsyncRead, { fn poll_read( self: Pin<&mut Self>, cx: &mut task::Context, buf: &mut [u8], ) -> Poll<io::Result<usize>> { futures...
module lamp: [ input :[on,off], output:[ligada,desligada,ring], t_signal:[], p_signal:[a,b], var:[], initially:[up(a),activate(rules)], on_exception:[], on#[a]===>[emit(ligada),up(b)], off#[a]===>[emit(ring),up(a)], on#[b]===>[emit(ring),up(b)], off#[b]===>[emit(desligada),up(a)] ].
//! Tests that failed at some point. mod fail0 { use utils::generated_file; define_ir! { struct set_a; type subset_a[subset_b reverse set_a]: set_a; trait set_b; struct subset_b: set_b; } generated_file!(fail0); }
fn fizz_buzz(n: i32) -> String { let mut word = String::new(); if n % 3 == 0 { word += "Fizz"; } if n % 5 == 0 { word += "Buzz"; } if word.len() == 0 { word = n.to_string(); } word } fn main() { for i in 1..=100 { println!("{}", fizz_buzz(i)); ...
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtCore/qsettings.h // dst-file: /src/core/qsettings.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin => // ...
// 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 std::{cell::RefCell, rc::Rc}; use crate::{context::ContextInner, spinel_sys::*}; #[derive(Debug)] pub(crate) struct RasterInner { context: Rc<Ref...
macro_rules! shared_impls { (pointer mod=$mod_:ident new_type=$tconst:ident[$($lt:lifetime),*][$($ty:ident),*] $(extra[$($ex_ty:ident),* $(,)* ])? $(where [ $($where_:tt)* ])? , original_type=$original:ident, ) => { mod $mod_{ use super::*; ...
mod persistance; use std::env; use persistance::persistance; fn main() { let arg: u128 = env::args().nth(1).and_then(|x| x.parse().ok()).expect("Missing positive integer as argument."); println!("Persistance for {} is {}", arg, persistance(arg)) }
//! Linux `statx`. use crate::fd::AsFd; use crate::fs::AtFlags; use crate::{backend, io, path}; pub use backend::fs::types::{Statx, StatxFlags, StatxTimestamp}; #[cfg(feature = "linux_4_11")] use backend::fs::syscalls::statx as _statx; #[cfg(not(feature = "linux_4_11"))] use compat::statx as _statx; /// `statx(dirf...
use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::render::BlendMode; use sdl2::pixels::Color; use setup; pub fn alpha_blend() { let basic_window_setup = setup::init("Alpha Blending", 640, 480); let mut events = basic_window_setup.sdl_context.event_pump().unwrap(); let mut renderer = basic_wi...
//! Provides functionality related to computing the Levenshtein edit distance //! metric. /// Compute the Levenshtein distance between `str1` and `str2`. /// /// #Parameters /// /// * `str1` - first string /// * `str2` - second string pub fn distance(str1: &[char], str2: &[char]) -> usize { let mut cost = 0; i...
// ignore-compare-mode-nll // revisions: base nll // [nll]compile-flags: -Zborrowck=mir #![feature(generic_associated_types)] pub trait X { type Y<'a> where Self: 'a; fn m(&self) -> Self::Y<'_>; } impl X for () { type Y<'a> = &'a (); fn m(&self) -> Self::Y<'_> { self } } fn f(x: &impl f...
use std::io::Cursor; use std::sync::Mutex; use sourcerenderer_bsp::PakFile; use crate::asset::asset_manager::{ AssetContainer, AssetFile, }; pub struct PakFileContainer { pakfile: Mutex<PakFile>, } impl PakFileContainer { pub fn new(pakfile: PakFile) -> Self { Self { pakfile: Mut...
extern crate rust_decimal; extern crate wasm_bindgen; mod util; use rust_decimal::prelude::*; use wasm_bindgen::prelude::*; fn format_currency_str (amount_str: Box<str>, decimal: &usize) -> String { let formatted = Decimal::from_str(&*amount_str).unwrap(); format!("{:.1$}", formatted, decimal) } fn format...
use bintree::Tree; use std::fmt; pub fn hbal_trees<T: fmt::Display + Copy>(h: usize, v: T) -> Vec<Tree<T>> { if h == 0 { vec![Tree::end()] } else if h == 1 { vec![Tree::leaf(v)] } else { let subtree1 = hbal_trees(h - 1, v); let subtree2 = hbal_trees(h - 2, v); let mu...
use std::fmt::Display; const TORQUE_START_THRESHOLD: u32 = 1000; #[derive(Debug)] pub enum Vehicle { Running, Stopped } fn move_vehicle<T, F>(rpm: T, torque_eq: F) -> Vehicle where F: Fn(T) -> u32, T: Display + Copy { let curr_torque = torque_eq(rpm); println!("Engine torque is: {}", rpm); let a...
pub use VkFormatFeatureFlags::*; #[repr(u32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VkFormatFeatureFlags { VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x0000_0001, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x0000_0002, VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 0x0000_0004, VK_FORMAT_FEATURE_UN...
#![feature(vec_remove_item)] use crate::objects::player::*; use crate::objects::exec::*; use crate::objects::node::*; use crate::objects::game_data::*; use crate::objects::action::*; use crate::objects::config::*; pub mod objects; pub mod game; mod generators { extern crate rand; extern crate heck; use ...
use adder::*; use adder::common; #[test] fn it_add_works() { assert_eq!(4, add_two(2)) } #[test] fn it_add_works2() { // 函数执行 common::common_test(); println!("你好, 集合测试中..."); assert_eq!(4, add_two(2)) }
/* ZVM Disassembler ================ Copyright (c) 2020 Dannii Willis MIT licenced https://github.com/curiousdannii/ifvms.js */ use bytes::Buf; use super::*; use super::opcodes::*; use super::Operand::*; // Disassemble one Z-Code instruction pub fn disassemble_instruction(state: &mut ZVMState) -> Instruction { ...
//! Compact binary representations of nucleic acid kmers pub type BitKmerSeq = u64; pub type BitKmer = (BitKmerSeq, u8); const NUC2BIT_LOOKUP: [Option<u8>; 256] = { let mut lookup = [None; 256]; lookup[b'A' as usize] = Some(0); lookup[b'C' as usize] = Some(1); lookup[b'G' as usize] = Some(2); look...
use assembler::Token; use instruction::Opcode; use nom::{alpha, digit}; use nom::types::CompleteStr; named!(pub opcode<CompleteStr, Token>, ws!( do_parse!( str: alpha >> ( Token::Op{code: Opcode::from(str)} ) ) ) ); mod tests { use super::...
use std::mem; #[derive(Clone, Debug)] pub struct UnionFind { root: Vec<usize>, size: Vec<usize>, } impl UnionFind { pub fn new(size: usize) -> Self { Self { root: (0..size).collect(), size: vec![0; size], } } // 指定した要素の根を返す(経路圧縮もする). pub fn root(&mut se...
/* * __ __ _ _ _ * | \/ | ___ ___ __ _| | (_)_ __ | | __ * | |\/| |/ _ \/ __|/ _` | | | | '_ \| |/ / * | | | | __/\__ \ (_| | |___| | | | | < * |_| |_|\___||___/\__,_|_____|_|_| |_|_|\_\ * * Copyright (c) 2017-2018, The MesaLink Authors. * All rights reserved. * *...
// 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. #![deny(warnings)] #![feature(async_await, await_macro, futures_api)] use std::borrow::Cow; use std::collections::HashMap; use std::fs; use std::os::unix:...
#[macro_use] extern crate log; use actix_web::{ error::{BlockingError, ResponseError}, Error as ActixError, HttpResponse, }; use derive_more::Display; use diesel::result::{DatabaseErrorKind, Error as DBError}; use r2d2::Error as PoolError; use serde::{Deserialize, Serialize}; #[derive(Debug, Display, PartialE...
use fileutil; use std::ascii::AsciiExt; use std::time::SystemTime; use std::collections::HashSet; fn reacts(c1: char, c2: char) -> bool { return c1.to_ascii_lowercase() == c2.to_ascii_lowercase() && c1 != c2; } fn react(chars: &Vec<char>) -> Vec<char> { let mut newchars: Vec<char> = Vec::with_capacity(chars.l...
use super::Compositor; use super::System; use openvr_sys::EVRApplicationType; use openvr_sys::EVRInitError; pub struct Api { pub system: System, pub compositor: Compositor, } impl Api { pub fn new() -> Self { Api::init(EVRApplicationType::EVRApplicationType_VRApplication_Scene); Api { ...
// 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 agre...
use bevy::{ app::AppExit, prelude::{ debug, App, AssetServer, Camera2dBundle, Color, Commands, Component, DefaultPlugins, Entity, EventReader, EventWriter, HorizontalAlign, ParallelSystemDescriptorCoercion, ParamSet, Query, Res, ResMut, SpriteBundle, Text as BevyText, Text2dBundle, TextA...
use input::Input; use input::evaluator::InputEvaluatorRef; use parser::{ Evaluator, Node }; // Maximum accumulator // // Examines a bunch of inputs and takes the // highest value. pub struct Maximum { inputs : Vec<Box<Input>>, } impl Maximum { pub fn create(inputs_v: Vec<Box<Input>>) -> Box<Input> { Box::ne...
#![allow(unused_mut)] #![allow(incomplete_features)] #![feature(generic_associated_types)] /* class Functor f where fmap :: (a -> b) -> F a -> F b */ trait Functor { type Unwrapped; type Wrapped<B>: Functor; fn map<F, B>(self, f: F) -> Self::Wrapped<B> where F: FnMut(Self::Unwrapped) -> B; } ...
use super::parse::{Command, Config}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::error::Error; use std::fmt::Display; use std::fs::File; use std::io::{Read, Write}; pub const LOGIN_API: &str = "/api/management/v1/useradm/auth/login"; pub const DEPLOY_API: &str = "/api/management/v1/dep...
//! Edit a `DataBase`. mod component; mod residue; use error::GrafenCliError; use ui::utils::{MenuResult, print_description, select_command}; use grafen::database::{write_database, DataBase}; use std::error::Error; pub fn user_menu(database: &mut DataBase) -> MenuResult { let path_backup = database.path.clone()...
use super::{HPAMap, Material}; pub type Materials = Vec<Vec<Material>>; pub type Visible = Vec<Vec<bool>>; #[derive(Debug)] pub struct Maze { pub width: usize, pub height: usize, pub data: Option<MazeData>, } impl Maze { pub fn new(width: usize, height: usize) -> Maze { Maze { width, height, data: Som...
use embedded_graphics::{ mono_font::{ascii::FONT_6X10, MonoFont}, pixelcolor::BinaryColor, }; use crate::themes::default::button::{ButtonStateColors, ButtonStyle}; pub struct PrimaryButtonInactive; pub struct PrimaryButtonIdle; pub struct PrimaryButtonHovered; pub struct PrimaryButtonPressed; impl ButtonStat...
use super::Diagnostic; use crate::util::{ attribute_arg, def_to_name, meta_into_nesteds, optional_attribute_arg, path_eq, ItemIdent, ItemMeta, ItemType, }; use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::{quote, quote_spanned, ToTokens}; use std::collections::HashMap; use syn::{ parse_quote...
//! Layout containers pub mod frame; pub mod linear;
use std::io; use std::io::Read; fn find_positions( tiles: &Vec<(Vec<Vec<char>>, Vec<Vec<u16>>)>, side_len: usize, used_orientations: &mut Vec<(usize, usize)>, ) -> bool { let row = used_orientations.len() / side_len; let col = used_orientations.len() % side_len; for (n, (_, tile)) in tiles.iter...
extern crate argparse; use std::process::Command; use std::os::unix::process::CommandExt; use argparse::{ArgumentParser, Store}; fn main() { let mut run = "".to_string(); let mut uid = "".to_string(); let mut gid = "".to_string(); { let mut ap = ArgumentParser::new(); ap.refer(&mut r...
// 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 ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - control register"] pub cr: CR, #[doc = "0x04 - software trigger register"] pub swtrigr: SWTRIGR, #[doc = "0x08 - channel1 12-bit right-aligned data holding register"] pub dhr12r1: DHR12R1, #[doc = "0x0c - DAC ch...
//! Encoding related code. //! //! You'll find two stuctures for configuration: //! * `EncodingConfig<E>`: For sinks without a default `Encoding`. //! * `EncodingConfigWithDefault<E: Default>`: For sinks that have a default `Encoding`. //! //! Your sink should define some `Encoding` enum that is used as the `E` par...
use std::error; use std::fmt; #[derive(Debug)] pub struct ErrorType1; impl error::Error for ErrorType1 { fn description(&self) -> &str { "Error 1!" } fn cause(&self) -> Option<&error::Error> { None } } impl fmt::Display for ErrorType1 { fn fmt(&self, f: &mut fmt::Formatter) -> Res...
use winapi::shared::windef::{HFONT, HBITMAP}; use winapi::ctypes::c_int; use winapi::um::winnt::HANDLE; use crate::resources::OemImage; use super::base_helper::{get_system_error, to_utf16}; #[allow(unused_imports)] use std::{ptr, mem}; #[allow(unused_imports)] use crate::NwgError; #[cfg(feature = "file-dialog")] use...
use scanner_proc_macro::insert_scanner; use std::collections::VecDeque; #[insert_scanner] fn main() { let n = scan!(usize); let (sy, sx) = scan!((usize, usize)); let (gy, gx) = scan!((usize, usize)); let a: Vec<Vec<char>> = (0..n) .map(|_| { let s = scan!(String); s.cha...
use structopt::StructOpt; use crate::auth_access_cmd::AuthAccessCmd; use crate::config_cmd::ConfigCmd; use crate::domain_cmd::DomainCmd; use crate::occurrence_cmd::OccurrenceCmd; use crate::stream_cmd::StreamCmd; use crate::stream_square_cmd::StreamSquareCmd; #[derive(Debug, StructOpt)] #[structopt(name = "Sidemash C...
#![allow(clippy::all)] #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(dead_code)] #![allow(deref_nullptr)] #![allow(unaligned_references)] include!(concat!(env!("OUT_DIR"), "/msfs-sys.rs")); // https://github.com/rustwasm/team/issues/291 extern "C" { pub fn nvg...
use super::{exception::Exception, value::Value, DynType}; pub enum ListItem { Middle(Value), Last(Value), End, } impl ListItem { pub fn to_middle(self) -> Result<Value, Exception> { match self { ListItem::Middle(value) => Ok(value), ListItem::Last(value) => Err(Exceptio...
use super::ifaces::LockIface; use std::fmt; use std::{ cell::UnsafeCell, sync::atomic::{spin_loop_hint, AtomicBool, Ordering}, }; use std::{ marker::PhantomData as marker, ops::{Deref, DerefMut}, thread::ThreadId, time::{Duration, Instant}, }; pub struct TTasGuard<'a, T: ?Sized> { mutex: &'...
use std::time::Duration; use libsystemd::daemon::{notify, NotifyState, watchdog_enabled}; use futures::prelude::*; #[cfg(feature = "tokio-core")] use tokio_core::reactor::{PollEvented, Handle}; #[cfg(feature = "tokio")] use tokio::reactor::{PollEvented2, Handle}; #[cfg(feature = "tokio")] use mio::Ready; use std::{io, ...
use crate::errors::ServiceError; use crate::models::msg::Msg; use crate::schema::order; use crate::utils::validator::Validate; use actix::Message; use actix_web::error; use actix_web::Error; use diesel; use uuid::Uuid; #[derive(Deserialize, Serialize, Debug, Message, Identifiable, AsChangeset)] #[rtype(result = "Res...
use serde::{Deserialize, Serialize}; #[repr(C)] #[derive(Serialize, Deserialize, Debug, Clone)] pub struct CodeImport { pub name: String, pub import: String, pub source: String, }