text
stringlengths
8
4.13M
use crate::vm::{ builtins::PyListRef, builtins::PyModule, PyObject, PyObjectRef, PyRef, PyResult, TryFromObject, VirtualMachine, }; use std::{io, mem}; pub(crate) fn make_module(vm: &VirtualMachine) -> PyRef<PyModule> { #[cfg(windows)] crate::vm::stdlib::nt::init_winsock(); #[cfg(unix)] { ...
extern crate quicksilver; use quicksilver::{ Result, geom::{Shape, Rectangle, Vector}, graphics::{Background::Col, Color}, input::MouseCursor, lifecycle::{Event, Settings, State, Window, run} }; struct RectangleState { grab_rect: Rectangle, crosshair_rect: Rectangle, } impl State for Rect...
#![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 GameSaveBlobGetResult(pub ::windows::core::IIn...
/// Trait implemented by all drawable charts providing the interface for drawing functionality. pub trait Chart { /// Draws the chart specified for the instance that this function is called on. fn draw(&self); }
#[tokio::main(flavor = "multi_thread")] async fn main() { println!("#test-1-inv-broker-sub-proc started") }
// Box Widget // Extensible widget for the widget library - handles drawing a box with a border and a fill color // // 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.or...
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] pub const DXCORE_ADAPTER_ATTRIBUTE_D3D11_GRAPHICS: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8c47866b_7583_450d_f0f0_6bada895af4b); pub const DXCORE_ADAPTER_ATTRIBUTE_D3D12_C...
use llvm; use llvm::prelude::*; use llvm::execution_engine::LLVMExecutionEngineRef; use std; use std::os::raw::c_char; use std::ffi::CString; use ir::Atom; use backend::Backend; const MEM_SIZE: isize = 30000; #[derive(Debug, Clone)] pub struct LLVMBackend { module: LLVMModuleRef, brainfuck_fn: LLVMValueRef, ...
use clap::{App, Arg, ArgMatches, SubCommand}; pub fn build_cli() -> App<'static, 'static> { App::new("mender-rust") .version("0.1.0") .author("V. Hubert <v-hubert@laposte.net>") .about("A small command line tool to perform tasks on a Mender server using its APIs.") .after_help( ...
fn main() { let mut v = vec![1,2,3]; let x = v.pop(); // fill up the missing parts match { => println!("stack empty"), Some() => println!("{}", ), } }
use crate::lib::math::vector::Vec2; use crate::lib::rendering::gl_render::{ImageRenderer, Texture}; use crate::lib::rendering::camera::*; use crate::lib::math::matrix::*; pub struct Bullet { position: Vec2<f32>, velocity: Vec2<f32>, } impl Bullet { pub fn new(position: Vec2<f32>, facing: Vec2<f32>) -> Bulle...
#[doc = "Reader of register ICR"] pub type R = crate::R<u32, super::ICR>; #[doc = "Reader of field `SEIF`"] pub type SEIF_R = crate::R<bool, bool>; #[doc = "Reader of field `XONEIF`"] pub type XONEIF_R = crate::R<bool, bool>; #[doc = "Reader of field `KEIF`"] pub type KEIF_R = crate::R<bool, bool>; impl R { #[doc =...
use crate::Point; use num_traits::Float; /// Returns the bearing to another Point in degrees. /// /// Bullock, R.: Great Circle Distances and Bearings Between Two Locations, 2007. /// (https://dtcenter.org/met/users/docs/write_ups/gc_simple.pdf) pub trait Bearing<T: Float> { /// Returns the bearing to another Poi...
pub trait ModI: Sized + Copy + std::ops::Add<Output = Self> + std::ops::Sub<Output = Self> + std::ops::Mul<Output = Self> + std::ops::Div<Output = Self> + std::ops::AddAssign + std::ops::SubAssign + std::ops::MulAssign + std::ops::DivAssign + std::default::Default + std::...
use diesel::prelude::*; use super::context::Context; use super::resolver::Member; use crate::schema::members; pub struct MutationRoot; #[juniper::object(Context = Context)] impl MutationRoot { fn create_member(context: &Context, data: NewMember) -> Member { let connection = context.db.get().unwrap();; ...
use serde::{Deserialize, Serialize}; use std::fs; #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct BlackmagicCameraProtocol { pub information: Information, pub groups: Vec<Group>, #[serde(rename = "bluetooth_services")] pub bluetooth_serv...
pub use game_1::{Game1}; use std::ops::{Deref,DerefMut}; pub type LowerGame = Game1; pub struct SpellGame{ pub lower_game: LowerGame } impl Deref for SpellGame{ type Target = LowerGame; fn deref(&self)->&Self::Target{ &self.lower_game } } impl DerefMut for SpellGame{ fn deref_mut(&mut self)->&mut Self::Targe...
//! is-terminal is a simple utility that answers one question: //! //! > Is this a terminal? //! //! A "terminal", also known as a "tty", is an I/O device which may be //! interactive and may support color and other special features. This crate //! doesn't provide any of those features; it just answers this one questio...
use std::fs::File; use std::io::{Read}; extern crate html5ever; extern crate clap; extern crate regex; use html5ever::{parse, one_input}; use html5ever::rcdom::RcDom; use clap::{Arg, App, SubCommand}; use regex::Regex; struct ModelValues { main_values: String, comparisons: Vec<String> } fn open_file(path:...
// 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 ...
use crate::{HdbError, HdbResult}; #[cfg(feature = "sync")] use byteorder::WriteBytesExt; use byteorder::{BigEndian, LittleEndian, ReadBytesExt}; pub(crate) const MAX_1_BYTE_LENGTH: u8 = 245; pub(crate) const MAX_2_BYTE_LENGTH: i16 = i16::max_value(); const LENGTH_INDICATOR_2BYTE: u8 = 246; const LENGTH_INDICATOR_4BYT...
#[macro_export] macro_rules! extend_module { ( $vm:expr, $module:expr, { $($name:expr => $value:expr),* $(,)? }) => {{ $( $vm.__module_set_attr($module, $vm.ctx.intern_str($name), $value).unwrap(); )* }}; } #[macro_export] macro_rules! py_class { ( $ctx:expr, $class_name:expr, $...
use std::collections::HashMap; use crate::idl; use super::errors::ValidationError; use super::namespace::Namespace; use super::r#type::Type; use super::typemap::TypeMap; pub struct Service { pub name: String, pub methods: Vec<Method>, } pub struct Method { pub name: String, pub input: Option<Type>, ...
// 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 ...
use futures01::Future; use snafu::Snafu; #[cfg(feature = "sources-docker")] pub mod docker; #[cfg(feature = "sources-file")] pub mod file; #[cfg(feature = "sources-generator")] pub mod generator; #[cfg(feature = "sources-http")] pub mod http; #[cfg(feature = "sources-internal_metrics")] pub mod internal_metrics; #[cfg...
#![feature(const_fn)] extern crate glfw; extern crate gl; extern crate state; use engine::*; use glfw::{Action, Context, Key, WindowHint, OpenGlProfileHint, WindowMode, Window, WindowEvent, CursorMode}; use std::sync::mpsc::Receiver; use ecs::components::*; use specs::prelude::*; use ecs::systems::*; use ecs::resourc...
use super::not_found; use crate::{ error::AppError, models::{entry, entry_tag, tag}, state::AppState, }; use axum::{ http::{header, StatusCode}, response::{IntoResponse, Response}, }; use minijinja::context; use sea_orm::{entity::prelude::*, query::*, sea_query::Query}; use std::sync::Arc; pub async fn view( app...
#![cfg_attr(not(feature = "std"), no_std)] use ink_env::{ hash::{Blake2x256, CryptoHash, HashOutput}, AccountId, }; use ink_prelude::vec::Vec; use ink_prelude::string::String; use ink_storage::traits::{PackedLayout, SpreadLayout}; /// 主合约错误信息 #[derive(Debug, PartialEq, Eq, scale::Encode, scale::Decode)] #[cf...
use serde::Deserialize; use sqs_executor::{ errors::{ CheckedError, Recoverable, }, event_decoder::PayloadDecoder, }; use crate::decoder::decompress::PayloadDecompressionError; #[derive(thiserror::Error, Debug)] pub enum JsonDecoderError { #[error("DecompressionError")] Decompressi...
use std::convert::TryInto; use std::ffi::c_void; use std::mem; use std::ptr::NonNull; use liblumen_alloc::erts::apply::find_symbol; use liblumen_alloc::erts::exception::InternalResult; use liblumen_alloc::erts::term::closure::{Definition, OldUnique}; use liblumen_alloc::erts::term::prelude::*; use liblumen_alloc::erts...
use ipfs_unixfs::file::adder::FileAdder; use basex_rs::{BaseX, BITCOIN, Encode}; use ipfs_unixfs::file::adder::Chunker; use ipfs_unixfs::file::adder::BalancedCollector; /* 【输入】 digest 需要计算hash的文件字节流 【输出】 Option类型、计算后的hash */ pub fn only_hash(digest : &Vec<u8>) -> Option<String> { // let mut...
// 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 agre...
// 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 agre...
use askama::Template; use serde::Deserialize; use crate::database as db; use deadpool_postgres::Pool; use crate::{utils::cache_long, socket}; #[derive(Template)] #[template(path = "login.html")] struct LoginTemplate { redirect_url: String, google_auth_url: String, } #[derive(Deserialize)] pub struct LoginQuer...
mod shared; #[cfg(feature = "local-testing")] #[tokio::test] async fn test_activity() { use shared::ds::{self, activity}; shared::init_logger(); let dual = shared::make_dual_clients(ds::Subscriptions::ACTIVITY) .await .expect("failed to start clients"); let shared::DualClients { one,...
#[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let influx_url = "some-url"; let token = "some-token"; let client = influxdb2_client::Client::new(influx_url, token); println!("{:?}", client.ready().await?); Ok(()) }
mod lib; fn main() { match lib::INIContext::new( "./test.ini", true ) { Ok( tree ) => { println!( "{:?} ou {:?}", tree.search( "generaly".to_string(), "name".to_string() ), tree.search( "generaly".to_string(), "rien".to_string() ) ); }, Err( err ) => println!( "err : {:?}", err ) }...
// 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 ...
use std::ops::{Deref, DerefMut}; use crate::ast; use crate::code::Code; use crate::context::{Build, CloneSafe, Context}; use crate::error::{Result, TensorNodeError}; use crate::execs::ExecIR; use crate::externs::ExternIR; use crate::graph::{RefGraph, Values}; use crate::nodes::{builtins, ASTBuild, NodeIR, NodeRoot}; u...
fn main() { // define a variable // let x = 5; // this is wrong! // coz x is immutable // x = 10; // define a immutable variable let mut x = 5; x = 10; // define a tuple let (y,z) = (1,2); let mut z = 5; let w = ( z = 6 ); // w has the value `()`, not `6` // w cannot be printed, as it is a tuple // prin...
//! Contains the `RSmallBox<_>` type. use crate::{ pointer_trait::{ AsMutPtr, AsPtr, CallReferentDrop, CanTransmuteElement, Deallocate, GetPointerKind, OwnedPointer, PK_SmartPointer, }, sabi_types::MovePtr, std_types::RBox, }; use std::{ alloc::{self, Layout}, fmt::{self, Displ...
mod error; mod audio; mod events; //mod events_term; mod token; use std::path::PathBuf; use events::Event; use hex_database::{Instance, Token, GossipConf}; fn main() { env_logger::init(); let (conf, path) = match hex_conf::Conf::new() { Ok(x) => x, Err(err) => { eprintln!("Error:...
use crate::types::*; use neo4rs_macros::BoltStruct; #[derive(Debug, PartialEq, Clone, BoltStruct)] #[signature(0xB3, 0x58)] pub struct BoltPoint2D { pub sr_id: BoltInteger, pub x: BoltFloat, pub y: BoltFloat, } #[derive(Debug, PartialEq, Clone, BoltStruct)] #[signature(0xB4, 0x59)] pub struct BoltPoint3D ...
const START: u32 = 347_312; const END: u32 = 805_915 + 1; // +1 so we can use exclusive ranges which are much more performant pub fn part1() -> usize { (START..END) .map(digits) .filter(|digits| is_in_order(digits) && has_multiple(digits)) .count() } pub fn part2() -> usize { (START..E...
#[cfg(test)] mod tests { fn bad(a: DoesNotExist) { // ^^^^^^^^^^^^ERR(<1.16.0) undefined or not in scope // ^^^^^^^^^^^^ERR(<1.16.0) type name // ^^^^^^^^^^^^HELP(<1.16.0) no candidates // ^^^^^^^^^^^^ERR(>=1.16.0,test) not found in this scope // ^^^^^^^^^^^^ER...
//! Named pipes use std::ffi::OsStr; use std::fs::{OpenOptions, File}; use std::io::prelude::*; use std::io; use std::os::windows::ffi::*; use std::os::windows::io::*; use std::time::Duration; use winapi::*; use kernel32::*; use handle::Handle; /// Readable half of an anonymous pipe. #[derive(Debug)] pub struct Anon...
const LINE_DBF: &str = "./tests/data/line.dbf"; const NONE_FLOAT_DBF: &str = "./tests/data/contain_none_float.dbf"; extern crate dbase; use std::collections::HashMap; use std::io::{Cursor, Seek, SeekFrom}; #[test] fn test_none_float() { let records = dbase::read(NONE_FLOAT_DBF).unwrap(); assert_eq!(records.l...
extern crate libc; #[no_mangle] pub extern "C" fn count_substrings(value: *const libc::c_char, substr: *const libc::c_char) -> i32 { let mut count: i32 = -1; let c_value = unsafe { std::ffi::CStr::from_ptr(value) }; let value = c_value.to_str(); let c_substr = unsafe { std::ffi::CStr::from_ptr(substr) ...
// 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, fidl_fuchsia_settings::*}; pub async fn command( proxy: PrivacyProxy, user_data_sharing_consent: Option<bool>, ) -> Result<St...
use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize, Debug)] pub struct RigidBody { pub name: String, pub status: RigidBodyStatus, } #[derive(Serialize, Deserialize, Debug)] pub enum RigidBodyStatus { Static, Dynamic, Kinematic, } #[derive(Serialize, Deserialize, Debug)] pub stru...
use super::search::get_all_files; use chrono::{Duration, DateTime, Local}; pub fn get_tracker_stats_all(password: &String) -> Vec<(String, Vec<(String, Vec<f64>, Vec<String>)>)> { let files = get_all_files(password); let mut return_vec = vec!(); for (filename, plaintext) in files { let mut o...
extern crate futures; use futures::*; use futures::stream::Stream; struct CounterStream { index: i32, limit: i32, } fn counter(limit: i32) -> CounterStream { CounterStream{index: 0, limit: limit} } impl Stream for CounterStream { type Item = i32; type Error = (); fn poll(&mut self, _task: &...
//! I2C use core::ops::Deref; use crate::hal::blocking::i2c::{Read, Write, WriteRead}; use crate::gpio::gpioa::{PA10, PA13, PA9}; use crate::gpio::gpiob::{PB6, PB7}; use crate::gpio::{AltMode, OpenDrain, Output}; use crate::pac::{i2c1::RegisterBlock, I2C1}; use crate::rcc::Rcc; use crate::time::Hertz; use cast::u8; ...
use xassembler::{compile, Target}; pub trait Compile: Target { const BUILD_DIR_NAME: &'static str; const PRELUDE: &'static str; const TERMINATE: &'static str; fn compile_subcommand(compiled: &str, dependeny_paths: Vec<&str>, output_path: &str) -> Result<(), String>; fn run_subcommand(compiled: &st...
pub fn cleanup_temp_files() { println!("Cleaning up temp files.. not implemented. Cannot delete temp* files"); }
use crate::monsters::Monster; pub mod lava_dragon; pub trait Dragon: Monster {}
use crate::ir::eval::prelude::*; impl IrEval for ir::IrBinary { type Output = IrValue; fn eval( &self, interp: &mut IrInterpreter<'_>, used: Used, ) -> Result<Self::Output, IrEvalOutcome> { use std::ops::{Add, Mul, Shl, Shr, Sub}; let span = self.span(); in...
#[cfg(not(feature = "binary"))] fn main() {} #[cfg(feature = "binary")] fn address_from_env(env: &'static str) -> Option<u64> { use std::env; match env::var(env) { Err(env::VarError::NotPresent) => None, Err(env::VarError::NotUnicode(_)) => { panic!("The `{}` environment variable mu...
#![deny(rustdoc::broken_intra_doc_links, rust_2018_idioms)] #![warn( clippy::clone_on_ref_ptr, clippy::dbg_macro, clippy::explicit_iter_loop, // See https://github.com/influxdata/influxdb_iox/pull/1671 clippy::future_not_send, clippy::todo, clippy::use_self, missing_debug_implementations...
pub mod assembler; pub mod instructions; pub mod repl; pub mod vm; extern crate nom; fn main() { let mut r = repl::REPL::new(); r.run(); }
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "Win32_Foundation")] #[inline] pub unsafe fn CryptSIPAddProvider(psnewprov: *mut SIP_ADD_NEWPROVIDER) -> super::super::super::Foundation::BOOL { #[cfg(windows)] { ...
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub type GattCharacteristic = *mut ::core::ffi::c_void; #[repr(transparent)] pub struct GattCharacteristicProperties(pub u32); impl GattCharacteristicProperties...
const INPUT: &str = include_str!("../../input/01"); fn solution(input: &str) -> i32 { input.lines().filter_map(|x| x.parse::<i32>().ok()).sum() } fn main() { println!("Solution: {}", solution(INPUT)); } #[cfg(test)] mod tests { use super::*; #[test] fn chronal_calibration_part_1() { asse...
#[doc = "Reader of register SECWM1R2"] pub type R = crate::R<u32, super::SECWM1R2>; #[doc = "Writer for register SECWM1R2"] pub type W = crate::W<u32, super::SECWM1R2>; #[doc = "Register SECWM1R2 `reset()`'s with value 0x0f00_0f00"] impl crate::ResetValue for super::SECWM1R2 { type Type = u32; #[inline(always)]...
use std::sync::{ Once, ONCE_INIT }; use std::intrinsics::abort; use std::{ mem, ptr }; use rand::{ thread_rng, Rng, OsRng }; use errno::{ Errno, set_errno }; const GARBAGE_VALUE: u8 = 0xd0; const CANARY_SIZE: usize = 16; static ALLOC_INIT: Once = ONCE_INIT; static mut PAGE_SIZE: usize = 0; static mut CANARY: [u8; CAN...
//! Device module docs. use std::{borrow::Borrow, fmt::Debug}; use resource; use fence::FenceCreateInfo; /// Abstract logical device. /// It inherits methods to allocate memory and create resources. pub trait Device: resource::Device { /// Semaphore type that can be used with this device. type Semaphore: Deb...
#![allow(non_snake_case, non_camel_case_types, dead_code)] #[repr(C)] pub struct stbtt__buf{ data: *mut u8, cursor: i32, size: i32, } #[inline] pub const fn new_stbtt__buf()->stbtt__buf{ stbtt__buf{ data: std::ptr::null_mut(), cursor: 0, size: 0, } } #[repr(C)] pub struct stbt...
//! `cargo run --example bulb` fn main() -> Result<(), Box<dyn std::error::Error>> { env_logger::init(); let mut bulb = tplink::Bulb::new([192, 168, 1, 107]); bulb.turn_on()?; assert_eq!(bulb.is_on()?, true); if let Err(e) = bulb.set_brightness(0) { println!("{}", e); } bulb.tur...
/* 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...
pub mod component; pub mod entity; pub mod light; pub mod material; pub mod model; pub mod transform; use std::cell::{Cell, RefCell}; use std::fmt::Debug; use std::rc::{Rc, Weak}; use crate::core::input::Input; use self::component::camera_component::CameraComponent; use self::entity::Entity; use self::light::Light; ...
#[cfg(test)] extern crate statechart; use statechart::interpreter::Interpreter; #[test] fn common_ancestor() { let l = vec![0, 1, 1, 3, 4]; let r = vec![0, 1, 2, 3, 1]; let a = Interpreter::common_ancestor(&l, &r); assert_eq!(a, vec![0, 1]); let a = Interpreter::common_ancestor(&r, &l); asser...
use image::DynamicImage; use image::GenericImage; use image::GenericImageView; use image::Rgba; use std::cmp::min; use std::path::PathBuf; use std::time::Instant; fn main() { // 何分の一にするか let mut ratio = String::new(); std::io::stdin().read_line(&mut ratio).ok(); // u32型に変換 let ratio: u32 = ratio.tr...
use super::Exception; #[repr(C)] #[derive(Clone, Copy, Debug)] pub enum Fault { Syscall, Interrupt, Exception(Exception), } impl Default for Fault { fn default() -> Self { Fault::Syscall } }
use serenity::prelude::*; use serenity::model::prelude::*; use serenity::framework::standard::{ Args, CommandResult, macros::command, }; use serenity::utils::Colour; use requests::ToJson; use std::collections::HashMap; use std::env; use std::time::Instant; use std::sync::mpsc; use std::thread; use std::sync::...
#[ic_cdk_macros::query] fn print() { ic_cdk::print("Hello World"); }
#[derive(Clone)] pub struct Timer { interrupt: u8, div: u8, tima: u8, tma: u8, tac: u8, } impl Timer { pub fn init() -> Self { Self { interrupt: 0, div: 0, tima: 0, tma: 0, tac: 0, } } } impl Timer { ...
// Copyright 2018 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 ...
#![feature(test)] use rand; extern crate test; #[macro_use] extern crate morgan; use rand::seq::SliceRandom; use rand::{thread_rng, Rng}; use morgan::blockBufferPool::{get_tmp_ledger_path, Blocktree}; use morgan::entryInfo::{make_large_test_entries, make_tiny_test_entries, EntrySlice}; use morgan::packet::{Blob, BLO...
extern crate multiinput; use multiinput::*; fn main() { let mut manager = RawInputManager::new().unwrap(); manager.register_devices(DeviceType::Joysticks(XInputInclude::True)); manager.register_devices(DeviceType::Keyboards); manager.register_devices(DeviceType::Mice); manager.print_device_list(); ...
use actix_web::http::StatusCode; use failure::Fail; #[derive(Debug, Fail)] pub enum ServiceError { #[fail(display = "invalid username: {}", _0)] InvalidUsername(String), #[fail(display = "failed to send request with error: {}", _0)] SendRequest(String), #[fail(display = "unexpected status code: {...
// Boats to Save People // https://leetcode.com/explore/challenge/card/january-leetcoding-challenge-2021/580/week-2-january-8th-january-14th/3602/ pub struct Solution; impl Solution { pub fn num_rescue_boats(people: Vec<i32>, limit: i32) -> i32 { let mut people = people.clone(); people.sort_unstab...
pub trait Stringable { fn to_s(&self) -> String; }
// This file is part of syslog2. 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/syslog2/master/COPYRIGHT. No part of syslog2, including this file, may be copied, modified, propagated, or distributed except...
use crate::Position; #[derive(Copy, Clone, Debug)] pub enum Key { // FIXME there has to be a more generic way A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, N0, N1, N2,...
use std::env; use std::error; use std::fs; fn main() -> Result<(), Box<dyn error::Error>> { let file = fs::File::open(wordcount_core::parse_file_name(env::args())?)?; let config = wordcount_core::Config::new(file)?; let word_count = wordcount_core::WordCount::new(config, |a, b| b.cmp(&a)); print!("{}"...
use std::fs::File; fn main() -> Result<(), std::io::Error> { let f = File::open("bar.txt")?; Ok(()) }
#![allow(non_upper_case_globals)] extern crate spatialos_sdk_sys; pub(crate) mod ptr; pub mod worker;
/////////////////////////////////////////////////////////////////////// /// /// https://adventofcode.com/2019/day/1 /// /// This binary calculates day 1 part 1 and 2 results. /////////////////////////////////////////////////////////////////////// use std::env; use std::fs::File; use std::io; use std::io::prelude::*; us...
pub struct Stream<'a> { data: &'a [u8], seek: usize, shift: usize, } impl<'a> Stream<'a> { pub fn new(data: &'a [u8]) -> Stream { Stream { data: data, seek: 0, shift: 0, } } pub fn has_next(&self) -> bool { self.seek < self.data.len() } pub fn next_byte(&mut self) -> u8 ...
// Workaround for clippy bug. #![allow(clippy::unnecessary_wraps)] mod print; mod lexer; mod ast; mod ty; use lexer::{Keyword, Token, Literal, IntegerSuffix, Lexer, Base}; pub use ast::{UnaryOp, BinaryOp, Expr, TypedExpr, Stmt, Body, BodyRef}; pub use ty::{TyKind, Ty}; #[derive(Clone, Debug, PartialEq, Eq)] pub stru...
use crate::core::transform::Transform; use crate::gameplay::collision::{CollisionLayer, CollisionWorld, Ray}; use hecs::Entity; use rand::Rng; const CLOSE_ENOUGH: f32 = 50.0; pub mod behavior; /// Will compute the force to move towards a target without slowing down. /// /// # Returns /// the force to apply to the en...
macro_rules! deconstruction { ($id:ident, $t:pat, $($p: expr),*) => { let mut bar = Vec::new(); for i in $id { match i { $t => {$(bar.push($p);)*}, _ => {}, } } let mut $id = bar.clone(); } } fn main() { let foo = vec!...
use super::*; #[derive(Default)] pub struct RenderState { pub(crate) visible: bool, pub render_skeleton: bool, pub render_position: bool, pub render_particles: bool, pub render_physics: bool, // Taken from http://urraka.github.io/soldat-map/#171/Airpirates pub disable_backgrou...
/*! see https://github.com/thewebdevel/codeframe for high level description of the library */ pub mod capture; pub mod codeframe_builder; pub mod codeframe_macro; pub mod color; mod utils; pub use crate::capture as capture_codeframe; pub use crate::codeframe_builder::Codeframe; pub use color::Color;
// plotters use plotters::prelude::*; // DenseMatrix wrapper around Vec use smartcore::linalg::naive::dense_matrix::DenseMatrix; use smartcore::linalg::BaseMatrix; use smartcore::math::num::RealNumber; /// Get min value of `x` along axis `axis` pub fn min<T: RealNumber>(x: &DenseMatrix<T>, axis: usize) -> T { let ...
//! File system with inode support //! //! Create a filesystem that has a notion of inodes and blocks, by implementing the [`FileSysSupport`], //! the [`BlockSupport`] and the [`InodeSupport`] traits together (again, all earlier traits are //! supertraits of the later ones). //! //! [`FileSysSupport`]: ../../cplfs_api/...
enum Order { Asc, Desc, } struct QueryBuilder { table: String, fields: Vec<String>, filters: Vec<String>, order: Option<Order>, order_field: Option<String>, } impl<'a> QueryBuilder { fn new() -> QueryBuilder { return QueryBuilder { table: String::new(), ...
// 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. //! Traits for use with the rust client library for cobalt. /// `AsEventCodes` is any type that can be converted into a `Vec<u32>` for the purposes of sto...
//! 2D physics ECS pub use collide2d::*; pub use core::physics2d::*; pub use physics::setup_dispatch_2d; use cgmath::{Basis2, Point2, Vector2}; use collision::primitive::Primitive2; use collision::Aabb2; use physics::{ ContactResolutionSystem, CurrentFrameUpdateSystem, DeltaTime, NextFrameSetupSystem, Physic...
// 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 ...