text
stringlengths
8
4.13M
// Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to ...
use anyhow::{anyhow, Context, Result}; use chrono::prelude::*; use chrono::{DateTime, Utc}; use mysql_async::prelude::*; use rand::Rng; use uuid::Uuid; pub async fn test_rw(opts: mysql_async::OptsBuilder, now: DateTime<Utc>) -> Result<String> { let mut conn = mysql_async::Conn::new(opts).await?; // create tab...
use std::io; use std::io::prelude::*; use std::collections::{HashMap, HashSet}; fn main() { let stdin = io::stdin(); let input = stdin.lock().lines().map(|line| line.unwrap()).collect::<Vec<String>>(); let mut orbits: HashMap<String, Vec<String>> = HashMap::new(); for line in input { let line:...
use std::{net::IpAddr, str::FromStr}; use crate::{InputType, InputValueError}; pub fn ip<T: AsRef<str> + InputType>(value: &T) -> Result<(), InputValueError<T>> { if IpAddr::from_str(value.as_ref()).is_ok() { Ok(()) } else { Err("invalid ip".into()) } } #[cfg(test)] mod tests { use su...
use text_grid::{Cell, CellSource, CellStyle, CellsFormatter, CellsSource, HorizontalAlignment}; #[test] fn impl_cell() { struct X(String); impl CellSource for X { fn fmt(&self, s: &mut String) { s.push_str(&self.0); } fn style(&self) -> CellStyle { Ce...
// 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 ...
macro_rules! future_err { ($e:expr) => { Box::new(futures::future::err($e)) }; } macro_rules! stream_err { ($e:expr) => { Box::new(futures::stream::once(Err($e))) }; } macro_rules! apikey_required { ($m:expr) => { if let crate::auth::Credentials::Token(_) = $m.credentials {...
use crate::{osm, LaneType}; use serde_derive::{Deserialize, Serialize}; use std::collections::BTreeMap; use std::iter; // (original direction, reversed direction) pub fn get_lane_types(osm_tags: &BTreeMap<String, String>) -> (Vec<LaneType>, Vec<LaneType>) { if let Some(s) = osm_tags.get(osm::SYNTHETIC_LANES) { ...
# ! [ doc = "Serial peripheral interface" ] # [ doc = r" Register block" ] # [ repr ( C ) ] pub struct Spi { # [ doc = "0x00 - control register 1" ] pub cr1: Cr1, # [ doc = "0x04 - control register 2" ] pub cr2: Cr2, # [ doc = "0x08 - status register" ] pub sr: Sr, # [ doc = "0x0c - data reg...
use crate::InputError; pub fn partition(input: &String) -> Result<std::collections::HashMap<String, usize>, InputError> { let mut row_range = [0, max_row_num()]; let mut column_range = [0, max_column_num()]; for instruction in input.chars() { let new_row_count = (row_range[1] - row_range[0] + 1) /...
use clap::{App, AppSettings, Arg, ArgMatches}; use rustpython_vm::Settings; use std::{env, str::FromStr}; pub enum RunMode { ScriptInteractive(Option<String>, bool), Command(String), Module(String), InstallPip(String), } pub fn opts_with_clap() -> (Settings, RunMode) { let app = App::new("RustPyth...
use gloo::timers::future::TimeoutFuture; use seed::browser::url::Url; use seed::{prelude::*, *}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use shared::lib::{prune_djs_without_queue, Input, Output, Playing, Room, Track, TrackArt, User}; mod pages; mod spotify; use pages::Page; use std::sync::...
#[macro_use] extern crate rental; pub struct Foo { i: i32, } impl Foo { fn try_borrow(&self) -> Result<&i32, ()> { Ok(&self.i) } fn fail_borrow(&self) -> Result<&i32, ()> { Err(()) } } pub struct FooRef<'i> { iref: &'i i32, misc: i32, } impl<'i> ::std::ops::Deref for FooRef<'i> { type Target = i32; fn der...
use crate::{Req}; pub fn run(reqs: Vec<Req>) { println!("doing requests"); }
use super::tree::{Node, NodeBox}; impl<T> Node<T> where Node<T>: From<T>, { pub fn boxer(data: T) -> NodeBox<T> { Some(Box::new(Self::from(data))) } } impl<T: Default + PartialOrd> From<T> for Node<T> { fn from(val: T) -> Self { Node::new(val) } }
// Translated from C++ to Rust. The original C++ code can be found at // https://github.com/jk-jeon/dragonbox and carries the following license: // // Copyright 2020-2021 Junekey Jeon // // The contents of this file may be used under the terms of // the Apache License v2.0 with LLVM Exceptions. // // (See accompanyi...
//! # WAL Inspect //! //! This crate builds on top of the WAL implementation to provide tools for //! inspecting individual segment files and translating them to human readable //! formats. #![deny(rustdoc::broken_intra_doc_links, rust_2018_idioms)] #![warn( clippy::clone_on_ref_ptr, clippy::dbg_macro, clip...
use crate::types::*; use crossbeam_channel::Sender; use jsonrpc_core::{self, Call, Error, Failure, Id, Output, Success, Value, Version}; use lsp_types::notification::Notification; use lsp_types::request::*; use lsp_types::*; use serde::Deserialize; use std::borrow::Cow; use std::collections::HashMap; use std::fs; // C...
#![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] //! # max-sys //! //! `max-sys` is a Rust FFI binding to the [Cycling 74](https://cycling74.com/) [Max SDK](https://github.com/Cycling74/max-sdk). //! It is automatically generated from the SDK source with [bindgen](https://git...
use std::collections::HashMap; use async_std::io::{Read, Write}; use crate::{Error, relay_chunked_stream, relay_sized_stream}; #[derive(Debug)] pub struct Relay { length: usize, length_limit: Option<usize>, } impl Relay { pub fn new() -> Self { Self { length: 0, length_lim...
extern crate bindgen; extern crate cfg_if; use bindgen::callbacks::{ EnumVariantCustomBehavior, EnumVariantValue, IntKind, MacroParsingBehavior, ParseCallbacks }; use std::fs::OpenOptions; use std::io::Write; use cfg_if::cfg_if; #[derive(Debug)] struct CustomCallbacks; impl ParseCallbacks for CustomCallbacks { fn...
pub mod handler; pub mod rover;
use std::collections::HashMap; use futures::prelude::*; use common::{Error, GiphyGif}; use crate::{Tx, PgPoolConn}; ////////////////////////////////////////////////////////////////////////////////////////////////// // FavoriteGif /////////////////////////////////////////////////////////////////////////////////// //...
//! Code generation for `ir::Variable`. use crate::codegen; use crate::ir; use crate::search_space::*; use fxhash::FxHashMap; use indexmap::IndexMap; use utils::*; /// Wraps an `ir::Variable` to expose specified decisions. pub struct Variable<'a> { variable: &'a ir::Variable, t: ir::Type, instantiation_dim...
#[macro_use] extern crate bitflags; extern crate regex; extern crate num_derive; mod str_utils; mod magic; mod magic_param; mod parse_magic_line; mod parse_magic_aux_line; mod parse_magic_entry; use std::path::Path; // use clap::{App, Arg}; fn load_one_magic(magic_file: &Path) { // init magic_set (magic_open -> ...
// Copyright 2019 MaidSafe.net limited. // // This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT // http://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD // https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied, // modified, or di...
pub mod loaders{ use assimp::Importer; use glium::index::PrimitiveType; use crate::my_game_engine::my_game_logic::my_renderer::{MyArmatureSkinVertex,VertexWeights,MyJoint,ModelRst,MyVertex,StaticMesh,AnimatedMesh}; use cgmath::Matrix3; use cgmath::Quaternion; pub fn load_texture(display:&mu...
use crate::Counter; use num_traits::Zero; use std::hash::Hash; use std::ops::{BitAnd, BitAndAssign}; impl<T, N> BitAnd for Counter<T, N> where T: Hash + Eq, N: Ord + Zero, { type Output = Counter<T, N>; /// Returns the intersection of `self` and `rhs` as a new `Counter`. /// /// `out = c & d...
pub fn reply(input: &'static str) -> &'static str { if input.is_empty() { "Fine. Be that way!" } else if is_shout(input) { "Whoa, chill out!" } else if is_question(input) { "Sure." } else { "Whatever." } } fn is_shout(input: &'static str) -> bool { input.to_uppe...
use aoc2018::*; use std::ops; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct Pos { x: i64, y: i64, } impl Pos { pub fn new(x: i64, y: i64) -> Pos { Pos { x, y } } pub fn neighbours(&self) -> [Pos; 8] { let Pos { x, y } = *self; [ ...
// 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 ...
//! Reader-based compression/decompression streams use std::io::prelude::*; use std::io::{self, BufReader}; use bufread; use super::CompressParams; /// A compression stream which wraps an uncompressed stream of data. Compressed /// data will be read from the stream. pub struct BrotliEncoder<R: Read> { inner: bu...
use crate::key::TypedKey; use crate::DataStore; use crate::{cache, dir, file, filter}; use itertools::Itertools; use std::collections::{HashMap, HashSet}; use std::path::PathBuf; use thiserror::Error; #[derive(Debug)] pub enum DiffTarget { FileSystem(PathBuf, Vec<String>, PathBuf), Database(TypedKey<dir::FSIte...
//! SputnikVM implementation, traits and structs. //! //! SputnikVM works on two different levels. It handles: //! 1. a transaction, or //! 2. an Ethereum execution context. //! //! To interact with the virtual machine, you usually only need to //! work with [VM](trait.VM.html) methods. //! //! ### A SputnikVM's Lifecy...
use super::session::UserSession; use crate::auth::session::get_cookie_from_header; use crate::init::AppConnections; use async_session::SessionStore; use axum::{ extract::Extension, http::{self, HeaderMap, HeaderValue, StatusCode}, response::IntoResponse, }; use tracing::info; pub async fn login(user_sessio...
use proptest::arbitrary::any; use proptest::prop_assert_eq; use proptest::strategy::{Just, Strategy}; use liblumen_alloc::erts::term::prelude::*; use crate::erlang::list_to_existing_atom_1::result; use crate::test::strategy; #[test] fn without_list_errors_badarg() { run!( |arc_process| strategy::term::is...
use std::{cell::RefCell, rc::Rc}; use crate::graphics::{Circle, Drawable, Font, Text}; use crate::gui::UiElement; use crate::State; use gl_bindings::{AbstractContext, Context}; use na::{Isometry3, Matrix4, Point3, Translation3, Vector3, Vector4}; use std::f32; struct WorldPoint { text: Text<'static>, dot: Ci...
#[doc = "Reader of register SDMMC_IDMACTRLR"] pub type R = crate::R<u32, super::SDMMC_IDMACTRLR>; #[doc = "Writer for register SDMMC_IDMACTRLR"] pub type W = crate::W<u32, super::SDMMC_IDMACTRLR>; #[doc = "Register SDMMC_IDMACTRLR `reset()`'s with value 0"] impl crate::ResetValue for super::SDMMC_IDMACTRLR { type T...
use assembler::directive_parsers::*; use assembler::label_parsers::*; use assembler::opcode_parsers::*; use assembler::operand_parsers::*; use assembler::register_parsers::*; use assembler::SymbolTable; use assembler::Token; use nom::multispace; use nom::types::CompleteStr; #[derive(Debug, PartialEq)] pub struct Assem...
use proconio::{input, marker::Chars}; fn main() { input! { n: usize, a: [Chars; n], }; let mut b = a.clone(); for j in 1..n { b[0][j] = a[0][j - 1]; } for i in 1..n { b[i - 1][0] = a[i][0]; } for j in 0..(n - 1) { b[n - 1][j] = a[n - 1][j + 1]; ...
use duct::cmd; use rand::prelude::*; use std::env::consts::EXE_EXTENSION; use std::fs; use std::path::{Path, PathBuf}; use std::sync::Once; use tempfile::tempdir; pub fn bao_exe() -> PathBuf { // `cargo test` doesn't automatically run `cargo build`, so we do that ourselves. static CARGO_BUILD_ONCE: Once = Once...
#![windows_subsystem = "windows"] extern crate azul; use azul::prelude::*; struct OpenGlAppState { } impl Layout for OpenGlAppState { fn layout(&self, _info: LayoutInfo<Self>) -> Dom<Self> { // See below for the meaning of StackCheckedPointer::new(self) Dom::new( NodeType::GlTexture(...
// Various ways to dereference a Box. use std::ops::DerefMut; struct Foo { field: Box<ToString> } fn use_foo(f: &mut Foo) -> String { // Doesn't work: // my_method(*field) // Works: my_method(&mut *f.field) // Works, but needs `use`: // my_method(f.field.deref_mut()) } fn my_method(x: ...
use chrono::prelude::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use std::convert::Into; use uuid::Uuid; #[derive(Debug, Serialize, Deserialize)] pub struct Point { pub ts: DateTime<Utc>, pub value: f64, pub trace_id: Uuid, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct SlimPoint {...
use std::io::BufReader; use std::fs::File; use std::io::prelude::*; fn main() { let f = File::open("inputs/day02.in").unwrap(); let file = BufReader::new(&f); let (paper, ribbon) = file .lines() .map(|l| -> Vec<u32> { let mut x: Vec<_> = l. unwrap(). ...
use crate::mysql::protocol::{Capabilities, Encode}; // https://dev.mysql.com/doc/internals/en/com-quit.html #[derive(Debug)] pub struct Quit; impl Encode for Quit { fn encode(&self, buf: &mut Vec<u8>, _: Capabilities) { buf.push(0x01); // COM_QUIT } }
/// For compiling Javascript values pub mod compiler; /// For executing the compiled Javascript values pub mod executor;
//! This module provides an easy and safe way to interact with attributes of [Elements](../struct.Element.html) //! //! # Note //! In the [crate::prelude](../prelude/index.html) the name for //! [Attribute](enum.Attribute.html) is [Attr](../prelude/index.html) and for //! [AttributeValue](enum.AttributeValue.html) is [...
fn main() { // chapter 1 let (x,y) = (1,2); let mut z: char = 'c'; //char are 4 bytes z = 's'; println!("{} plus {} equals {}", x, y, x+y); println!("{}", z); println!("{}", add(y)); println!("y after the function {}", y); // chapter 3 let y: bool = false; let a = [ 1, 2, 3]; let a = [ 0; 20]; //initia...
/* todo!() //trait to give a more dsl feel pub trait KotlinUtils: Sized { #[inline] fn also<F: Fn(&Self)>(self, f: F) -> Self { f(&self); self } #[inline] fn run<F: Fn(&Self) -> R, R>(&self, block: F) -> R { block(self) } #[inline] fn run_owned<F: Fn(Self) -> R, ...
use std::{collections::HashMap, hash::Hash}; #[derive(Debug)] pub struct Graph<T, E, ID: Hash + Eq> { pub data: HashMap<ID, (T, Vec<ID>)>, pub edges: HashMap<ID, (E, ID, ID)>, } impl<T, E, ID: Clone + Hash + Eq> Graph<T, E, ID> { pub fn new() -> Self { Graph { data: HashMap::new(), ...
///There is no public API calls located in the strategy module. This module contains the /// implementation details for an Order and Chaos AI. extern crate rayon; use crate::board::{BoardDirection, Game, GameStatus, Move, MoveType, Player, Strategy}; use rand::seq::SliceRandom; use rayon::prelude::*; use std::f64::INFI...
fn main() { let mut user1 = User { email: String::from("someone@example.com"), username: String::from("someusername123"), active: true, sign_in_count: 1, }; user1.email = String::from("anotheremail@example.com"); let mut user2 = build_user(String::from("someemail@intene...
use super::LifetimeIndex; use std::fmt::{self, Debug}; /// A set of lifetime indices. pub(crate) struct LifetimeCounters { set: Vec<u8>, } const MASK: u8 = 0b11; const MAX_VAL: u8 = 3; impl LifetimeCounters { pub fn new() -> Self { Self { set: Vec::new() } } /// Increments the counter for th...
/* * 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...
pub const INTERSECTION_EPSILON: f64 = 0.00001;
/// du -h . --max-depth=0 /// // use std::process::Command; use std::fs; use std::path::Path; use std::process::Command; use std::io::{self, Write}; fn main() { if let Ok(files) = get_files("/home/susilo/var/Rust") { for file in files { let path_name = format!("{}/Cargo.toml", &file)...
#![allow(dead_code)] use std::io; use std::slice; use std::str; use crate::other; // Keywords for PAX extended header records. pub const PAX_NONE: &str = ""; // Indicates that no PAX key is suitable pub const PAX_PATH: &str = "path"; pub const PAX_LINKPATH: &str = "linkpath"; pub const PAX_SIZE: &str = "size"; pub co...
extern crate sdl2; use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::render::TextureCreator; use sdl2::ttf::Font; use sdl2::video::WindowContext; use crate::common::make_title_texture; use crate::sdl_main::{SCR_WIDTH}; use self::sdl2::render::{Canvas, Texture}; use self::sdl2::video::Window; pub(crate) struc...
extern crate pine; // use pine::error::PineError; use pine::ast::input::*; use pine::ast::name::*; use pine::ast::stat_expr_types::*; use pine::ast::string::*; const TEXT_WITH_COMMENT: &str = "//@version=4 study(\"Test\") // This line is a comment a = close // This is also a comment plot(a) "; #[test] fn comment_test...
use binary_search_range::BinarySearchRange; use proconio::input; fn main() { input! { n: usize, q: usize, mut a: [u64; n], xs: [u64; q], }; a.sort(); let mut cum_sum = vec![0; n + 1]; for i in 0..n { cum_sum[i + 1] = cum_sum[i] + a[i]; } for x in xs ...
#![allow(clippy::comparison_chain)] #![allow(clippy::collapsible_if)] use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{BTreeSet, BinaryHeap, HashMap, HashSet}; use std::fmt::Debug; use itertools::Itertools; use whiteread::parse_line; const ten97: usize = 1000_000_007; /// 2の逆元 mod ten97.割りたいとき...
use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{HashMap, HashSet}; use itertools::Itertools; use whiteread::parse_line; const ten97: usize = 1000_000_007; /// 2の逆元 mod ten97.割りたいときに使う const inv2ten97: u128 = 500_000_004; fn main() { let n: usize = parse_line().unwrap(); let hh: Vec<i...
//! Error type for this crate. use std::error::Error; /// Error generated while parsing UCUM strings. #[derive(Debug)] pub struct UcumError<'a> { message: &'static str, txt: &'a [u8], position: usize, cause: Option<Box<dyn Error>>, } impl<'a> UcumError<'a> { /// Build a new error with a given mes...
use prost::Message; mod item { include!(concat!(env!("OUT_DIR"), "/sample.item.rs")); } fn create(id: &str, price: i32) -> item::Item { let mut d = item::Item::default(); d.item_id = id.to_string(); d.price = price; d } fn main() { let d = create("item-1", 100); println!("{:?}", d...
fn main() { let a = 1; let b = a; // copy println!("a = {}", a); println!("b = {}", b); let x = Box::new(2); let y = x; //println!("x = {}", x); // compile error : moved x value println!("y = {}", y); }
#![feature(convert)] #![feature(vecmap)] use std::collections::VecMap; fn sort_word(word: &str) -> String { let mut wordvec = word.chars().collect::<Vec<char>>(); let mut puncmap = VecMap::new(); for (i, c) in wordvec.iter().enumerate() { if !c.is_alphabetic() { puncmap.insert(i, c.clone()); } } wordvec.retain(...
#![allow(unused)] mod document; mod error; mod session; mod text; pub use document::*; pub use error::*; pub use session::*; pub use text::*; pub use wasm_lsp_parsers::core::{ language::{self, Language}, NodeExt, };
use num::range_step; use sdl2; use sdl2::event::Event; use sdl2::pixels::Color; use sdl2::rect::{Point, Rect}; use setup; const SCREEN_WIDTH: u32 = 640; const SCREEN_HEIGHT: u32 = 480; pub fn point_drawer() { let basic_window_setup = setup::init("Geometry Rendering", SCREEN_WIDTH, SCREEN_HEIGHT); let mut e...
use std::io::Read; fn read<T: std::str::FromStr>() -> T { let token: String = std::io::stdin() .bytes() .map(|c| c.ok().unwrap() as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) .collect(); token.parse().ok().unwrap() } fn main() { let...
#[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::HB16CFG { #[doc = r"Modifies the contents of the register"] #[inline(always)] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, ...
//! CallExpression use serde::{Deserialize, Serialize}; /// Represents a function call #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize, Deserialize)] pub struct CallExpression { /// Type of AST node #[serde(rename = "type", skip_serializing_if = "Option::is_none")] pub r#type: Option<String>, ...
use std::env; use std::fmt; use std::fs; use std::io::{self, Read}; use std::path::{Path, PathBuf}; use std::process; use std::str::FromStr; use std::sync::atomic; use std::time::Duration; use csv; use Csv; static XSV_INTEGRATION_TEST_DIR: &'static str = "xit"; static NEXT_ID: atomic::AtomicUsize = atomic::ATOMIC_U...
use crate::player_connection::PlayerConnection; use serde::{Deserialize, Serialize}; pub type PlayerName = String; pub type PlayerNameRef<'a> = &'a str; #[derive(Clone, Serialize, Deserialize)] pub struct Player<PC: PlayerConnection> { name: PlayerName, pub connection: Option<PC>, pub state: PlayerState, ...
use crate::{HdbResult, ServerError}; #[cfg(feature = "sync")] use byteorder::{LittleEndian, ReadBytesExt}; /// Describes the success of a command. #[derive(Clone, Debug, PartialEq, Eq)] pub enum ExecutionResult { /// Number of rows that were affected by the successful execution. RowsAffected(usize), /// Co...
/* Copyright (c) 2015, 2016 Saurav Sachidanand 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 Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, di...
use std::collections::HashMap; use opencv::core::{CV_PI, Point, Scalar, Vector, Size, MatTrait, Point2f, BORDER_CONSTANT, MatTraitManual, Mat}; use opencv::imgcodecs::{imread, imwrite, IMREAD_GRAYSCALE, IMREAD_COLOR}; use opencv::imgproc::{canny, hough_lines_p, line, warp_affine, get_rotation_matrix_2d, WARP_INVERSE_MA...
use std::io::{self, Read}; use std::io::prelude::*; use std::collections::BTreeSet; use std::collections::HashSet; use std::collections::HashMap; fn main(){ let stdin = std::io::stdin(); let mut it = stdin.lock().lines(); let mut s:HashSet<char> = HashSet::new(); let mut m:HashMap<String,f64> = HashMap::new(...
use std::process::Output; mod cache; use cache::CheckPackmanCache; pub trait UseCase { fn id(&self) -> String; fn name(&self) -> String; fn description(&self) -> String; fn execute(&self) -> Output; } pub fn items() -> [impl UseCase; 1] { let usecases: [CheckPackmanCache; 1] = [ CheckPac...
use crate::connectionInfo::ContactInfo; use bincode::serialize; use morgan_interface::pubkey::Pubkey; use morgan_interface::signature::{Keypair, Signable, Signature}; use morgan_interface::transaction::Transaction; use std::collections::BTreeSet; use std::fmt; /// CrdsValue that is replicated across the cluster #[deri...
// 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 { failure::{Error, ResultExt}, fidl_fuchsia_test_echos::{EchoExposedBySiblingRequest, EchoExposedBySiblingRequestStream}, fuchsia_async as ...
use std::io::Write; pub mod env; pub mod functions; #[derive(Debug, Clone, PartialEq, Eq)] pub enum AST { Nil, Const(i64), Lit(String), Let(String, Box<AST>, Box<AST>), Def(String, Box<AST>), Function(String, Box<AST>), Apply(Box<AST>, Box<AST>), Native1(String, Box<AST>), Native2(...
#[macro_use] extern crate log; extern crate env_logger; extern crate clap; extern crate libc; extern crate nasl_sys; use std::fs; use std::env; use std::ptr; use std::mem; use std::ffi::{ CStr, CString }; use std::net::{ Ipv4Addr, IpAddr, }; pub fn c_str<T: Into<Vec<u8>>>(t: T) -> *mut libc::c_char { CString::n...
#[doc = "Reader of register I2C_BUFOUT"] pub type R = crate::R<u32, super::I2C_BUFOUT>; #[doc = "Writer for register I2C_BUFOUT"] pub type W = crate::W<u32, super::I2C_BUFOUT>; #[doc = "Register I2C_BUFOUT `reset()`'s with value 0"] impl crate::ResetValue for super::I2C_BUFOUT { type Type = u32; #[inline(always...
extern crate tree_index as tree; use tree::{Change, TreeIndex, Verification}; #[test] fn set_and_get() { let mut index = TreeIndex::default(); assert_eq!(index.get(0), false); assert_eq!(index.set(0), Change::Changed); assert_eq!(index.get(0), true); assert_eq!(index.set(0), Change::Unchanged); assert_eq...
mod git_monitor; use tauri::Manager; #[derive(Clone, serde::Serialize)] struct Payload { message: String, } fn print_type_of<T>(_: &T) { println!("{}", std::any::type_name::<T>()) } fn main() { tauri::Builder::default().setup(|app| { println!("Is this working ?"); //example of communicating let id =...
use byteorder::{ByteOrder, LittleEndian}; use leb128; mod name_section; #[derive(Debug, Clone)] pub struct FuncType { pub params: Vec<u8>, pub results: Vec<u8>, } #[derive(Debug, Clone)] pub struct FuncExport { pub name: String, pub func: Func, } #[derive(PartialEq, Clone)] pub enum ExportType { ...
use super::base_helper::{to_utf16, from_utf16}; use super::high_dpi; use winapi::shared::windef::{HFONT, HWND, HMENU}; use winapi::shared::minwindef::{UINT, WPARAM, LPARAM, LRESULT}; use winapi::um::winuser::WM_USER; use winapi::ctypes::c_int; use std::{ptr, mem}; #[cfg(feature = "rich-textbox")] use winapi::um::winus...
use log; use actix_web::{error, error::BlockingError, web, HttpResponse, Result, dev::HttpResponseBuilder, http::header, http::StatusCode}; use derive_more::{Display, Error}; use tera::{Context, Tera}; use serde::Deserialize; use crate::db::{self, DatabaseError}; #[derive(Debug, Display, Error)] pub enum ServerError ...
pub fn goodbye() -> String { "バイバイ".to_string() }
fn main() { let s1 = "a=1&b=2&c"; println!("\"{}\" -> {:?}", s1, parse_params(s1)); // "a=1&b=2&c" -> [("a", "1"), ("b", "2")] let s2 = "a=1&b="; println!("\"{}\" -> {:?}", s2, parse_params(s2)); // "a=1&b=" -> [("a", "1"), ("b", "")] let s3 = "a=1"; println!("\"{}\" -> {:?}", s3, pars...
use std::f32; use cgmath::InnerSpace; use Vector3; #[derive(PartialEq)] pub struct Camera { pub pos: Vector3, dir_top_left: Vector3, screen_du: Vector3, screen_dv: Vector3, img: (u32, u32), } impl Camera { pub fn look_dir(pos: Vector3, dir: Vector3, up: Vector3, fov: f32, img: (u32, u32)) ->...
/// Sign of Y, magnitude of X (f32) /// /// Constructs a number with the magnitude (absolute value) of its /// first argument, `x`, and the sign of its second argument, `y`. #[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] pub fn copysignf(x: f32, y: f32) -> f32 { let mut ux = x.to_bits(); let uy = y...
mod msg; mod msg_types; mod raw_msg; pub use msg::*; pub use raw_msg::*;
//! The `blob_fetch_stage` pulls blobs from UDP sockets and sends it to a channel. use crate::service::Service; use crate::streamer::{self, BlobSender}; use std::net::UdpSocket; use std::sync::atomic::AtomicBool; use std::sync::Arc; use std::thread::{self, JoinHandle}; pub struct BlobFetchStage { thread_hdls: Vec...
// Copyright 2019. The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following // disclai...
// 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 ...
use std::{ fmt, future::Future, pin::Pin, task::{Context, Poll}, }; use bitflags::bitflags; use futures_core::ready; use smallvec::SmallVec; use crate::{ actor::{Actor, ActorContext, ActorState, AsyncContext, Running, SpawnHandle, Supervised}, address::{Addr, AddressSenderProducer}, contex...
mod surface; mod functions; fn main() { //Small example to check that everything is working nicely: I have a plane which has already been // traslated to the origin and rotated such that it is parallel to the xy plane. Then I can call // my checking function to see if my point is in the bounded region. ...
use sqlx::mysql::{MySqlRow, MySqlConnectOptions}; use sqlx::Connection; use futures::TryStreamExt; use crate::mysqlaccessor::{MySQLAccessor, MySQLAccessorError, MySQLAccessorErrorType}; macro_rules! check_conn_open { ($ins:expr) => { { if $ins.conn.is_none() { return Err(MySQLAc...