text stringlengths 8 4.13M |
|---|
use num_traits::Float;
use crate::algorithm::intersects::Intersects;
use crate::{
Coordinate, CoordinateType, Line, LineString, MultiPolygon, Point, Polygon, Rect, Triangle,
};
/// Checks if the geometry A is completely inside the B geometry
pub trait Contains<Rhs = Self> {
/// Checks if `rhs` is completely ... |
use std::fmt;
use std::marker::PhantomData;
use std::str::FromStr;
use serde::de::{self, MapAccess, Visitor};
use serde::{Deserialize, Deserializer};
#[derive(Debug, Clone, Deserialize, PartialOrd, PartialEq)]
pub struct RawPath {
pattern: String,
is_regex: bool,
}
impl RawPath {
pub fn new<S: Into<Strin... |
use std::{io, i32};
use std::fmt::{Debug, Formatter, Result as FmtResult};
use std::sync::atomic::Ordering;
use integer_atomics::AtomicI32;
use lock_wrappers::raw::Mutex;
use sys::{futex_wait, futex_wake};
/// A simple mutual exclusion lock (mutex).
///
/// This is not designed for direct use but as a building block f... |
#[cfg(all(feature = "glutin", not(target_arch = "wasm32")))]
pub mod glutin;
#[cfg(target_arch = "wasm32")]
pub mod web;
#[cfg(all(feature = "wgl", not(target_arch = "wasm32")))]
pub mod wgl;
#[cfg(not(any(target_arch = "wasm32", feature = "glutin", feature = "wgl")))]
pub mod dummy;
|
mod create;
mod get_players;
mod join;
mod status;
pub use self::create::*;
pub use self::get_players::*;
pub use self::join::*;
pub use self::status::*;
|
use std::{env, error::Error};
use futures::stream::StreamExt;
use twilight_cache_inmemory::{InMemoryCache, ResourceType};
use twilight_gateway::{cluster::{Cluster, ShardScheme}, Event};
use twilight_http::Client as HttpClient;
use twilight_model::gateway::Intents;
#[tokio::main]
async fn main() -> Result<(), Box<dyn E... |
use tui::widgets::{Row, Table, Borders, Block};
use tui::text::Text;
use tui::style::{Style, Color};
use tui::layout::Constraint;
use chrono::{DateTime, Local};
pub fn render(logs: &Vec<(DateTime<Local>, String, u8)>) -> Table<'static> {
let mut parsed_logs = vec![];
let mut unprocessed = logs.clone();
un... |
//! A "bare wasm" target representing a WebAssembly output that makes zero
//! assumptions about its environment.
//!
//! The `wasm32-unknown-unknown` target is intended to encapsulate use cases
//! that do not rely on any imported functionality. The binaries generated are
//! entirely self-contained by default when us... |
use game::*;
impl Spellbook{
pub fn new(game: &mut Game1, x: f64, y: f64, spell_id: usize)->SpellbookID{
let mover_id=Mover::new(&mut game.movers, x, y);
let basic_drawn_id=BasicDrawn::new_holistic(game, mover_id, 0);
SpellbookID{id: game.spellbooks.add(Spellbook{mover_id: mover_id, basic_drawn_id: basic_drawn_... |
//! Extended display identification data
//!
//! 1.3
//!
//! https://glenwing.github.io/docs/VESA-EEDID-A1.pdf
use nom::{
number::complete::{be_u16, le_u16, le_u32, le_u64, le_u8},
IResult,
};
// TODO
// - Error type https://github.com/Geal/nom/blob/master/examples/custom_error.rs
// - checksum check
// - spl... |
use std::env;
use std::path::Path;
use std::process::Command;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
println!("Here: {} ", out_dir);
// note that there are a number of downsides to this approach, the comments
// below detail how to improve the portability of these commands.
Comman... |
//! RomFS example.
//!
//! This example showcases the RomFS service and how to mount it to include a read-only filesystem within the application bundle.
use ctru::prelude::*;
fn main() {
ctru::use_panic_handler();
let gfx = Gfx::new().expect("Couldn't obtain GFX controller");
let mut hid = Hid::new().exp... |
//! Miscellaneous utility macros and functions.
use std::iter::FromIterator;
#[macro_export]
macro_rules! werr {
($($arg:tt)*) => (
if let Err(err) = stderr().write_str(&*format!($($arg)*)) {
panic!("{}", err);
}
)
}
/// Creates a vector of string-slices from a slice of strings.
/... |
use winapi::um::winuser::{WS_VISIBLE, WS_DISABLED};
use winapi::um::wingdi::DeleteObject;
use winapi::shared::windef::HBRUSH;
use crate::win32::{
base_helper::check_hwnd,
window_helper as wh,
resources_helper as rh
};
use super::{ControlBase, ControlHandle};
use crate::{Bitmap, Icon, NwgError, RawEventHan... |
#[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::MCS {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... |
use std::time::Duration;
use naia_shared::{LinkConditionerConfig, SharedConfig};
pub fn get_shared_config() -> SharedConfig {
let tick_interval = Duration::from_millis(1000);
// Simulate network conditions with this configuration property
let link_condition = Some(LinkConditionerConfig::average_condition... |
use crate::core;
use crate::value::Value;
/// Returns a named value registered by OCaml
pub fn named_value<S: AsRef<str>>(name: S) -> Option<Value> {
unsafe {
let p = format!("{}\0", name.as_ref());
let named = core::callback::caml_named_value(p.as_str().as_ptr());
if named.is_null() {
... |
use runestick::{CompileMeta, SourceId, Span};
/// A visitor that will be called for every language item compiled.
pub trait CompileVisitor {
/// Called when a meta item is registered.
fn register_meta(&self, _meta: &CompileMeta) {}
/// Mark that we've encountered a specific compile meta at the given span.... |
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
fn main() {
run();
}
fn run() {
let start = std::time::Instant::now();
// code goes here
let limit: u64 = 999;
let mut res = 0;
let mut soft_limit;
soft_limit = limit / 3;
res += 3 * (soft_limit * (soft_limit + 1)) / 2;
soft_limit = limit / 5;
re... |
extern crate nalgebra;
#[macro_use] extern crate glium;
extern crate time;
use glium::{DisplayBuild, Surface};
use nalgebra::{PerspectiveMatrix3, Vector3, Matrix4, Point3, Isometry3, ToHomogeneous, Translation};
#[derive(Clone, Copy, Debug)]
struct Vert {
position: [f32;3],
}
implement_vertex!(Vert, position);
... |
use bevy::prelude::*;
const NUM_SLIDES: isize = 6;
const WINDOW_WIDTH: f32 = 1280.0;
/// The current viewed slide.
pub struct Page(pub isize);
/// Tags the main camera.
struct WorldCamera;
/// Component for smooth camera movement.
#[derive(Debug, Default)]
struct CameraTarget(f32);
pub struct DemoCameraPlugin;
imp... |
const CRTC_COL: u16 = 25;
const CRTC_ROW: u16 = 80;
const CRTC_ADDR: u16 = 0x3d4;
const CRTC_DATA: u16 = 0x3d5;
const CRTC_CURSOR_H: u8 = 0x0E;
const CRTC_CURSOR_L: u8 = 0x0F;
use arch::x86_32::device::io;
// カーソル位置指定
pub unsafe fn set_cursor(pos: u16) {
io::outb(CRTC_ADDR, CRTC_CURSOR_H);
io::o... |
//! Describes the struct that holds the options needed by the formatting functions.
//! The three most common formats are provided as constants to be used easily
mod defaults;
pub use self::defaults::*;
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
/// Holds the standard to use when displaying the size.
pub enum Kilo ... |
use anyhow::{anyhow, Context, Result};
use chrono::{DateTime, Utc};
use dialoguer;
use dialoguer::Input;
use std::collections::HashMap;
use std::{thread, time::Duration};
use crate::providers::okta::client::Client;
use crate::providers::okta::factors::{Factor, FactorResult, FactorVerificationRequest};
use crate::provi... |
use crate::utils::{file_name_as_str, LogCommandExt};
use crate::Result;
use crate::Runnable;
use std::fs;
use std::process::Command;
use anyhow::{bail, Context};
use log::debug;
pub mod regular_platform;
pub fn strip_runnable(runnable: &Runnable, mut command: Command) -> Result<Runnable> {
let exe_stripped_name ... |
use crate::smb2::requests::create::Create;
/// Serializes the create request body.
pub fn serialize_create_request_body(request: &Create) -> Vec<u8> {
let mut serialized_request: Vec<u8> = Vec::new();
serialized_request.append(&mut request.structure_size.clone());
serialized_request.append(&mut request.se... |
use super::bus::BusDevice;
pub struct PostCodeHandler {}
impl PostCodeHandler {
pub fn new() -> Self {
PostCodeHandler {}
}
}
impl BusDevice for PostCodeHandler {
fn write(&mut self, _offset: u64, data: &[u8]) {
println!("POST: 0x{:x}", data[0]);
}
}
|
//! Routines for dumping read_* responses
use generated_types::{
read_response::{frame::Data, *},
Tag,
};
/// Convert a slice of frames to a format suitable for
/// comparing in tests.
pub(crate) fn dump_data_frames(frames: &[Data]) -> Vec<String> {
frames.iter().map(dump_data).collect()
}
fn dump_data(da... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qrect.h
// dst-file: /src/core/qrect.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= main ... |
mod plugins;
mod structs;
pub use libloading::Library;
pub use plugins::*;
pub use structs::*;
#[macro_export]
macro_rules! make_plugin {
($plugin_type:ty) => {
impl From<$crate::Library> for $plugin_type {
fn from(library: $crate::Library) -> Self {
let mut plugin = Self::new(... |
use account::NewRegistration;
extern crate bcrypt;
use bcrypt::{hash, verify, BcryptError, DEFAULT_COST};
use diesel;
use diesel::mysql::MysqlConnection;
use diesel::prelude::*;
use diesel::result;
use schema::users;
pub enum UserCreateError {
DbError(diesel::result::Error),
HashError(bcrypt::BcryptError),
}
... |
use anyhow::{Context, Result as AnyhowResult};
use ethers::prelude::*;
use gumdrop::Options;
use hifi_liquidator::{escalator, liquidations::Liquidator, sentinel::Sentinel};
use hifi_liquidator_structs::{Config, Opts};
use std::{convert::TryFrom, env, fs::OpenOptions, sync::Arc, time::Duration};
use tracing::info;
use t... |
#![allow(dead_code)]
use std::sync::atomic::{AtomicI8, AtomicU64, Ordering};
use crate::config::{Config, ConfigStatus};
use crate::debug::is_debug_mode;
use crate::model::{
concede_update, reset_lock, spin_update, Backoff, Message, WorkerUpdate, EXPIRE_PERIOD,
};
use crate::pool::PoolStatus;
use crate::worker::Wor... |
use crate::{Line, Plane, Point};
/// Projections
///
/// Projections in Geometric Algebra take on a particularly simple form.
/// For two geometric entities $a$ and $b$, there are two cases to consider.
/// First, if the grade of $a$ is greater than the grade of $b$, the projection
/// of $a$ on $b$ is given by:
///
/... |
// 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 {
fuchsia_criterion::criterion::{Bencher, Criterion},
fuchsia_zircon as zx,
};
pub fn benches(c: &mut Criterion) {
c.bench_function_over_i... |
use crate::event::Value;
use crate::sinks::influxdb::{
encode_namespace, encode_timestamp, healthcheck, influx_line_protocol, influxdb_settings,
Field, InfluxDB1Settings, InfluxDB2Settings, ProtocolVersion,
};
use crate::sinks::util::encoding::EncodingConfigWithDefault;
use crate::sinks::util::http::{BatchedHtt... |
pub struct ProconReader<R: std::io::Read> {
reader: R,
}
impl<R: std::io::Read> ProconReader<R> {
pub fn new(reader: R) -> Self {
Self { reader }
}
pub fn get<T: std::str::FromStr>(&mut self) -> T {
use std::io::Read;
let buf = self
.reader
.by_ref()
... |
use white_point::NamedWhitePoint;
use num::{cast, Float};
use channel::{FreeChannelScalar, PosNormalChannelScalar};
use xyz::Xyz;
use xyy::XyY;
/// Incandescent / Tungsten.
#[derive(Clone, Debug, PartialEq)]
pub struct A;
impl<T> NamedWhitePoint<T> for A
where T: Float + FreeChannelScalar + PosNormalChannelScalar... |
use core::cmp;
use core::fmt::{self, Debug, Display, Write};
use core::mem;
use core::ptr;
use core::slice;
use core::str::{self, Utf8Error};
use std::ffi::CStr;
use hashbrown::HashMap;
use lazy_static::lazy_static;
use thiserror::Error;
use liblumen_arena::DroplessArena;
use liblumen_core::alloc::prelude::*;
use ... |
#[doc = "Reader of register M3FAR"]
pub type R = crate::R<u32, super::M3FAR>;
#[doc = "Writer for register M3FAR"]
pub type W = crate::W<u32, super::M3FAR>;
#[doc = "Register M3FAR `reset()`'s with value 0"]
impl crate::ResetValue for super::M3FAR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Sel... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::executor::Executor;
use crate::TransactionExecutor;
use crypto::{hash::CryptoHash, HashValue};
// use logger::prelude::*;
use starcoin_accumulator::{Accumulator, MerkleAccumulator};
use starcoin_state_api::ChainState;
use... |
use std::collections::HashMap;
fn main() {
let mut mem : HashMap<u64, u64> = HashMap::new();
let mut mem2 : HashMap<u64, u64> = HashMap::new();
let mut mask : String = String::new();
for line in aoc::file_lines_iter("./day14.txt") {
let v : Vec<_> = line.split(" = ").collect();
if v[0]... |
#[cfg(feature = "serde")]
#[macro_use]
extern crate serde;
extern crate approx;
pub use self::vector2::*;
pub use self::vector3::*;
pub use self::vector4::*;
pub use self::math::*;
mod traits;
mod math;
mod vector2;
mod vector3;
mod vector4; |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qfontcombobox.h
// dst-file: /src/widgets/qfontcombobox.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main bloc... |
mod kinds_src;
use crate::utils;
use kinds_src::KindsSrc;
use std::path::Path;
use eyre::Result;
use xshell::{read_file, write_file};
pub fn run() -> Result<()> {
let kinds_src = KindsSrc::get()?;
let syntax_kinds_file =
utils::project_root().join("crates/parser/src/syntax_kind/generated.rs");
... |
use crate::{
data::{api_key::ApiKey, error::ErrorCode},
KafkaRequest, KafkaResponse,
};
use rskafka_wire_format::prelude::*;
#[derive(Debug, Clone, Eq, PartialEq, Hash, WireFormatWrite)]
pub struct CreateTopic {
pub name: String,
pub partitions: i32,
pub replication_factor: i16,
pub assignments... |
#[allow(dead_code)]
#[derive(Debug, Clone, Copy)]
pub enum Operation {
///Operation I/O.
Read = 0x0A,
Write = 0x0B,
///Operation load & store of data.
Load = 0x14,
Store = 0x15,
///Operation arithmetic.
Add = 0x1E,
Sub = 0x1F,
Div = 0x20,
Mul = 0x21,
///Operation of contr... |
#[allow(dead_code)]
pub struct StatusEffects {
effects: Vec<StatusEffect>,
}
#[allow(dead_code)]
pub enum StatusEffect {
MoveSpeed(f32),
AttackSpeed(f32),
DamageMod(f32),
Stun(f32),
Suppression(f32),
}
|
use crate::vec3::Point3;
use crate::ray::Ray;
// axis-aligned bounding boxes
#[derive(Clone)]
pub struct AABB {
pub min: Point3,
pub max: Point3,
}
impl AABB {
pub fn new(a: Point3, b: Point3) -> Self {
AABB {
min: a,
max: b,
}
}
pub fn hit(&self, r: &Ray, ... |
use log::{debug, info};
use serde::de;
use serde_backtrace::serde_backtrace;
use serde_titan_quest::arc;
use std::{fs::File, io::BufReader, path::Path};
use test_case::test_case;
fn read_arc(path: impl AsRef<Path>) {
stderrlog::new().verbosity(3).init().ok();
let _: () = serde_backtrace(
arc::from_read_seek_seed(
... |
pub mod api_versions;
pub mod create_topics;
pub mod fetch;
pub mod find_coordinator;
pub mod join_group;
pub mod metadata;
pub mod offset_fetch;
pub mod sync_group;
|
use super::{pack, unpack, Action, State};
use vte_generate_state_changes::generate_state_changes;
#[test]
fn table() {
let mut content = vec![];
generate_table(&mut content).unwrap();
let content = String::from_utf8(content).unwrap();
let content = codegenrs::rustfmt(&content, None).unwrap();
sna... |
extern crate chrono;
extern crate dotenv;
extern crate slack;
extern crate termion;
extern crate tui;
#[macro_use]
extern crate failure;
/// Contains stateful components - parts of the app.
///
/// Should depend on `models` as components usually need to contain state.
mod components;
/// Contains data conversion and... |
fn takes_slice(slice: &str)
{
println!("Got: {}", slice);
}
fn indexing() {
let hachiko = "忠犬ハチ公";
for b in hachiko.as_bytes() {
print!("{}, ", b);
}
println!("");
for c in hachiko.chars() {
print!("{}, ", c);
}
println!("");
let dog = hachiko.chars().nth(1);
// print!("dog is {}", dog);
}
fn concat... |
#![feature(never_type)]
fn f() -> Result<usize, !> {
Ok(0)
}
fn main() {
println!("{}", f().unwrap());
}
|
use std::rc::Rc;
use ash::vk;
use gpu_allocator::vulkan::Allocation;
use super::{allocator::Allocator, error::GraphicsResult, uploader::Uploader};
/// The filtering mode with which a [`Texture2D`] should be sampled.
pub enum TextureFilterMode {
/// Take the average of the surrounding texels
Linear,
// Ta... |
/// Implements a broadcast-listener / callback / observable pattern.
///
/// `Signal` holds a list of subscriptions, each with a callback closure to run
/// on the next broadcast.
///
/// As `rt-graph` uses GTK, the terminology (`Signal` struct and its method names) match
/// GTK's terms.
pub struct Signal<T: Clone> {
... |
use crate::blocks::Extension;
use eosio_cdt::eos::{
Checksum256, Deserialize, Name, Serialize, Signature, TimePointSec, Varuint32,
};
#[derive(Debug, Serialize, Deserialize)]
pub enum Traces {
TransactionTrace(TransactionTraceV0),
}
#[derive(Debug, Serialize, Deserialize)]
pub struct TransactionTraceV0 {
... |
extern crate rand;
use std::fs;
use std::io::Read;
use std::os;
use gpu;
use keyboard;
const FONTSET: [u8; 80] =
[
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x10, 0xF0, 0x10, 0xF0, // 3
0x90, 0x90, 0xF0, 0... |
//! Day 10
use std::{collections::HashMap, hash::Hash, iter::once};
use itertools::Itertools;
use num_traits::{NumOps, Unsigned};
trait Solution {
fn part_1(&self) -> usize;
fn part_2(&self) -> usize;
}
impl Solution for str {
fn part_1(&self) -> usize {
let distribution: HashMap<u32, _> = calcul... |
//! Custom error types
use std::fmt;
use crate::SchemaVersion;
/// A typedef of the result returned by many methods.
pub type Result<T, E = Error> = std::result::Result<T, E>;
/// Enum listing possible errors.
#[derive(Debug, PartialEq)]
#[allow(clippy::enum_variant_names)]
#[non_exhaustive]
pub enum Error {
//... |
use std::string::ToString;
use std::collections::BTreeMap;
use std::error::Error;
use std::fmt;
use std::{i32,i64,usize};
use rustc_serialize::json::{Json,ToJson};
use parse::Presence::*;
#[derive(Clone, PartialEq, Debug)]
pub enum ParseError {
InvalidJsonType(String),
InvalidStructure(String),
MissingFie... |
//!
//! This module contains several [passes](Pass) that can be chained to form a [pipeline](Pipeline).
//!
mod cataract;
mod lens;
mod retina;
mod yuv_420_rgb;
mod yuv_rgb;
pub use self::cataract::Cataract;
pub use self::lens::Lens;
pub use self::retina::Retina;
pub use self::yuv_420_rgb::Yuv420Rgb;
pub use self::yu... |
use std::io::{
stdout,
Stdout,
Write,
};
pub struct WriterWrapper<W>
where
W: Write,
{
backing_writer: W,
}
impl<W> WriterWrapper<W>
where
W: Write,
{
pub fn new(writer: W) -> Self {
Self {
backing_writer: writer,
}
}
#[allow(dead_code)]
/// Mostly ... |
use unicode_segmentation::UnicodeSegmentation;
use crate::grid::Frame;
/// Currently, an action is either printing a string or moving to a location.
/// The first value is the x location, the second is the y location.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, ... |
use std::collections::HashSet;
use darling::ast::{Data, Style};
use proc_macro::TokenStream;
use quote::quote;
use syn::{visit_mut::VisitMut, Error, Type};
use crate::{
args::{self, RenameTarget},
utils::{get_crate_name, get_rustdoc, visible_fn, GeneratorResult, RemoveLifetime},
};
pub fn generate(union_args... |
use num_bigint::BigInt;
use crate::time::{convert_milliseconds, Unit};
use liblumen_alloc::erts::time::Monotonic;
cfg_if::cfg_if! {
if #[cfg(all(target_arch = "wasm32", feature = "time_web_sys"))] {
mod web_sys;
pub use self::web_sys::*;
} else {
mod std;
pub use self::std::*;
}
}
pub fn ti... |
#![no_std]
#![cfg_attr(test, no_main)]
#![feature(abi_x86_interrupt)]
#![feature(custom_test_frameworks)]
#![test_runner(crate::testing::test_runner)]
#![reexport_test_harness_main = "test_main"]
#![feature(alloc_error_handler)]
#[allow(unused_imports)]
use core::panic::PanicInfo;
#[cfg(test)]
use bootloader::{entry_... |
use crate::erlang::monotonic_time_0;
use crate::erlang::subtract_2;
use crate::erlang::system_time_0;
use crate::erlang::time_offset_0;
use crate::test::with_process;
const TIME_OFFSET_DELTA_LIMIT: u64 = 20;
#[test]
fn approximately_system_time_minus_monotonic_time() {
with_process(|process| {
let monoton... |
use super::core::Clock;
use super::core::Updatable;
use super::numeric;
use ggez::input;
use ggez::input::mouse::MouseButton;
use ggez::*;
use std::collections::HashMap;
use std::hash::Hash;
///
/// # マウスのボタンの状態
/// マウスのボタンの状態を表す
///
/// MousePressed: 押されている
/// MouseReleased: 離されている
///
#[derive(Debug, Eq, PartialEq,... |
use std::cmp::Ordering;
#[derive(Clone, Copy)]
pub struct Sprite {
/// Sprite x and y positions
pub x: u8,
pub y: u8,
/// The tile number of the sprite
pub tile_num: u8,
/// True if the sprite is above the background
pub above_background: bool,
/// True if the sprite should be flippe... |
pub trait ExprSyn: Clone {
fn lit(n: i64) -> Self;
fn neg(t: Self) -> Self;
fn add(u: Self, v: Self) -> Self;
}
pub mod parse {
/*
expr := term ('+' term)*
term := lit | '-' term | '(' expr ')'
lit := digits
*/
use nom::{
branch::alt,
bytes::complete::tag,
... |
use futures::task::Task;
use std::collections::HashMap;
use std::time::Instant;
pub trait Store<Path, Item> {
type Error;
fn get(&self, path: &Path, key: &str) -> Result<Option<Item>, Self::Error>;
fn get_all(&self, path: &Path) -> Result<HashMap<String, Item>, Self::Error>;
fn delete(&self, path: &P... |
use piston::{
input::{RenderEvent, UpdateEvent},
window::Window,
};
use texture::CreateTexture;
use conrod_core::{
Borderable,
Labelable,
Positionable,
Sizeable,
Widget,
widget_ids,
};
use super::{game, main_menu::MainMenu, WindowContext};
use crate::{audio, chart, config::Config};
wid... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]... |
use piston_window::G2d;
use graphics::math::{ Scalar, Vec2d, Matrix2d, identity };
use graphics::Transformed;
use std::f64::consts::PI;
use game::camera::Camera;
use game::world::TILE_RECT;
use game::world::TILE_SIZE;
use util::graphics::Image;
use game::*;
const CAMERA_BASE: Scalar = 0.8;
const MOVE: Scalar = 5.0;
p... |
fn func1(a: i32) -> impl Fn(i32) -> i32 {
move |b| a + b
}
fn func2(a: i32, f: fn(i32) -> i32) -> impl Fn(i32) -> i32 {
move |b| f(a) + b
}
fn func3<A, B>(f: &dyn Fn(A) -> B) -> impl Fn(A) -> B + '_ {
move |a| f(a)
}
fn func4<'a, A, B, C>(f: &'a dyn Fn(A) -> B, g: &'a dyn Fn(B) -> C) -> impl Fn(A) -> C ... |
use std::{cmp, fmt::Debug};
// I provide two types of the People struct. The first is a simple, non generic struct, which I use to show how Rust's Vec type
// can sort our data. The second is generic over the ordering.
pub mod simple {
#[derive(Default, PartialEq, Eq, PartialOrd, Ord, Clone)]
// Rust's macro ... |
// 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 clap::{App, Arg};
use fonttools::font::{self, Font};
use std::fs::File;
use std::io;
pub fn read_args(name: &str, description: &str) -> clap::ArgMatches<'static> {
App::new(name)
.about(description)
.arg(
Arg::with_name("INPUT")
.help("Sets the input file to use")
... |
use crate::utils::*;
pub(crate) const NAME: &[&str] = &["rayon::IndexedParallelIterator"];
pub(crate) fn derive(data: &Data, items: &mut Vec<ItemImpl>) -> Result<()> {
let iter = quote!(::rayon::iter);
derive_trait!(
data,
Some(format_ident!("Item")),
parse_quote!(#iter::IndexedParall... |
use rom;
use register;
use shared::*;
pub struct Mmu {
///cartridge provides 0x0000 - 0x7fff in two banks
rom: Box<rom::Cartridge>,
///0x8000 - 0x9fff (1fff wide)
vram: [u8; 0x1fff],
///0xc000 - 0xcfff (1fff wide) (0xc000 - 0xddff echoed in 0xe000-0xfdff)
work_ram_0: [u8; 0x1fff],
///0xd000... |
use super::{Coordinates, Side};
use crossterm::style::{Color, Print, ResetColor, SetBackgroundColor, SetForegroundColor};
use crossterm::{cursor, execute, terminal};
use std::io;
use std::io::stdout;
/// The Grid draws empty boxes and defines the layout for the game.
#[derive(Debug, PartialEq)]
pub struct Grid {
... |
extern crate olin;
use log::{error, info};
use olin::sys;
pub extern "C" fn test() -> Result<(), i32> {
info!("testing for issue 37: https://github.com/Xe/olin/issues/37");
let mut envvar_val = [0u8; 64];
let resp = unsafe { sys::env_get("BUTTS".as_bytes().as_ptr(), 5, envvar_val.as_mut_ptr(), 64) };
... |
// 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... |
#[doc = "Reader of register PREMAC"]
pub type R = crate::R<u32, super::PREMAC>;
#[doc = "Reader of field `R0`"]
pub type R0_R = crate::R<bool, bool>;
impl R {
#[doc = "Bit 0 - Ethernet MAC Module 0 Peripheral Ready"]
#[inline(always)]
pub fn r0(&self) -> R0_R {
R0_R::new((self.bits & 0x01) != 0)
... |
#![feature(test)]
extern crate test;
use rand::Rng;
use test::Bencher;
macro_rules! unary {
($($func:ident),*) => ($(
paste::item! {
#[bench]
pub fn [<$func>](bh: &mut Bencher) {
let mut rng = rand::thread_rng();
let x = rng.gen::<f64>();
bh.iter(|| test::bl... |
#[cfg(feature = "pledge")]
#[macro_use]
extern crate pledge;
use getopts::Options;
#[cfg(feature = "pledge")]
use pledge::{pledge, Promise, ToPromiseString};
use std::env;
use std::path::Path;
use std::process::exit;
#[macro_use]
pub mod bartender;
pub mod mkfifo;
pub mod poll;
use crate::bartender::Config;
/// C... |
use net::{Packet, DeserialiseError, TAG_REGISTER};
/// A packet for registration.
pub struct RegPacket {
pub name: String,
}
impl RegPacket {
pub fn new(name: &str) -> RegPacket {
RegPacket { name: name.to_owned() }
}
}
impl Packet for RegPacket {
fn serialise(&self) -> Vec<u8> {
use std::mem::transmu... |
// Copyright 2014 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 ... |
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
impl super::INTSTAT {
#[doc = r" Reads the contents of the register"]
#[inline]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
}
#[doc = r" Value of the field"]
pub struct MSTPENDINGR {
... |
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
extern crate stringmatch;
use util;
fn print_and_check_result(
name: &str,
queries: &Vec<Vec<char>>,
res: &Vec<Vec<usize>>,
answer: Option<&Vec<Vec<usize>>>,
) {
println!("<{}>", name);
for idx in 0..res.len() {
let que... |
//use test::Bencher;
use std::{thread, time};
use chrono::Local;
use serde_json::json;
use crate::engine::node::Node;
use crate::engine::parser;
use crate::engine::runtime::OptMap;
#[test]
fn test_eval_arg() {
let box_node = parser::parser(String::from("startTime == null"), &OptMap::new()).unwrap();
let john... |
use super::ds::{BSPTree, KDTree, MyTree};
use crate::{
geo::{Geo, HitResult, HitTemp, TextureRaw},
linalg::{Mat, Ray, Transform, Vct},
Deserialize, Flt, Serialize, EPS,
};
use serde::de::{self, Deserializer, MapAccess, Visitor};
use serde::ser::{SerializeStruct, Serializer};
use std::collections::HashMap;
u... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
pub const CLSID_WPD_NAMESPACE_EXTENSION: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x35786d3c_b075_49b9_88dd_029876e11c01);
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp... |
#![feature(decl_macro)]
#[macro_use] extern crate rocket;
use rocket::http::RawStr;
#[get("/samples?<q>&<s>")]
fn samples(q: &RawStr, s: Option<String>) -> String {
format!("q={}, s={:?}", q, s)
}
fn main() {
rocket::ignite()
.mount("/", routes![samples])
.launch();
}
|
use std::sync::Arc;
use block_format::Block;
use bytes::Bytes;
use cid::{Cid, Codec, IntoExt};
use ipld_format::{FormatError, Link, NavigableNode, Node, NodeStat, Resolver, Result};
pub struct EmptyNode {
cid: Cid,
data: Bytes,
}
impl Default for EmptyNode {
fn default() -> Self {
EmptyNode {
... |
use std::fmt::Display;
// The type bounds are implemented only where necessary, with the exception of PartialOrd, which is
// in the types, because a binary tree contains inherently orderable data.
//
pub struct BinaryTree<T: PartialOrd> {
node: Option<Box<Node<T>>>,
}
struct Node<T: PartialOrd> {
data: T,
... |
use crate::chain::broadcaster::SenseiBroadcaster;
use crate::chain::manager::SenseiChainManager;
use crate::error::Error;
use crate::node::PeerManager;
use crate::p2p::peer_connector::PeerConnector;
use crate::p2p::utils::{parse_peer_addr, parse_pubkey};
use crate::services::node::OpenChannelRequest;
use crate::{chain:... |
extern crate regex;
use std::io;
use std::fs;
use std::io::BufRead;
use std::path::Path;
fn main() {
let input = parse_input();
let mut ferry = input.ferry;
let mut next_ferry = ferry.next_ferry();
while ferry != next_ferry {
ferry = next_ferry;
next_ferry = ferry.next_ferry();
}
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.