text
stringlengths
8
4.13M
use std::io::prelude::*; use std::fs::{File}; // NOTE(Lito): We are ignoring Normals and Objects for now. #[derive(Clone, Copy, Debug)] pub struct Vertex { pub x: f64, pub y: f64, pub z: f64, } #[derive(Debug)] pub struct Face { pub verts: Vec<usize> } #[derive(Debug)] pub struct Model { pub face...
use model::Grid; use std::iter; pub struct TextRenderer; impl TextRenderer { pub fn render(&self, grid: &Grid) { self.render_horizontal_wall(&grid); self.render_rows(&grid); self.render_horizontal_wall(&grid); } fn render_rows(&self, grid: &Grid) { for row in 0..grid.rows ...
use futures::ready; use std::io::{Error, ErrorKind, Result}; use std::pin::Pin; use std::task::{Context, Poll}; use crate::{AsyncReadAll, AsyncWriteAll, Request, Response}; use protocol::{MetaType, Protocol}; pub struct MetaStream<P, B> { instances: Vec<B>, idx: usize, parser: P, } impl<P, B> MetaStream...
//! The Credentials Provider for Credentials stored in a profile inside of a Credentials file. use regex::Regex; use std::ascii::AsciiExt; use std::collections::HashMap; use std::env::{home_dir, var as env_var}; use std::fs; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::{Path, PathBuf}; use {Aw...
//! This module implements a parser for the TSBLIB95 specification. This //! specification can be found //! (here)[http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/] //! under the link "Documentation". Currently this parser only supports //! symmetric TSPs. use nom::*; use std::str::{self, FromStr}; use itertools...
use anyhow::{anyhow, Error}; use css_in_rust::Style; use log::{debug, trace}; use std::collections::hash_map::HashMap; use std::time::Duration; use yew::services::timeout::TimeoutService; use yew::services::Task; use yew::{html, Component, ComponentLink, Html, ShouldRender}; use yewtil::NeqAssign; use crate::component...
use apllodb_server::{ApllodbCommandSuccess, ApllodbServer}; use apllodb_shared_components::Session; use self::step_res::StepRes; pub(crate) mod step_res; pub(crate) mod steps; #[derive(Debug)] pub struct Step { sql: String, expected: StepRes, } impl Step { pub fn new(sql: impl Into<String>, expected: St...
//! # chan_downloader //! //! `chan_downloader` is a collection of utilities to //! download images/webms from a 4chan thread use log::info; use reqwest::{Client, Error}; use std::{ fs::File, io::{self, Cursor}, }; /// Represents a 4chan thread #[derive(Debug)] pub struct Thread { pub board: String, p...
#[doc = "Reader of register CH6_TOP"] pub type R = crate::R<u32, super::CH6_TOP>; #[doc = "Writer for register CH6_TOP"] pub type W = crate::W<u32, super::CH6_TOP>; #[doc = "Register CH6_TOP `reset()`'s with value 0xffff"] impl crate::ResetValue for super::CH6_TOP { type Type = u32; #[inline(always)] fn res...
#[macro_use] extern crate log; use async_pq::Client; use async_std::task; use futures::future::join_all; use std::{thread, time}; fn main() { env_logger::init(); let st = time::Instant::now(); let conc = 10; let client = Client::new("postgresql://myuser:secret@localhost:15432/mydb", conc).unwrap(); ...
/* * Binomial heap test (Rust) * * Copyright (c) 2022 Project Nayuki. (MIT License) * https://www.nayuki.io/page/binomial-heap * * 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 wit...
use super::*; #[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] #[repr(transparent)] pub struct SoundControl(u16); impl SoundControl { const_new!(); bitfield_int!(u16; 0..=2: u16, right_volume, with_right_volume, set_right_volume); bitfield_int!(u16; 4..=6: u16, left_volume, with_left_volume, set_left_volume...
// // Copyright 2020 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...
use crate::chunk::{Chunk, OpCode}; pub fn disassemble_chunk(chunk: &Chunk, name: String) { println!("== {} ==", name); for (index, op_code) in chunk.code.iter().enumerate() { disassemble_instruction(index, op_code) } } fn disassemble_instruction(index: usize, instruction: &OpCode) { println!(...
use std::io; /*str es el tipo nativo de string */ /* no es el objeto y son inmutables*/ fn find_tdl_in_string(string : &String) -> &str { let bytes = string.as_bytes(); for (i, &item) in bytes.iter().enumerate() { if item == b'L' { return &string[0..i+1]; } } &string[..] ...
use druid::{FontDescriptor, FontFamily, TextLayout}; pub struct LapceFont { font: FontDescriptor, } impl LapceFont { pub fn new(font_name: &str, size: f64) { let font = FontDescriptor::new(FontFamily::new_unchecked("Cascadia Code")) .with_size(size); let mut text_layout = TextLayou...
#[macro_use] extern crate log; pub fn log_a() { debug!("a"); } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } }
struct Space_Station{ } impl Space_Station{ }
use std::iter::{Peekable}; use tokens::*; use position::*; use ast::*; use utils::*; pub fn parse<'a, T: Iterator<Item = Token<'a>>>(tokens: &mut T) -> Tree { let mut peekable = tokens.peekable(); let s = parse_tree(&mut peekable); expect_eof(&mut peekable); s } fn parse_tree<'a, T: Iterator<Item = Token<'a>>...
//! Parse HTML documents into [HtmlDocuments](HtmlDocument). //! //! # Example: parse HTML text into a document //! ```rust //! use skyscraper::html::{self, parse::ParseError}; //! # fn main() -> Result<(), ParseError> { //! let html_text = r##" //! <html> //! <body> //! <div>Hello world</div> //! </bod...
#[doc = "Register `FMC_BCHPBR1` reader"] pub type R = crate::R<FMC_BCHPBR1_SPEC>; #[doc = "Field `BCHPB` reader - BCHPB"] pub type BCHPB_R = crate::FieldReader<u32>; impl R { #[doc = "Bits 0:31 - BCHPB"] #[inline(always)] pub fn bchpb(&self) -> BCHPB_R { BCHPB_R::new(self.bits) } } #[doc = "Thes...
use crate::ethcore_network::*; use ed25519_dalek::{Keypair}; #[allow(deprecated)] use super::error::*; use parking_lot::{ Mutex }; use std; use std::cell::{Cell as StdCell, RefCell}; use std::collections::{HashMap, VecDeque}; use std::convert::From; use std::clone::Clone; use std::path::PathBuf; use std::sync::mpsc; us...
use mongodb::{options::ClientOptions, Client}; use std::sync::Arc; use warp::Filter; mod api; mod user; mod generate_maps; use api::*; const MONGODB_URL: &str = "mongodb://localhost:27017"; const DATABASE: &str = "mvp"; #[tokio::main] async fn main() { // prints initial map data generate_maps::generate(); ...
use failure; use failure::ResultExt; use serde_json; use std::collections::HashMap; use std::fs; #[derive(Deserialize, Debug)] struct City { location: (f64, f64), neighbours: Vec<String>, } #[derive(Deserialize, Debug)] pub struct Data(HashMap<String, City>); pub fn from_file(path: &str) -> Result<Data, fail...
use ethane::contract::{CallOpts, CallResult, Caller}; use ethane::types::{Address, H256, U256}; use ethane::{Connection, Http}; use ethane_abi::*; use std::convert::TryFrom; use std::path::Path; use test_helper::{ deploy_contract, wait_for_transaction, ConnectionWrapper, TEST_ERC20_NAME, TEST_ERC20_PATH, }; const ...
use std::sync::Arc; use eyre::Report; use hashbrown::HashMap; use rosu_v2::prelude::{GameMode, OsuError, Username}; use twilight_model::{ application::interaction::{ application_command::{CommandDataOption, CommandOptionValue}, ApplicationCommand, }, id::{marker::UserMarker, Id}, }; use cr...
use super::Point; use std::io::{self, Write}; pub fn write_gpx<'a>(mut w: impl Write, segments: impl Iterator<Item=&'a [Point]>) -> io::Result<()> { writeln!(w, r#"<?xml version="1.0" encoding="utf-8"?> <gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1" creator="alpinereplay-rs/1">"#)?; for seg in s...
use util::*; fn main() -> Result<(), Box<dyn std::error::Error>> { let timer = Timer::new(); let count = input::vec::<String>(&std::env::args().nth(1).unwrap(), "\n\n") .iter() .map(|s| s.replace("\n", " ")) .filter(|s| { let mut res = true; for field in vec!["by...
use serde::Serialize; use uvm_core::unity::{Version, Manifest, Modules, Module}; use std::collections::HashSet; use std::iter::FromIterator; use std::path::Path; use stringreader::StringReader; mod fixures; fn save_json_output<P: AsRef<Path>, T: ?Sized + Serialize>(dir:P, file_name: &str, value:&T) -> std::io::Result<...
pub(crate) mod sponge; pub(crate) mod poseidon; pub(crate) mod rescue; pub(crate) mod rescue_prime; mod sbox; mod matrix; #[cfg(test)] mod tests;
//! # libinjection //! //! Rust bindings for (libinjection)][1] //! //! [1]: https://github.com/client9/libinjection //! //! ## How to Use //! //! ``` //! extern crate libinjection; //! //! use libinjection::{sqli, xss}; //! //! fn main() { //! let (is_sqli, fingerprint) = sqli("' OR '1'='1' --").unwrap(); //! ...
#[doc = "Register `PDCRB` reader"] pub type R = crate::R<PDCRB_SPEC>; #[doc = "Register `PDCRB` writer"] pub type W = crate::W<PDCRB_SPEC>; #[doc = "Field `PD6` reader - Port B pull-down bit i (i = 15 to 0) Setting PDi bit while the APC bit of the PWR_CR3 register is set activates a pull-down device on the PB\\[i\\] I/...
#[macro_use] extern crate log; #[macro_use] extern crate serde_derive; use rsocket_rust::extension::MimeType; use rsocket_rust_messaging::*; fn init() { let _ = env_logger::builder() .format_timestamp_millis() .is_test(true) .try_init(); } #[derive(Serialize, Deserialize, Debug, Default)]...
table! { actor (actor_id) { actor_id -> Int4, first_name -> Text, last_name -> Text, last_update -> Timestamptz, } } table! { address (address_id) { address_id -> Int4, #[sql_name = "address"] address_name -> Text, address2 -> Nullable<Text>, ...
use crate::tokenizer::{PreTokenizedString, PreTokenizer, Result, SplitDelimiterBehavior}; use unicode_categories::UnicodeCategories; fn is_bert_punc(x: char) -> bool { char::is_ascii_punctuation(&x) || x.is_punctuation() } #[derive(Copy, Clone, Debug)] pub struct BertPreTokenizer; impl_serde_unit_struct!(BertVisi...
use crate::cars::data::CarObjective::{Route, Simple, Temporary}; use crate::cars::data::{CarComponent, CarObjective}; use crate::engine_interaction::TimeInfo; use crate::map_model::{Map, NavMesh}; use crate::physics::PhysicsWorld; use crate::physics::{Kinematics, Transform}; use cgmath::MetricSpace; use cgmath::{Angle,...
fn fib(x: u32) -> u32 { if x < 2 { 1 } else { fib(x - 1) + fib(x - 2) } } fn main() { println!("{}", fib(40)); }
pub struct Timer { divider_register: u8, // div timer_counter: u8, // tima timer_modulo: u8, // tma timer_control: u8, // tac internal_counter: u32, divider_counter: u32, } impl Timer { pub fn new() -> Timer { Timer { divider_register: 0, timer_counter: 0, ...
use std::{ collections::HashSet, net::IpAddr, sync::{Arc, Mutex}, thread::{Builder, JoinHandle}, }; use tokio::{ runtime::Runtime, sync::mpsc::{self, Sender}, }; use crate::network::dns::{resolver::Lookup, IpTable}; type PendingAddrs = HashSet<IpAddr>; const CHANNEL_SIZE: usize = 1_000; pub...
// This file is part of rdma-core. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ...
use cosmwasm_std::{Decimal, HumanAddr, Uint128}; use cw20::Cw20ReceiveMsg; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; // We define a custom struct for each query response #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] pub struct ConfigInfo { pub owner: HumanAddr, pub...
use crate::data::{Primitive, Value}; use crate::prelude::*; use derive_new::new; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use std::cmp::{Ordering, PartialOrd}; use std::fmt; #[derive(Debug, Default, Eq, PartialEq, Serialize, Deserialize, Clone, new)] pub struct Dictionary { pub entries: IndexMa...
#[doc = "Register `VCTR11` reader"] pub type R = crate::R<VCTR11_SPEC>; #[doc = "Register `VCTR11` writer"] pub type W = crate::W<VCTR11_SPEC>; #[doc = "Field `B352` reader - B352"] pub type B352_R = crate::BitReader; #[doc = "Field `B352` writer - B352"] pub type B352_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG...
pub fn roman_to_int(s: String) -> i32 { use std::collections::HashMap; let mut dict = HashMap::new(); dict.insert('I', 1); dict.insert('V', 5); dict.insert('X', 10); dict.insert('L', 50); dict.insert('C', 100); dict.insert('D', 500); dict.insert('M', 1000); let mut n = 0; le...
pub trait NodeBasicMovement<T> { fn move_to_left(&mut self); fn move_to_right(&mut self); fn insert_to_left(&mut self, item: T); fn insert_to_right(&mut self, item: T); } #[derive(Debug)] pub struct NodeInSequence<T> { pub current_node: T, pub left_list: Vec<T>, pub right_list: Vec<T>, } i...
// Copyright 2020 <盏一 w@hidva.com> // 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,...
use super::*; use crate::model::enums::Era; use serenity::model::id::UserId; #[test] fn remove_started_server() { let db_conn = &DbConnection::test(); let alias = "foo".to_owned(); db_conn .insert_game_server(&GameServer { alias: alias.clone(), state: GameServerState::Starte...
use serenity::prelude::*; use serenity::model::channel::Message; use serenity::framework::standard::{ CommandResult, Args, macros::{ command, group } }; group!({ name: "frack_you", options: { prefix: "frack" }, commands: [frack_you] }); #[co...
use macros::list; fn main() { let mut l = list![8]; println!("{:?}", l); }
fn first_word(s: &str) -> &str { for (i, &v) in s.as_bytes().iter().enumerate() { if v == b' ' { return &s[..i]; } } return &s[..]; } fn main() { let my_string = String::from("sss asdf sdfd"); let my_str = "sdfsld alksdjflka a"; let _word = first_word(&my_string[..5...
use opencv::prelude::*; use opencv::imgproc::*; use opencv::core::*; use vision_traits::{Configurable, DynErrResult, input::InputSingular, Node, output::OutputSingular, types::range::RangeU8}; #[derive(Configurable)] pub struct HsvFilterS { hue: RangeU8<0, 180>, saturation: RangeU8<0, 255>, value: RangeU8...
use serde_json::{Value}; use crate::ofn_2_thick::axiom_translation as axiom_translation; pub fn ofn_2_thick(v : &Value) -> Value { match v[0].as_str() { Some("SubClassOf") => axiom_translation::translate_subclass_of_axiom(v), Some("DisjointClasses") => axiom_translation::translate_disjoint_cla...
pub use core::f32::consts::PI; pub use core::f32::consts::FRAC_PI_2 as PI_HALF; pub const PI_TWO:f32 = PI * 2f32; pub const PI_SQUARED:f32 = PI * PI; pub const TAU:f32 = core::f32::consts::TAU; pub const TAU_SQUARED:f32 = TAU * TAU; pub const fn cos_approx_a1(a:f32) -> f32 { let a2 = a*a; let a4 = a2*a2; return 1.0...
use specs::{self, Component}; use components::InitFromBlueprint; #[derive(Clone, Debug, Deserialize)] pub struct Attacker { pub damage: u32, } impl Component for Attacker { type Storage = specs::VecStorage<Self>; } impl InitFromBlueprint for Attacker {}
use super::link::Link; use eos::*; use prelude::*; use std::cmp::min; use views::svg; pub struct DonationList { props: Props, donations: EosData<Vec<Donation>>, eos_agent: Box<Bridge<EosAgent>>, } pub enum Msg { Eos(EosOutput), } #[derive(PartialEq, Clone, Default)] pub struct Props { pub context...
pub mod hash; pub mod merkle;
//! Chia proof of space implementation use crate::chiapos::Tables; #[cfg(any(feature = "parallel", test))] use crate::chiapos::TablesCache; use crate::{PosTableType, Quality, Table, TableGenerator}; use core::mem; use subspace_core_primitives::{PosProof, PosQualityBytes, PosSeed}; const K: u8 = 17; /// Abstraction th...
#![no_std] #![feature(const_in_array_repeat_expressions)] pub mod lis3dsh;
use fst::raw::{Fst, Node, Output}; /// Wraps a Map to add the `get_before` method. pub struct Map<D> { map: fst::Map<D>, } impl Map<Vec<u8>> { pub fn from_iter(iter: impl Iterator<Item = (u64, u64)>) -> Result<Self, fst::Error> { let map = fst::Map::from_iter(iter.map(|(key, value)| (key.to_be_bytes()...
// --- paritytech --- use cumulus_pallet_xcmp_queue::Config; use xcm_executor::XcmExecutor; // --- darwinia-network --- use crate::*; impl Config for Runtime { type Event = Event; type XcmExecutor = XcmExecutor<XcmConfig>; type ChannelInfo = ParachainSystem; type VersionWrapper = (); }
use std::collections::HashMap; use std::io::Read; fn main() -> Result<(), Box<dyn std::error::Error>> { let mut resp = reqwest::blocking::get("https://ip.nyaa.gay/ip")?; let mut body = String::new(); resp.read_to_string(&mut body)?; println!("{}", body.trim()); Ok(()) }
/* chapter 4 syntax and semantics scope and shadowing */ fn main() { let n: i32 = 8; { println!("{}", n); // prints "8" let n = 12; println!("{}", n); // prints "12" } println!("{}", n); // prints "8" let n = 42; print!("{}", n); // prints "42" } // output should be: /* 8...
use tonic::{transport::Server, Request, Response, Status}; use dapr::{ appcallback::*, dapr::dapr::proto::runtime::v1::app_callback_server::{AppCallback, AppCallbackServer}, }; #[derive(Default)] pub struct AppCallbackService {} #[tonic::async_trait] impl AppCallback for AppCallbackService { /// Invokes ...
use std::fmt::Display; pub trait Response: Display {}
use yaml_rust::YamlLoader; use std::env; use std::path; use super::{Context, Module, RootModuleConfig}; use crate::configs::kubernetes::KubernetesConfig; use crate::formatter::StringFormatter; use crate::utils; fn get_kube_context(contents: &str) -> Option<(String, String)> { let yaml_docs = YamlLoader::load_fr...
pub enum PointerEvent { ButtonPress, ButtonRelease, EnterWindow, LeaveWindow, PointerMotion, PointerMotionHint, Button1Motion, Button2Motion, Button3Motion, Button4Motion, Button5Motion, ButtonMotion, KeymapState, }
use regex::Regex; const INPUT: &str = include_str!("../input.txt"); fn spec_iter() -> impl Iterator<Item = (usize, usize, char, String)> { let re = Regex::new( r"(?x) (?P<min>\d+) - (?P<max>\d+) \s (?P<letter>[[:alpha:]]+) ...
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Peripheral group structure"] pub gr0: GR, _reserved1: [u8; 24usize], #[doc = "0x40 - Peripheral group structure"] pub gr1: GR, _reserved2: [u8; 24usize], #[doc = "0x80 - Peripheral group structure"] pub gr2:...
#![allow(non_snake_case)] use cgmath::{vec3, SquareMatrix, InnerSpace}; use crate::mesh::Vertex; use crate::camera::Camera; use crate::types::*; use crate::{SCR_WIDTH, SCR_HEIGHT, DRAW_DISTANCE}; pub static BOUNDING_BOX: [Vertex; 8] = [ Vertex { Position: Vector3 { x: -0.5, y: -0.5, z: -0.5 }, Normal: Vector3 { x: ...
/* * YNAB API Endpoints * * Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.youneedabudget.com * * The ve...
use std::sync::{atomic::AtomicBool, Arc}; use lavalink_rs::LavalinkClient; use poise::serenity_prelude::TypeMapKey; use songbird::Songbird; use sqlx::PgPool; use tokio::time::Instant; use crate::types::{IdleHashMap, LastMessageHashMap}; pub struct PgPoolContainer; impl TypeMapKey for PgPoolContainer { type Valu...
use conrod_core::{self, widget, Colorable, Labelable, Positionable, Widget, Sizeable, color}; use custom_widget::item_history; use conrod_keypad::custom_widget::text_edit::TextEdit; use conrod_keypad::english; use custom_widget::Message; use std::sync::mpsc; /// The type upon which we'll implement the `Widget` trait. #...
#[doc = "Register `OR` reader"] pub type R = crate::R<OR_SPEC>; #[doc = "Register `OR` writer"] pub type W = crate::W<OR_SPEC>; #[doc = "Field `TS_OP0` reader - general purpose option bits"] pub type TS_OP0_R = crate::BitReader; #[doc = "Field `TS_OP0` writer - general purpose option bits"] pub type TS_OP0_W<'a, REG, c...
//! Link: https://adventofcode.com/2019/day/16 //! Day 16: Flawed Frequency Transmission //! //! You're 3/4ths of the way through the gas giants. //! Not only do roundtrip signals to Earth take five hours, //! but the signal quality is quite bad as well. //! You can clean up the signal with the Flawed Frequency Tra...
use super::*; use std::path::Path; #[derive(Debug, Deserialize)] pub struct KkConf { groups: Vec<Group>, participants: Vec<Participants>, } impl KkConf { pub fn build<P: AsRef<Path>>(path: P) -> KkConf { toml::from_str(&file_utils::read_from_file(path)).unwrap() } pub fn new(participant...
extern mod rfc4648; use std::vec; use rfc4648::base16; use rfc4648::base32; use rfc4648::base64; fn t(source: ~[~str], expect: ~[~str], cb: &fn(&[u8]) -> ~[u8]) { let mut source_b = vec::with_capacity(source.len()); let mut expect_b = vec::with_capacity(expect.len()); for s in source.move_iter() { sourc...
extern crate dirac; pub mod checks;
struct Identifier(String); struct Function { name: Identifier, parameters: Vec<Identifier>, expression: Expr, } enum Expr { Const(bool), Var(Identifier), Not(Box<Expr>), Func { ident: Identifier, param: Vec<Expr> }, And(Box<Expr>, Box<Expr>), Or(Box<Expr>, Box<Expr>), } // a | b //...
use {data::semantics::Semantics, proc_macro2::TokenStream, quote::quote}; impl Semantics { pub fn runtime_register_functions() -> TokenStream { quote! { fn register_classes(source: &Group, classes: &mut HashMap<&'static str, Group>) { for source in &source.classes { for class in &source.classes { ...
use crate::extensions::NodeExt as _; use crate::hud; use crate::mob; use crate::player; use gdnative::api::{Area2D, AudioStreamPlayer, PathFollow2D, Position2D, RigidBody2D}; use gdnative::prelude::*; use rand::*; use std::f64::consts::PI; #[derive(NativeClass)] #[inherit(Node)] #[user_data(user_data::LocalCellData<...
extern crate hacspec_lib; extern crate proc_macro; extern crate proc_macro2; extern crate quote; extern crate syn; use proc_macro2::TokenStream; use quote::{quote, quote_spanned}; use syn::spanned::Spanned; use syn::{parse_macro_input, Data, DeriveInput, Fields, Ident, Index}; enum Expression { Binop(TokenStream,...
use crate::ast_parser; use crate::options::ParseOptions; pub fn parse( src: String, parse_options: ParseOptions, ) -> Result<swc_ecma_ast::Module, anyhow::Error> { let p = ast_parser::AstParser::new(); p.parse_module("root.ts", &src, parse_options, |parse_result| { let module = parse_result?; ...
use crate::BASE_ADDR; /// All possible errors in this crate #[derive(Debug)] pub enum Error<E> { /// I²C communication error I2C(E), /// Invalid input data provided InvalidInputData, } /// Measurement result #[derive(Debug, Clone, Copy, PartialEq)] pub struct Measurement { /// Temperature (°C) ...
//! Provides an 'EventLoop' class for managing the gui worker. use std::time::{ Instant }; /// In most of the examples the `glutin` crate is used for providing the window context and /// events while the `glium` crate is used for displaying `conrod::render::Primitives` to the /// screen. /// /// This `Iterator`-like ...
extern crate rider_config; use std::process::Command; #[cfg_attr(tarpaulin, skip)] fn main() { let generator = rider_config::directories::get_binary_path("rider-generator").unwrap(); println!("generator will be {:?}", generator); Command::new(generator).status().unwrap(); let editor = rider_config::di...
use super::webgl::WebGlRenderingContext; use crate::arena::{resource, BlockRef}; use crate::libs::random_id::U128Id; use std::cell::Cell; use std::collections::HashMap; use std::collections::VecDeque; use std::rc::Rc; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; #[derive(Hash, PartialEq, Eq, Clone)] enum T...
/// GitBlobResponse represents a git blob #[derive(Debug, Default, Clone, Serialize, Deserialize)] pub struct GitBlobResponse { pub content: Option<String>, pub encoding: Option<String>, pub sha: Option<String>, pub size: Option<i64>, pub url: Option<String>, } impl GitBlobResponse { /// Creat...
use core::marker::PhantomData; use futures::{Poll, Async, AsyncSink, StartSend}; use futures::sink::Sink; pub struct SyncSink<Item, F> { _item: PhantomData<Item>, f: F, } impl<Item, F> SyncSink<Item, F> where F: FnMut(Item), { pub fn new(f: F) -> Self { Self { _item: PhantomData, ...
use std::iter::Peekable; use std::cmp::Ordering; use regex::Regex::*; use regex::Regex; #[derive(Debug,Clone)] pub struct Derivatives<R> { pub d: Vec<(Vec<char>, R)>, pub rest: R, } impl<R> Derivatives<R> { pub fn map<F: FnMut(R) -> R>(self, mut f: F) -> Derivatives<R> { Derivatives { ...
use std::cell::UnsafeCell; use std::ptr; use std::sync::atomic::{AtomicPtr, Ordering}; use crossbeam_utils::{Backoff, CachePadded}; struct Node<T> { next: AtomicPtr<Node<T>>, value: Option<T>, } impl<T> Node<T> { unsafe fn new(v: Option<T>) -> *mut Node<T> { Box::into_raw(Box::new(Node { ...
fn main() { f2(3); } fn f2(xx: i32) { println!("{}", xx); }
use std::{collections::HashMap, sync::Arc, time::Duration}; use serde::Deserialize; use crate::{ bson::{doc, DateTime}, hello::{HelloCommandResponse, HelloReply, LastWrite}, options::ServerAddress, sdam::{ description::topology::{test::f64_ms_as_duration, TopologyType}, ServerDescripti...
fn main() { // Constants are like macros in C, i.e., are changed in compiler time const MAX_VALUE: u64 = 15; println!( "The constants MAX_VALUE ({}) it's like an MACRO in C", MAX_VALUE ); // Imutable variables are like constants in C let x: i64 = 3; let x: i64 = x * 6; println!("X value is {} "...
//! Module for actions setting flags. //! //! This contains helper functions to set flags whenever a signal happens. The flags are atomic //! bools or numbers and the library manipulates them with the `SeqCst` ordering, in case someone //! cares about relative order to some *other* atomic variables. If you don't care a...
#[doc = "Register `CFGR2` reader"] pub type R = crate::R<CFGR2_SPEC>; #[doc = "Register `CFGR2` writer"] pub type W = crate::W<CFGR2_SPEC>; #[doc = "Field `OVSE` reader - Oversampler Enable This bit is set and cleared by software. Note: Software is allowed to write this bit only when ADSTART = 0 (which ensures that no ...
use std::{fs::File, time::Duration}; use resol_vbus::{DataSet, RecordingWriter}; use tokio::prelude::*; use tokio_serial::{DataBits, FlowControl, Parity, Serial, SerialPortSettings, StopBits}; use tokio_resol_vbus::LiveDataStream; fn main() { // Create an recording file and hand it to a `RecordingWriter` let...
#[macro_use] extern crate serde_json; extern crate conrod_core; extern crate conrod_glium; #[cfg(target_os="android")] extern crate rusttype; #[cfg(target_os="android")] extern crate android_glue; #[cfg(not(target_os="android"))] extern crate find_folder; extern crate conrod_chat; extern crate futures; extern crate har...
//generics //generics constructor struct genericPoint<T> { x : T, y : T, } struct parametricGenericPoint<T,U> { x : T, y : U, } fn main() { //enum Option<T> let x: Option<i32> = Some(4); let y: Option<f64> = Some(4.0); let ip = genericPoint {x : 0, y : 0}; let fp = gener...
use crossbeam::thread; use crate::account::Account; use csv; use std::collections::BTreeMap; use std::io; use structopt::StructOpt; use transaction::Transaction; mod account; mod transaction; type AccountsType = BTreeMap<u16, Account>; /// This is the struct we use to parse command line /// arguments and display us...
// 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...