text
stringlengths
8
4.13M
use std::{sync::atomic::AtomicU32, time::Duration}; use async_trait::async_trait; use messagebus::{ derive::{Error as MbError, Message}, error, receivers::BufferUnorderedConfig, AsyncHandler, Bus, Message, Module, }; use thiserror::Error; #[derive(Debug, Error, MbError)] enum Error { #[error("Erro...
extern crate hal; use crate::graphics; use graphics::gfxal; /// a vertex buffer, this is used to represent the mesh pub struct VertexBuffer { buffer: gfxal::Buffer, } impl VertexBuffer { /// Create a new vertex buffer, data is the raw vertex data #[profiled] pub fn new<T>(data: &mut [T]) -> VertexBuff...
use interactive_process::InteractiveProcess; use std::{process::Command, thread::sleep, time::Duration}; fn main() { let mut cmd = Command::new("examples/echo_stream.py"); let mut proc = InteractiveProcess::new(&mut cmd, |line| { println!("Got: {}", line.unwrap()); }) .unwrap(); proc.send(...
use web_sys::WebGl2RenderingContext; pub trait Drawwable { // TODO(Angus): replace with api fn draw(&self, context: &WebGl2RenderingContext) -> Result<(), DrawError>; } pub enum DrawError { }
extern crate libc; use std::fmt; use std::ffi::CString; use std::os::raw::c_char; use super::tqapi_ffi::*; // TradeApi pub struct AccountInfo { pub account_id : String, // 帐号编号 pub broker : String, // 交易商名称,如招商证券 pub account : String, // 交易帐号 pub status : String, // 连接...
use std::fs::File; use std::io::{BufReader, prelude::*}; fn main() { // creates a File object that requires a path argument // at present this program will crash if "README.md" does not exist let f = File::open("README.md").unwrap(); /* // reader == new BufReader struct created using 'f' as th...
use std::collections::HashMap; use std::fs::File; use std::io::{self, BufRead}; use std::path::{Path, PathBuf}; use anyhow::Result; // The output is wrapped in a Result to allow matching on errors // Returns an Iterator to the Reader of the lines of the file. fn read_lines<P>(filename: P) -> io::Result<io::Lines<io::...
use std::collections::HashMap; use std::env; use std::fs; fn main() { let args : Vec<String> = env::args().collect(); if args.len() < 2 { return; } let mut valid_rooms = 0; for line in fs::read_to_string(&args[1]).unwrap().split('\n') { let mut room_valid : bool = true; let...
#[doc = "Register `ACR` reader"] pub type R = crate::R<ACR_SPEC>; #[doc = "Register `ACR` writer"] pub type W = crate::W<ACR_SPEC>; #[doc = "Field `HLFCYA` reader - Flash half cycle access enable"] pub type HLFCYA_R = crate::BitReader; #[doc = "Field `HLFCYA` writer - Flash half cycle access enable"] pub type HLFCYA_W<...
use crate::lib::environment::Environment; use crate::lib::error::DfxResult; use crate::lib::identity::Identity; use crate::lib::provider::create_agent_environment; use crate::lib::root_key::fetch_root_key_if_needed; use crate::lib::waiter::waiter_with_timeout; use crate::util::expiry_duration; use candid::de::Argument...
// std imports {{{ use std::fs; use std::io::ErrorKind::NotFound; use std::path::PathBuf; // }}} // 3rd party imports {{{ use serde_derive::{ Deserialize, Serialize, }; use url::Url; // }}} // Own imports {{{ use crate::error::Error; // }}} /// Binary name. const BINARY_NAME: &str = env!("CARGO_PKG_NAME"); ...
use silkenweb::{ elements::{div, hr, Div}, memo::{MemoCache, MemoFrame}, mount, signal::Signal, Builder, }; use silkenweb_tutorial_common::define_counter; // ANCHOR: main fn main() { let count = Signal::new(0); mount( "app", div() .text("How many counters would ...
use {Errno, Result, NixPath}; use std::os::unix::io::AsRawFd; pub mod vfs { #[cfg(target_pointer_width = "32")] pub mod hwdep { use libc::{c_uint}; pub type FsType = c_uint; pub type BlockSize = c_uint; pub type NameLen = c_uint; pub type FragmentSize = c_uint; p...
use crate::console; use crate::preloader::WORKDIR; use colored::Colorize; use execute::Execute; use std::process::{self, Command}; pub fn compile_app(directory: &str) -> Result<(), String> { console::log(format!("{}", format!("Building {}...", directory).yellow()), true); let mut build_command = Command::new(...
// Derived from here: // // https://docs.rs/tantivy/0.11.3/tantivy/collector/struct.TopDocs.html#example use tantivy::schema::Field; use tantivy::SegmentReader; use tantivy::collector::TopDocs; use tantivy::query::QueryParser; use tantivy::schema::*; use tantivy::{doc, DocAddress, DocId, Index, Score}; fn create_sch...
#![allow(unused_parens)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(dead_code)] use std::env::current_dir; use std::fs::File; use std::io::BufReader; mod parser; use parser::parse; const filename_input: &'static str = "fact.ng"; fn main () { let filename_base = current_dir().unwrap(); ...
// This file was generated mod weak_private { pub trait Sealed<T: ?Sized> { } } /// Extension for [`Weak`](std::rc::Weak) pub trait IsntWeakExt<T: ?Sized>: weak_private::Sealed<T> { /// The negation of [`ptr_eq`](std::rc::Weak::ptr_eq) #[must_use] fn not_ptr_eq(&self, other: &std::rc::Weak<T>) -> bool; } ...
use crate::{ num::{real::consts::PI, Real}, source::{Source, SourceBuilder}, }; use std::time::Duration; pub trait Wave: Source { fn freq(&self) -> Real; } pub trait WaveBuilder where Self: SourceBuilder, Self::Source: Wave, { fn freq(&mut self, freq: Real) -> &mut Self; fn get_freq(&self...
impl Solution { pub fn generate_matrix(n: i32) -> Vec<Vec<i32>> { fn gen(i: i32, n: i32) -> Vec<Vec<i32>> { if n == 1 { return vec![vec![i]]; } if n == 2 { return vec![vec![i, i+1], vec![i+3, i+2]]; } let N = n as us...
use clapme::ClapMe; use display_as::{display, with_template, DisplayAs, HTML, URL, UTF8}; use serde::{Deserialize, Serialize}; use warp::reply::Reply; use warp::{path, Filter}; mod atomicfile; // mod sheets; #[derive(Debug, ClapMe, Serialize)] struct TlsFlags { /// Contact email for domain. email: String, ...
/* https://projecteuler.net We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? NOTES: Using the is_pandigital() trait (with a small tweak to f...
struct Solution; impl Solution { pub fn longest_common_prefix(strs: Vec<String>) -> String { match strs.len() { 0 => return String::new(), 1 => return strs[0].clone(), _ => (), }; let mut buf = String::new(); for (i, c) in strs[0].as_bytes().iter...
use actix_web::HttpResponse; use super::super::response; pub fn index() -> HttpResponse { response::health::response() }
mod point_layout; pub use self::point_layout::*; mod point_type; pub use self::point_type::*; pub mod conversion; //pub use self::conversion;
//! Core functionality: Uses strongly typed objects to represent input and //! output. Public interfaces will wrap this code with common types for ease //! of use. use std::collections::HashMap; use std::hash::Hash; /// Represents the number of rows and columns occupied by a given table cell. #[derive(Copy, Clone, Pa...
use crate::*; use serde::{Deserialize, Serialize}; pub(crate) struct JsonService<'a, T: Transport> { device: &'a Client<T>, uri: http::Uri, api_version: String, } impl<'a, T: Transport> JsonService<'a, T> { pub fn new(device: &'a Client<T>, path_and_query: &str, api_version: String) -> Self { ...
use kvfmt::kvfmt; fn main() { let dir = "/var/log"; let paths = vec!["dmesg", "syslog"]; assert_eq!( "dir=/var/log paths=[\"dmesg\", \"syslog\"]", kvfmt!(dir, ?paths) ); }
use crate::parser_state::Type; pub use crate::Span; #[derive(Debug)] pub enum ParseError { ExtraTokens(Span), ExtraPositional(Span), UnexpectedEof(String, Span), Unclosed(String, Span), UnknownStatement(Span), Mismatch(String, Span), MultipleRestParams(Span), VariableNotFound(Span), ...
use crate::common::{CurrentCell, LazyLoadCellOutput}; use crate::syscalls::{Source, ITEM_MISSING, LOAD_CELL_SYSCALL_NUMBER, SUCCESS}; use ckb_core::cell::CellMeta; use ckb_protocol::CellOutput as FbsCellOutput; use ckb_store::ChainStore; use ckb_vm::{ Error as VMError, Memory, Register, SupportMachine, Syscalls, A0...
// Import hacspec and all needed definitions. use hacspec_lib::*; const BLOCK_SIZE: usize = 128; const LEN_SIZE: usize = 16; pub const K_SIZE: usize = 80; pub const HASH_SIZE: usize = 512 / 8; bytes!(Block, BLOCK_SIZE); array!(OpTableType, 12, usize); bytes!(Sha512Digest, HASH_SIZE); array!(RoundConstantsTable, K_SIZ...
use super::TextureFormat; use util::bits::BitField; #[derive(Copy, Clone)] pub struct TextureParams(pub u32); impl TextureParams { pub fn offset(self) -> u32 { self.0.bits(0,16) << 3 } pub fn repeat_s(self) -> bool { self.0.bits(16,17) != 0 } pub fn repeat_t(self) -> bool { self.0.bits(17,18) != 0 } p...
// Copyright 2018-2019 Mozilla // // 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, sof...
static FILENAME: &str = "input/data"; #[derive(Debug, Clone, PartialEq)] enum Operation { Add, Multiply, Number(usize), Parenthesis(bool), } fn main() { let data = std::fs::read_to_string(FILENAME).expect("could not read file"); let ops = parse(&data); println!("part one: {}", part_one(&op...
use std::collections::{HashMap, HashSet}; use irc::conn::Conn; #[deriving(Clone, PartialEq)] pub enum ChannelType { Moderate, // we mod this channel Control // we are controlled here } #[deriving(Clone)] pub struct IRCChannel { name: String, chantype: ChannelType, nicks: HashSet<String>, joined: bool, ...
use handlegraph::packedgraph::{iter::EdgeListHandleIter, nodes::IndexMapIter}; use rhai::plugin::*; use handlegraph::{ handle::{Direction, Handle, NodeId}, handlegraph::*, pathhandlegraph::*, }; use handlegraph::packedgraph::{paths::StepPtr, PackedGraph}; use std::sync::Arc; #[derive(Clone)] pub struct ...
use std::sync::Arc; use crate::libcore::material::Material; use crate::math::Point3; use crate::math::Ray; use crate::math::Vec3; pub struct HitRecord<'a> { pub p: Point3<f64>, pub normal: Vec3<f64>, pub t: f64, pub front_face: bool, pub material: &'a dyn Material, } pub trait Hittable { fn hi...
pub mod comment; pub mod post; pub mod requests; pub mod rights; pub mod user; pub use comment::*; pub use post::*; pub use requests::*; pub use rights::*; pub use user::*;
use num_traits::PrimInt; /// 1からnまでの総和を算出する pub fn sum_one_to_n<T: PrimInt>(n: T) -> i32 { let n: i32 = n.to_i32().unwrap(); if n <= 0 { panic!("n is not natural number."); } if n == 1 { 1 } else { n + sum_one_to_n(n - 1) } } /// 最小公約数 pub fn lcm(a: i32, b: i32) -> i32 { if a < 1 || b < 1 { ...
//! Improving Our I/O Project with [Iterator] //! //! [iterator]: https://doc.rust-lang.org/book/ch13-03-improving-our-io-project.html use std::env; use std::fs; use std::process; use the_book::ch13::sec03::{search, Config}; fn main() { // parse the command line. let c = Config::new(env::args()).unwrap_or_els...
fn is_valid(num: i64, previous: &[i64]) -> bool { previous.iter() .flat_map(|i| previous.iter().map(move |j| (i,j))) .find_map(|(i,j)| { if (i != j) && (i + j == num) { Some(true) } else { None } ...
mod args; mod stream; pub use args::Args; pub use stream::Stream;
use std::collections::HashMap; // TODO: Needs Improvement struct LRUCache { map: HashMap<i32, i32>, key_age: Vec<(i32, usize)>, capacity: usize, timestamp: usize, } impl LRUCache { fn new(capacity: i32) -> Self { Self { map: HashMap::new(), key_age: Vec::new(), ...
mod event; mod reader; mod writer; pub use event::HttpEvent; pub use reader::{ReaderError, Reader as EventReader}; pub use writer::{WriterError, Writer as EventWriter}; pub const CE_ID_HEADER: &str = "ce-id"; pub const CE_TYPE_HEADER: &str = "ce-type"; pub const CE_SOURCE_HEADER: &str = "ce-source"; pub const CE_SPEC...
// 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::{ errors::{utils::check_slice_size, InternalPakeError, PakeError, ProtocolError}, keypair::{Key, KeyPair, SizedBytes}, ...
fn main() { let proto_root = "../../protobuffers"; println!("cargo:rerun-if-changed={}", proto_root); protoc_grpcio::compile_grpc_protos( &["../../protobuffers/buff.proto"], &[proto_root], &"src/protobuffers", None, ) .expect("Failed to compile gRPC definitions!"); }
struct TextDocumentContentChangeEvent { range: Option<Range>, rangeLength: Option<i32>, text: String, } struct DidChangeTextDocumentParams { textDocument: VersionedTextDocumentIdentifier, contentChanges: Vec<TextDocumentContentChangeEvent>, } impl Notification for DidChangeTextDocumentParams { ...
//! Due to limitations in open-gl every image and font is stored in a texture atlas crated upon //! running the application. use super::*; use math::*; use glium::Rect; pub fn crate_atlas<D>( display: &glium::Display, images: &mut Vec<glium::texture::RawImage2d<D>>, dimensions: &Vec<Vec2<u32>> ) -> (gli...
use anyhow::Error; use git::{init, Rev}; fn main() -> Result<(), Error> { let version = git::version(); println!("git version: {}", version); let git = init().unwrap(); dbg!(&git); let mut revs = Rev::new(&git); revs.add_head_to_pending(); dbg!(&revs.rev_info.total); Ok(()) }
#[doc = "Register `MPCBB1_VCTR47` reader"] pub type R = crate::R<MPCBB1_VCTR47_SPEC>; #[doc = "Register `MPCBB1_VCTR47` writer"] pub type W = crate::W<MPCBB1_VCTR47_SPEC>; #[doc = "Field `B1504` reader - B1504"] pub type B1504_R = crate::BitReader; #[doc = "Field `B1504` writer - B1504"] pub type B1504_W<'a, REG, const...
use std::error::Error as StdError; use std::fmt; use rand::{distributions::Alphanumeric, thread_rng, Rng}; use svc_agent::error::Error as AgentError; //////////////////////////////////////////////////////////////////////////////// #[derive(Debug)] pub enum ClientError { Agent(AgentError), Payload(String), ...
#[doc = "Reader of register RCC_AHB6RSTCLRR"] pub type R = crate::R<u32, super::RCC_AHB6RSTCLRR>; #[doc = "Writer for register RCC_AHB6RSTCLRR"] pub type W = crate::W<u32, super::RCC_AHB6RSTCLRR>; #[doc = "Register RCC_AHB6RSTCLRR `reset()`'s with value 0"] impl crate::ResetValue for super::RCC_AHB6RSTCLRR { type T...
use super::*; use arbitrary::Arbitrary; use std::fs::File; use std::io::prelude::*; use std::fs::remove_file; #[derive(Arbitrary, Debug)] pub struct FromCsvHarnessParams { edge_reader: EdgeFileReaderParams, nodes_reader: Option<NodeFileReaderParams>, directed: bool, } #[derive(Arbitrary, Debug)] pub stru...
use std::io::{self, BufRead}; fn main() { let stdin = io::stdin(); let mut iter = stdin.lock().lines(); let _ = iter.next(); let line = iter.next().unwrap().unwrap(); let mut vs: Vec<i32> = line.split_whitespace() .map(|num| num.parse().unwrap()) ...
//! Azure service bus crate for the unofficial Microsoft Azure SDK for Rust. This crate is part of a collection of crates: for more information please refer to [https://github.com/azure/azure-sdk-for-rust](https://github.com/azure/azure-sdk-for-rust). #![recursion_limit = "128"] // #[macro_use] // extern crate log; /...
use crate::GRID_SIDE; use crate::agent::Id; use crate::rand::Rng; use std::cmp; #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub struct Position { pub x: usize, pub y: usize, } impl Position { pub fn random() -> Position { let mut rng = rand::thread_rng(); Position { x: rng.ge...
use cgmath::{ElementWise, Matrix2, Vector2}; use math::{Aabb, Rot}; use graphics::quad_types::QUAD_VERTICES; #[derive(Copy, Clone)] pub struct Transform { pub pos: Vector2<f32>, pub rot: Rot, pub scale: f32, pub size: Vector2<f32>, } impl Default for Transform { fn default() -> Self { Tran...
#[macro_use] extern crate impl_ops; use minifb::{Scale, Window, WindowOptions}; use scoped_threadpool::Pool; use framebuffer::Framebuffer; use renderer::Program; use vector::Vector3; use crate::matrix::Matrix4; use crate::renderer::RenderRegion; use crate::vector::Vector4; mod framebuffer; mod texture; mod utils; m...
use std::convert::Infallible; use warp::{self, Filter}; use crate::db::Db; use crate::handlers; use crate::models::Customer; /// All customer routes pub fn customer_routes( db: Db, ) -> impl Filter<Extract = impl warp::Reply, Error = warp::Rejection> + Clone { get_customer(db.clone()) .or(update_custo...
use std::collections::HashSet; use anyhow::*; use nom::{ branch::alt, bytes::complete::tag, character::complete::char, character::complete::digit1, combinator::{map, map_res}, sequence::tuple, Finish, IResult, }; #[derive(Debug, Eq, PartialEq, Copy, Clone)] pub enum Op { Acc, Jmp, ...
#[doc = "Register `IER` reader"] pub type R = crate::R<IER_SPEC>; #[doc = "Register `IER` writer"] pub type W = crate::W<IER_SPEC>; #[doc = "Field `ADRDYIE` reader - ADC ready interrupt enable This bit is set and cleared by software to enable/disable the ADC Ready interrupt. Note: The software is allowed to write this ...
use core::cmp; use cast::u32; use stm32::{FLASH, RCC}; use time::Hertz; /// Extension trait that constrains the `RCC` peripheral pub trait RccExt { /// Constrains the `RCC` peripheral so it plays nicely with the other abstractions fn constrain(self) -> Rcc; } impl RccExt for RCC { fn constrain(self) -> ...
pub use self::ai::AiSystem; pub use self::camera::PanningSystem; pub use self::collision::{CollisionSystem, DestroySystemDesc}; pub use self::contract::{AcceptContractSystemDesc, ExpireContractSystem, FulfillContractSystem}; pub use self::move_ships::{ ChaseSystem, DockingSystem, MoveShipsSystem, PatrolSystem,...
enum IpAddr { V4(String), V6(String), } fn route(ip_type: IpAdrrKind) {} fn main() { let ip_v_four = IpAdrr::V4(String::from("127.0.0.1")); let ip_v_six = IpAdrrKind::V6(String::from("::1")); }
use std::net::{TcpListener, TcpStream}; use std::thread; use std::io::BufReader; fn main() { let listener = TcpListener::bind("127.0.0.1:3000").unwrap(); for stream in listener.incoming() { match stream { Err(_) => { /* 적당히 에러처리 */ } Ok(stream) => { // 커넥션 성공, 새...
pub mod buffer; pub mod command; pub mod completion; pub mod container; pub mod editor; pub mod explorer; pub mod find; pub mod keypress; pub mod language; pub mod lsp; pub mod movement; pub mod palette; pub mod panel; pub mod proxy; pub mod scroll; pub mod signature; pub mod split; pub mod source_control; pub mod outl...
use std::sync::Arc; use crate::{ commands::slash, common::{ redis::get, tts::{create_tts_engine, TtsType}, }, data::{DatabasePool, GcpAccessToken}, tasks, }; use api_models::guild::Guild as GuildModel; use regex::Regex; use serenity::{ async_trait, client::{Context, EventHan...
pub use self::aggregate::Aggregate; pub use self::filter::{Filter, FilterPredicate}; pub use self::join::{Join, JoinPredicate}; pub use self::project::ProjectIterator; pub use self::seqscan::SeqScan; pub use self::tuple_iterator::TupleIterator; use common::{CrustyError, TableSchema, Tuple}; mod aggregate; mod filter; ...
fn main() { let mut m1: Vec<Vec<f64>> = vec![vec![1.0,2.0],vec![3.0,4.0]]; let mut r_m1 = &mut m1; let rr_m1 = &mut r_m1; let mut m2: Vec<Vec<f64>> = vec![vec![1.0, 2.0, 3.0, 4.0], vec![4.0, 5.0, 6.0, 7.0], vec![7.0, 8.0, 9.0, 10.0], vec![10.0, 11.0, 12.0, 13.0]]; let mut r_m2 = &mut...
//! Static predicate traits. use std::fmt::Debug; std_prelude!(); /// A predicate over a single variable. /// /// For a given `T` implementing `Predicate`, /// `T::default().fmt(..)`` should print the name /// of the predicate, with angle brackets to indicate /// generic predicate parameters. pub trait Pred<T: ?Sized...
use { super::{ localmap::{local_key, Entry, LocalKey}, Input, }, crate::error::Error, http::header::{HeaderName, HeaderValue}, mime::Mime, }; pub trait FromHeaderValue: Sized { type Error: Into<Error>; fn from_header_value(h: &HeaderValue) -> Result<Self, Self::Error>; } i...
/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT license. */ pub mod scratch_traits; pub use scratch_traits::*; pub mod concurrent_queue; pub use concurrent_queue::*; pub mod pq_scratch; pub use pq_scratch::*; pub mod inmem_query_scratch; pub use inmem_query_scratch::*; pu...
use std::collections::BTreeMap; type Map<T> = BTreeMap<String, T>; #[derive(Debug, Clone, Copy)] enum Binop { Add, Sub, Mul, Eq, } #[derive(Debug, Clone)] enum Value { IntVal(i32), BoolVal(bool), Closure(String, Box<Expr>, Map<Box<Value>>), } #[derive(Debug, Clone)] enum Expr { IntLi...
// This file is part of Substrate. // Copyright (C) 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 // // http://...
use crate::{ alloc::{Allocator, GlobalAllocator}, containers::Array, }; use core::{ borrow::Borrow, ops::{Deref, DerefMut}, }; pub struct WString<A: Allocator = GlobalAllocator> { buf: Array<u16, A>, } impl<A: Allocator> WString<A> { pub fn new_with(alloc: A) -> Self { Self { ...
use crate::types; #[derive(Clone, Debug, PartialEq)] pub struct Declaration { name: String, type_: types::Function, } impl Declaration { pub fn new(name: impl Into<String>, type_: types::Function) -> Self { Self { name: name.into(), type_, } } pub fn name(&...
use crate::appkit::NSMenuItem; use crate::base::id; // https://developer.apple.com/documentation/appkit/nsmenu #[derive(Clone, Copy, Debug)] #[repr(C)] pub struct NSMenu(id); impl Default for NSMenu { fn default() -> Self { Self::new() } } impl NSMenu { pub fn new() -> Self { Self(unsafe { msg_send!(cl...
use z80::Z80; /* ** BIT b, r|(hl) ** Condition Bits: R01_ ** Clocks: ** (hl): 3 ** r: 2 */ pub fn bit(z80: &mut Z80, op: u8) { let val = match op & 0x7 { 0x6 => z80.mmu.rb(z80.r.get_hl()), 0x7 => z80.r.a, 0x0 => z80.r.b, 0x1 => z80.r.c, 0x2 => z80.r.d, ...
use shrev::*; use specs::*; use types::*; use dispatch::SystemInfo; use component::channel::*; use component::counter::*; use component::event::TimerEvent; use component::time::ThisFrame; use protocol::server::ScoreUpdate; use protocol::{to_bytes, ServerPacket}; use websocket::OwnedMessage; pub struct UpdateScore ...
mod add; mod build; mod check; mod cmin; mod coverage; mod fmt; mod init; mod list; mod run; mod tmin; pub use self::{ add::Add, build::Build, check::Check, cmin::Cmin, coverage::Coverage, fmt::Fmt, init::Init, list::List, run::Run, tmin::Tmin, }; use clap::{Parser, ValueEnum}; use std::{fmt as stdfmt, path::...
#![allow(dead_code)] use crate::utils::environment; use std::path::PathBuf; use std::{env, fs}; use rand::distributions::Alphanumeric; use rand::Rng; #[macro_export] macro_rules! assert_match { ($pattern:pat, $var:expr) => { assert!(match $var { $pattern => true, _ => false, ...
#[derive(Debug, Copy, Clone)] pub struct EnvelopePoint { pub(crate) frame: u16, pub(crate) value: u16 } impl EnvelopePoint { pub(crate) fn new() -> EnvelopePoint { EnvelopePoint{ frame: 0, value: 0 } } } pub type EnvelopePoints = [EnvelopePoint;12]; #[der...
#![doc = "generated by AutoRust 0.1.0"] #![allow(unused_mut)] #![allow(unused_variables)] #![allow(unused_imports)] use super::{models, API_VERSION}; #[non_exhaustive] #[derive(Debug, thiserror :: Error)] #[allow(non_camel_case_types)] pub enum Error { #[error(transparent)] WebApps_List(#[from] web_apps::list::...
use std::cell::RefCell; use std::rc::Rc; use crate::treenode::TreeNode; pub fn build_tree(preorder: Vec<i32>, inorder: Vec<i32>) -> Option<Rc<RefCell<TreeNode>>> { fn build_tree_by_slice(preorder: &[i32], inorder: &[i32]) -> Option<Rc<RefCell<TreeNode>>> { match preorder.len() { 0 => None, ...
use std::env; use std::fs::*; use clap::*; use serde::{Serialize, Deserialize}; use std::io::prelude::*; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct ProgramArgs { pub input_file: String, pub output_file: String, pub printbed_width: f32, pub printbed_height: f32, pub scali...
use async_std::io; use async_trait::async_trait; use crate::Request; #[async_trait] pub trait Middleware: Send + Sync { async fn call(&self, request: &mut Request<'_>) -> io::Result<()>; } /// Log all requests. pub struct Logger {} impl Default for Logger { fn default() -> Self { femme::pretty::Logg...
pub use crate::{ db::HirDatabase, error::HirError, expressions::{ AscriptionExprData, AssignmentData, BlockExprData, CallExprData, ExpressionData, FieldExprData, IfExprData, LiteralData, LiteralKind, MatchExprData, RecordExprData, StatementData, }, ident::{IdentifierData, Sco...
//! Things related to making VapourSynth plugins. use anyhow::Error; use crate::api::API; use crate::core::CoreRef; use crate::frame::FrameRef; use crate::function::Function; use crate::map::{self, Map, Value, ValueIter}; use crate::node::Node; use crate::video_info::VideoInfo; mod frame_context; pub use self::frame...
use sudo_test::{Command, Env, TextFile}; use crate::{Result, USERNAME}; #[test] fn signal_sent_by_child_process_is_ignored() -> Result<()> { let script = include_str!("kill-su-parent.sh"); let script_path = "/tmp/script.sh"; let env = Env("") .user(USERNAME) .file(script_path, TextFile(sc...
struct Node { val: i32, next: Option<Box<Node>>, } impl Node { fn new(val: i32) -> Self { Node { val, next: None } } fn insert(&mut self, val: i32) { match &mut self.next { Some(n) => { n.insert(val) }, ...
pub fn rand(min: i32, max: i32) -> i32 { Rando }
use crate::network::message::{GameState, PaddleState}; #[cfg(not(target_arch = "wasm32"))] use log::*; use nalgebra::{Isometry2, Point2, Vector2}; use ncollide2d::query::Proximity; use ncollide2d::shape::Cuboid; use ncollide2d::{query, shape}; #[cfg(target_arch = "wasm32")] use quicksilver::log::*; #[derive(Debug)] pu...
use crate::helpers::{Fd, Shell}; use crate::lexer::Token::{self, *}; use crate::lexer::{ Action, Expand::{self, *}, Op, }; use nix::unistd::User; use os_pipe::pipe; use std::cell::RefCell; use std::collections::HashMap; use std::env; use std::io::Write; use std::iter::Peekable; use std::process::exit; use s...
use std::collections::HashMap; use amethyst::assets::{AssetStorage, Handle, Loader}; use amethyst::ecs::World; use amethyst::renderer::{ ImageFormat, SpriteRender, SpriteSheet, SpriteSheetFormat, Texture}; use amethyst::prelude::WorldExt; #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub enum SpriteSheets { ...
use libc::{c_void, c_char}; use super::ObsData; pub enum ObsSource {} extern { pub fn rust_obs_register_input_source( id: *const c_char, new: extern fn(settings: *mut ObsData, source: *mut ObsSource) -> *mut c_void, width: unsafe extern fn(this: *mut c_void) -> u32, height: unsafe ...
//! This module contains basic methods to manipulate the contents of local directories. //! All methods in this module represent cross-platform filesystem operations. use std::fs; use error::Error; use operation::Operation; use super::Result; use super::exists as exists; /// Recursively creates the directory indicat...
use std::f32; use std::f32::consts as math_consts; use modulator::foc_modulator as foc; use platform_traits::pwm_inverter as pwm; use platform_traits::current_sensor as cs; use platform_traits::rotor_position_sensor as encoder; use platform_traits::blocking_delay as delay; use foc_types::types as t; use pid_controller:...
use super::*; //#[test] fn show_circles() { println!("CIRCLES "); for (circle, span) in CIRCLES_SPAN.iter() { println!("diameter: {}", circle.radius * 2.0); println!(); println!("{}", span); println!(); println!(); } println!("QUARTER ARCS:"); for (diameter, ...
/// An enum to represent all characters in the VariationSelectorsSupplement block. #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)] pub enum VariationSelectorsSupplement { /// \u{e0100}: '󠄀' VariationSelectorDash17, /// \u{e0101}: '󠄁' VariationSelectorDash18, /// \u{e0102}: '󠄂' VariationSe...
mod deck; fn main() { //let mut st: deck::Deck = deck::new(); let mut deck = deck::Deck::new(); loop { let card = deck.pop(); match card { None => break, Some(card) => println!("{}", card) } } } // fn main_loop(st: &mut deck::Deck) { // main_loop(st); /...
// cross module macros go here #[macro_export] macro_rules! vm_panic { ($s: expr, $err: expr) => { println!("!! Lua VM crash"); // TODO unwind the entire frame stack here for more information let f = &$s.current_frame; let (line_no, lines) = f.code.sourcemap.get_lines_for_bytecode(f....