text stringlengths 8 4.13M |
|---|
//! Hooks which can be execute by the native os shell.
use std::io::{BufRead as _, BufReader};
use std::path::Path;
use std::process::{Command, Stdio};
use color_eyre::eyre::Result;
use serde::{Deserialize, Serialize};
use thiserror::Error;
/// An enum of errors which can occur during the execution of a [`Hook`].
#[... |
use crate::code_generator::intermediate::{Access, Constant, Context, Instruction, Label, UniqueVariable, Variable, VariableIndex, OperationType};
use ::virtual_machine::instruction::Instruction as VmInstruction;
use std::cmp::Ordering;
use std::collections::BTreeMap;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Partial... |
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
#![allow(dead_code)]
use wasmlib::*;
pub const SC_NAME: &str = "dividend";
pub const SC_HNAME: ScHname = ScHname(0xcce2e239);
pub const PARAM_ADDRESS: &str = "address";
pub const PARAM_FACTOR: &str = "factor";
pub const VAR_MEMBERS: &str = "mem... |
//! Contexts-related tests.
#![feature(plugin)]
#![plugin(stainless)]
describe! memory {
// TODO: Test memory usage / allocations / freeing
}
|
#[doc = "Reader of register LTDC_GC2R"]
pub type R = crate::R<u32, super::LTDC_GC2R>;
#[doc = "Reader of field `EDCEN`"]
pub type EDCEN_R = crate::R<bool, bool>;
#[doc = "Reader of field `STSAEN`"]
pub type STSAEN_R = crate::R<bool, bool>;
#[doc = "Reader of field `DVAEN`"]
pub type DVAEN_R = crate::R<bool, bool>;
#[do... |
pub mod http_check;
pub mod http_analyzer; |
#[doc = "Register `DMACR` reader"]
pub type R = crate::R<DMACR_SPEC>;
#[doc = "Register `DMACR` writer"]
pub type W = crate::W<DMACR_SPEC>;
#[doc = "Field `DIEN` reader - DMA input enable"]
pub type DIEN_R = crate::BitReader;
#[doc = "Field `DIEN` writer - DMA input enable"]
pub type DIEN_W<'a, REG, const O: u8> = crat... |
use crate::utils::wait_until;
use crate::{Net, Spec};
use ckb_app_config::CKBAppConfig;
use log::info;
pub struct Discovery;
impl Spec for Discovery {
crate::name!("discovery");
crate::setup!(num_nodes: 3);
fn run(&self, net: &mut Net) {
let node0_id = net.nodes[0].node_id();
let node2 =... |
use super::bicycle::BicycleRepoInterface;
use crate::{
bikes::BicycleDomain,
datasource::db,
diesel::RunQueryDsl,
error::Error,
schema::{bicycles, bicycles::dsl::*},
};
use diesel::{ExpressionMethods, QueryDsl};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Insertable)]
#[ta... |
use std::convert::TryFrom;
static FILENAME: &str = "input/data";
const OCCUPIED: char = '#';
const EMPTY: char = 'L';
type Matrix = Vec<Vec<char>>;
trait MatrixMethods {
fn get_char(&self, x: isize, y: isize) -> Option<char>;
}
impl MatrixMethods for Matrix {
fn get_char(&self, x: isize, y: isize) -> Optio... |
use anyhow::Result;
use pcd_rs::{PcdDeserialize, Reader};
#[derive(PcdDeserialize)]
pub struct Point {
pub x: f32,
pub y: f32,
pub z: f32,
pub rgb: f32,
}
pub fn main() -> Result<()> {
let reader = Reader::open("test_files/ascii.pcd")?;
let points: Result<Vec<Point>> = reader.collect();
pr... |
pub mod print;
|
pub mod branching_simplify;
pub mod const_folding;
pub mod dead_code_eliminator;
pub mod loop_unroll;
pub mod util;
|
pub mod blocks;
pub mod movies;
pub mod requests;
|
use crate::crypto::multi_party_schnorr::Parameters;
use crate::federation::{Federation, Federations};
use crate::net::SignerID;
use crate::rpc::TapyrusApi;
use std::convert::TryInto;
use std::sync::Arc;
use tapyrus::{Address, PublicKey};
pub struct NodeParameters<T: TapyrusApi> {
pub rpc: std::sync::Arc<T>,
pu... |
// Copyright 2018-2020 Parity Technologies (UK) Ltd.
//
// Licensed under the Apache License, Version 2.0 or MIT license, at your option.
//
// A copy of the Apache License, Version 2.0 is included in the software as
// LICENSE-APACHE and a copy of the MIT license is included in the software
// as LICENSE-MIT. You may ... |
use crate::protocol::Command;
use bytes::{ Bytes, BytesMut, BufMut };
use std::sync::Arc;
pub fn generate_response(val: Bytes, erorr_code: u16) -> crate::Result<Bytes> {
/* Generate status code and header for the response. */
let resp_str =
format!("HTTP/1.1 {}\r\nContent-Length: {}\r\n\r\n", erorr_c... |
use std::fs::File;
use std::io::{Cursor, Read, Write};
use std::path::{Path, PathBuf};
use actix_web::http::header::ContentEncoding;
use libflate::gzip::Encoder;
use serde::Deserialize;
use strum::{Display, EnumIter, EnumString};
use tar::Builder;
use zip::{write, ZipWriter};
use crate::errors::ContextualError;
/// ... |
//! Tests auto-converted from "sass-spec/spec/non_conformant/parser/interpolate/44_selector/todo_single_escape"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/non_conformant/parser/interpolate/44_selector/todo_single_escape/11_escaped_interpolated_value.hrx"
// Ignoring "t11_escaped_interpolated_value", e... |
use termion::event::Key;
use widget::{Bound, BoundSize, Widget};
use {Position, Size};
use std::fmt;
mod config;
mod consts;
mod edit;
mod history;
mod keymap;
mod kill_ring;
mod line_buffer;
mod process;
mod state;
mod undo;
use self::consts::KeyPress;
pub use self::edit::Editor;
use self::keymap::InputState;
use s... |
use string_repr::StringRepr;
#[macro_export]
macro_rules! path {
($path:expr) => {
Path::new($path)
};
}
pub struct Path<'a>(&'a str);
impl<'a> Path<'a> {
/// Create new Path.
/// # Example:
/// ```rust
/// use wdg_uri::path::Path;
/// let path = Path::new("/");
/// ```
pu... |
use crate::parser::lexer::TokenStream;
use crate::parser::tokens::{Token, TokenType, TokenType::*};
use std::rc::Rc;
use std::result;
use std::str;
use std::{collections::HashMap, path::PathBuf};
use thiserror::Error;
use crate::parser::span::Span;
use crate::parser::ast::*;
use serde::{Deserialize, Serialize};
use ... |
#![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)]
Servers_CheckNameAvailability(#[from]... |
extern crate futures;
extern crate rand;
use std::time::Duration;
use std::thread;
use std::sync::mpsc::channel;
use rand::Rng;
use futures::Future;
use futures::sync::oneshot;
fn main() {
let (data_tx, data_rx) = channel();
let (oneshot_tx, oneshot_rx) = channel();
thread::spawn(move|| {
loop {... |
use serde::{Serialize, Deserialize};
use crate::schema::users;
#[derive(Debug, Identifiable, Queryable, Serialize, Deserialize, PartialEq)]
pub struct User {
pub id: i32,
pub username: String,
pub email: Option<String>,
pub profile: Option<i32>,
pub password: String,
pub login_session: String,
... |
pub mod button;
pub mod playback;
use crate::player::PlaybackRequest;
#[derive(Clone, Debug)]
pub enum Input {
Button(button::Command),
Playback(PlaybackRequest),
}
|
use crate::simulation::agent_shader::ty::PushConstantData;
use crate::simulation::blur_fade_shader;
use crate::simulation::Simulation;
use imgui::{Context, Ui};
use imgui_vulkano_renderer::Renderer;
use imgui_winit_support::{HiDpiMode, WinitPlatform};
use std::sync::Arc;
use std::time::{Duration, Instant};
use vulkano:... |
#[doc = "Register `ISR` reader"]
pub type R = crate::R<ISR_SPEC>;
#[doc = "Field `FLT1` reader - Fault 1 Interrupt Flag"]
pub type FLT1_R = crate::BitReader;
#[doc = "Field `FLT2` reader - Fault 2 Interrupt Flag"]
pub type FLT2_R = crate::BitReader;
#[doc = "Field `FLT3` reader - Fault 3 Interrupt Flag"]
pub type FLT3_... |
#[macro_use]
extern crate pest;
#[macro_use]
extern crate pest_derive;
#[macro_use]
extern crate lazy_static;
mod operations;
mod parse;
mod print;
mod serialize;
mod spot;
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
pub enum HyperLTL {
/// A quantifier, e.g. `forall pi`
Quant(QuantKind, Vec<String>, Box<Hyp... |
// get an iterator if an operating system is present
pub fn devices<'a>(&'a self)
-> io::Result<Devices<'a>> { ... }
// contains setup search handle, current index
// as well as a pointer to the shared buffer
pub struct Devices<'a> { ... }
// close search handle and release buffer
impl Drop for Devices { ...... |
// 1864. Minimum Number of Swaps to Make the Binary String Alternating
// https://leetcode.com/contest/weekly-contest-241/problems/minimum-number-of-swaps-to-make-the-binary-string-alternating/
//
use std::cmp::Ordering;
impl Solution {
fn swap_counter(s: &String, result_first_char: char) -> u32 {
let mut... |
// Copyright (c) 2017-present PyO3 Project and Contributors
use crate::{
attributes::FromPyWithAttribute,
method::{FnArg, FnSpec},
pyfunction::Argument,
utils::{remove_lifetime, replace_self, unwrap_ty_group},
};
use proc_macro2::{Span, TokenStream};
use quote::{quote, quote_spanned};
use syn::ext::Ide... |
// Copyright © 2020, Oracle and/or its affiliates.
//
// Copyright (c) 2019 Intel Corporation. All rights reserved.
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license ... |
use pancurses::{endwin, Input, Window};
use std::{thread, time};
const VERSION: &str = "v0.2.0";
mod display;
mod interface;
mod mechanics;
fn main() {
let screen = display::init_curses();
let colors = display::init_colors();
let mut window = display::init_window(&screen);
let mut max_yx = screen.get... |
pub(crate) mod year_2022;
|
pub mod instruction;
mod test;
use self::instruction::*;
use std::ops::DerefMut;
fn same_sign(lhs: u8, rhs: u8) -> bool {
lhs & 0x80 == rhs & 0x80
}
trait Address where Self: Sized {
fn low_byte(self) -> u8;
fn high_byte(self) -> u8;
fn combine_low_high(low: u8, high: u8) -> Self;
fn add_offset(se... |
// Modified from: http://www.adammil.net/blog/v125_roguelike_vision_algorithms.html#diamondcode
use rl_utils::{Area, Coord};
use crate::{utils::Octant, Fov, FovCallbackEnum, FovConfig, Los, VisionShape};
#[derive(Copy, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Debug)]
struct Slope {
x: isize,
y: isize,
}
... |
#[derive(Clone, Debug)]
pub struct Query {
sql: String,
id: String,
}
impl Query {
pub fn new(sql: impl AsRef<str>) -> Self {
Self {
sql: sql.as_ref().to_string(),
id: "".to_string(),
}
}
pub fn id(self, id: impl AsRef<str>) -> Self {
Self {
... |
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use serde::{Deserialize, Serialize};
use crate::SqlValue;
/// `Eq + Hash` hash key used for hash algorithms.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub struct SqlValueHashKey(u64);
impl From<... |
use std::convert::From;
#[derive(Debug, PartialEq)]
pub enum Deleted {
No,
Soft,
Hard,
}
#[derive(Debug)]
pub struct Record {
pub rvolumes: Vec<String>,
pub deleted: Deleted, // TODO: handle pub later
pub hash: String, // TODO: handle pub later
}
impl Record {
pub fn new() -> Self {
Self {
rvolumes: vec!... |
use itertools::Itertools;
use std::{env, fs::File, iter::FromIterator, path::PathBuf};
const IMG_WIDTH: usize = 25;
const IMG_HEIGHT: usize = 6;
const IMG_SIZE: usize = IMG_WIDTH * IMG_HEIGHT;
#[derive(Default, Debug)]
struct Numbers {
zeros: usize,
ones: usize,
twos: usize,
}
fn count<I: Iterator<Item =... |
use serde::{Deserialize, Serialize};
/// Represents a customer
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct Customer {
/// A unique identifier for a customer record
pub guid: String,
/// First name
pub first_name: String,
/// Last name
pub last_name: String,
/// Em... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
use vector::Metric;
use crate::index::InmemIndex;
use crate::model::configuration::index_write_parameters::IndexWriteParametersBuilder;
use crate::model::{IndexConfiguration};
use crate::model::vertex::DIM_128;
use c... |
use diesel::{self, prelude::*};
mod schema {
table! {
questbooks {
id -> Nullable<Integer>,
uid -> Text,
message -> Text,
}
}
}
use self::schema::questbooks;
use self::schema::questbooks::dsl::{questbooks as all_questbooks};
#[table_name="questbooks"]
#[der... |
use simdjson_rust::dom;
use std::fmt;
use flate2::read;
use flate2::write;
use flate2::Compression;
use std::error::Error;
use std::ffi::OsStr;
use std::fs::File;
use std::io::{self, BufRead, BufReader, BufWriter, Write};
use std::path::Path;
use std::time::Instant;
/// Read normal or compressed files seamlessly
/... |
use std::ffi::CString;
use criterion::measurement::{Measurement, ValueFormatter};
use libpapi_sys::*;
mod formatter;
use formatter::InsFormatter;
pub struct PapiMeasurement {
event_set: std::os::raw::c_int,
}
impl PapiMeasurement {
pub fn new(event: &str) -> PapiMeasurement {
let mut event_set = PAP... |
#[derive(Debug, PartialEq, Eq, Deserialize)]
pub struct Photo {
pub id: Id,
pub album_id: Id,
pub owner_id: OwnerId,
pub user_id: Id,
pub photo_75: String,
pub photo_130: String,
pub photo_604: String,
pub width: u16,
pub height: u16,
pub text: String,
pub date: Timestamp,
}... |
use super::*;
use crate::{graphics::*};
pub struct ProgressBar {
text : &'static str,
min : usize,
max : usize,
fill : f32,
scale : usize,
empty_color : Color,
filled_color : Color,
}
impl Renderable for ProgressBar {
fn draw(&self, x : usize, y : usize) {
let lbl = label:... |
/// Helps write correct plurals.
///
/// # Examples
///
/// ```
/// assert_eq!(plural(0, "coin"), "0 coins");
/// assert_eq!(plural(1, "coin"), "1 coin");
/// assert_eq!(plural(2, "coin"), "2 coins");
/// ```
pub fn plural(count: i32, word: &str) -> String {
if count == 1 {
format!("{} {}", count, word)
... |
extern crate cbindgen;
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn main() {
let crate_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let cfg = cbindgen::Config::from_root_or_default(std::path::Path::new(&crate_dir));
let c = cbindgen::Builder::new()
.with_config(cfg)
... |
struct Solution;
/// https://leetcode.com/problems/majority-element/
impl Solution {
/// 0 ms 2.3 MB
pub fn majority_element(nums: Vec<i32>) -> i32 {
let mut major = nums[0];
let mut count = 1;
for &num in &nums[1..] {
if major == num {
count += 1;
... |
// Generated by the capnpc-rust plugin to the Cap'n Proto schema compiler.
// DO NOT EDIT.
// source: protos/src/bronx.capnp
pub mod set {
#![allow(unused_imports)]
use capnp::capability::{FromClientHook, FromTypelessPipeline};
use capnp::{text, data, Result};
use capnp::private::layout;
use capnp::traits::... |
#[doc = "Reader of register TEMP_OR"]
pub type R = crate::R<u32, super::TEMP_OR>;
#[doc = "Writer for register TEMP_OR"]
pub type W = crate::W<u32, super::TEMP_OR>;
#[doc = "Register TEMP_OR `reset()`'s with value 0"]
impl crate::ResetValue for super::TEMP_OR {
type Type = u32;
#[inline(always)]
fn reset_va... |
pub(crate) fn clone_into_array<A, T>(slice: &[T]) -> A
where
A: Default + AsMut<[T]>,
T: Clone,
{
let mut a = Default::default();
<A as AsMut<[T]>>::as_mut(&mut a).clone_from_slice(slice);
a
}
pub(crate) fn concat(ctxt: &[u8], tag: &[u8]) -> Vec<u8> {
let mut out = Vec::new();
out.extend_fr... |
#![feature(slice_strip)]
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
fn main() {
let listener = TcpListener::bind("localhost:9149").unwrap();
for stream in listener.incoming().take(3) {
let stream = stream.unwrap();
handle_connection(stream);
}
}
fn handle_connection(mut stream: T... |
use crate::{Timestamp, Uint64};
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Serialize, Deserialize, PartialEq, Eq, Hash, Debug)]
pub struct TxPoolInfo {
pub pending: Uint64,
pub proposed: Uint64,
pub orphan: Uint64,
pub total_tx_size: Uint64,
pub total_tx_cycles: Uint64,
pub l... |
//! Iterators over a `Rope`'s data.
//!
//! All iterators here can also be used with `RopeSlice`'s. When used
//! with a `RopeSlice`, they iterate over only the data that the
//! `RopeSlice` refers to. For the line and chunk, iterators, the data
//! of the first and last yielded item will be truncated to match the
//... |
//! A simple implementation of an in-memory files-sytem written in Rust using the BTreeMap
//! data-structure.
//!
//! This code is inspired from https://github.com/bparli/bpfs and was modified to work
//! with node-replication for benchmarking.
use std::collections::BTreeMap;
use std::ffi::OsStr;
use std::iter;
use ... |
// Copyright 2012-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-MI... |
#[doc = "Reader of register UARTPCELLID1"]
pub type R = crate::R<u32, super::UARTPCELLID1>;
#[doc = "Reader of field `UARTPCELLID1`"]
pub type UARTPCELLID1_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:7 - These bits read back as 0xF0"]
#[inline(always)]
pub fn uartpcellid1(&self) -> UARTPCELLID1_R {
... |
use std::sync::{Arc, Mutex, MutexGuard};
use raw::vp::{self, VPInstance};
use globals::{GLOBALS, Globals};
use instance::Instance;
use std::os::raw::{c_int, c_void};
macro_rules! generate_callback {
($this_callback_name:expr, $current_callback_name:expr, $current_instance:expr, $activate:expr) => {{
if $... |
use fluentbit::*;
use rmpv;
use serde_json;
#[derive(Default)]
struct JsonExample {}
impl FLBPluginMethods for JsonExample {
fn plugin_register(&mut self, info: &mut PluginInfo) -> FLBResult {
info.name = "rustout".into();
info.description = "This is a default description".into();
Ok(())
... |
use std::ptr;
impl<T> Drop for Node<T> {
#[inline]
fn drop(&mut self) {
while self.mask != 0 {
let bit = self.mask.trailing_zeros();
unsafe {
ptr::read(&mut self.values[bit as usize]);
}
self.mask &= !(1 << bit);
}
unsafe ... |
use std::io::Write;
use std::str::FromStr;
// main関数は値を返さないので、返り値の型の記述はしない
fn main () {
gcd();
}
// コマンドライン引数からsimple_gcdを実行する関数
fn gcd () {
// mutでないと値を代入できない
// vectorに入れる型を指定する必要はない。推論してくれる
let mut numbers = Vec::new();
// コマンドライン引数から値をベクトルに格納
// std::env::argsはイテレータを返す
for arg in std:... |
extern crate proc_macro;
//extern crate syn;
//extern crate quote;
use proc_macro::TokenStream;
use std::str::FromStr;
#[proc_macro]
pub fn Dingirsu_Reflect(input: TokenStream) -> TokenStream {
let mut original_code =input.to_string();
//original_code=original_code.replace(" fn\n", " fn");
let mut co... |
//! Sx127x Integration testing
//!
//! Copyright 2019 Ryan Kurte
use std::collections::HashMap;
use std::thread;
use std::time::Duration;
extern crate embedded_spi;
use embedded_spi::utils::{load_config, DeviceConfig};
extern crate radio_sx127x;
use radio_sx127x::prelude::*;
extern crate radio;
use radio::{Receive,... |
use std::fs;
use itertools::Itertools;
pub fn day1(args: &[String]) -> i32 {
println!("Day 1");
if args.len() != 1 {
println!("Missing input file");
return -1;
}
let filename = &args[0];
println!("In file {}", filename);
let contents = fs::read_to_string(filename)
.expec... |
#![feature(async_closure)]
use chrono::{Utc};
use lobby_manager::*;
use serde::{Deserialize, Serialize};
mod planetwars;
mod pw_maps;
mod websocket;
mod game_manager;
mod lobby_manager;
use mozaic_core::{Token};
use uuid::Uuid;
use warp::{Rejection, reply::{Reply, Response, json}};
use warp::Filter;
use std::{con... |
/*
* Copyright 2020 Damian Peckett <damian@pecke.tt>
*
* 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 applica... |
use super::targeting;
use super::data::{ Object, Game, Tcod, MessageLog, UseResult, Ai };
use crate::{PLAYER, HEAL_AMOUNT, LIGHTNING_RANGE, LIGHTNING_DAMAGE, CONFUSE_RANGE, CONFUSE_NUM_TURNS, FIREBALL_RADIUS, FIREBALL_DAMAGE};
pub fn cast_heal(
_inventory_id: usize,
objects: &mut [Object],
game: &mut Game,... |
fn main() {
let s = String::from("hello");
takes_ownership(s.clone());
println!("{}", s);
let x = 5;
make_copy(x);
println!("{}", x);
let s1 = String::from("hello");
let (s2, len) = calculate_length(s1);
println!("The length of '{}' is {}.", s2, len);
}
fn calculate_leng... |
struct Solution();
impl Solution {
pub fn gray_code(n: i32) -> Vec<i32> {
//动态规划
let mut gray_vec=Vec::new();
gray_vec.push(0);
// if n==0{
// return gray_vec;
// }
// gray_vec.push(1);
// if n==1{
// return gray_vec;
/... |
// Copyright (c) 2017 Anatoly Ikorsky
//
// 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 http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
// m... |
// --- paritytech ---
use pallet_timestamp::Config;
// --- darwinia-network ---
use crate::{weights::pallet_timestamp::WeightInfo, *};
frame_support::parameter_types! {
pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
}
impl Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = Mo... |
use crate::colors::{BitDepth, ColorType};
use crate::headers::IhdrData;
use crate::png::PngImage;
use indexmap::map::{Entry::*, IndexMap};
use rgb::RGBA8;
use std::borrow::Cow;
pub mod alpha;
use crate::alpha::*;
pub mod bit_depth;
use crate::bit_depth::*;
pub mod color;
use crate::color::*;
pub(crate) use crate::alp... |
use byteorder::{LittleEndian, WriteBytesExt};
use encoding::{codec::utf_16, Encoding};
use failure::{ensure, Error};
use crate::{chunks::TOKEN_PACKAGE, model::owned::OwnedBuf};
#[derive(Default, Debug)]
pub struct PackageBuf {
id: u32,
package_name: String,
inner_chunks: Vec<Box<dyn OwnedBuf>>,
}
#[allow... |
use crate::map::line::Line;
use crate::map::line::LineSystem;
use crate::map::sector;
use crate::map::sector::Sector;
use crate::map::triangulate::triangulate_sector;
use crate::things::thing::Thing;
use crate::things::thing::Updatable;
use std::collections::HashSet;
pub const WORLD_SCALE: f32 = 0.25;
pub const WORLD_... |
use std::fs::File;
use std::io::{BufReader, BufRead};
use regex::Regex;
fn main() {
// println!("read begin");
let f=File::open("./src/13_134820.log").unwrap();
let buf=BufReader::new(f);
let mut l_all =Vec::new();
for line in buf.lines(){
// println!("1 begin");
let line_data=line... |
extern crate hyper;
extern crate futures;
extern crate url;
#[macro_use]
extern crate log;
extern crate env_logger;
#[macro_use]
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate crypto;
use std::sync::{RwLock};
use hyper::{StatusCode};
use hyper::Method::{Get};
use hyper::server::{Req... |
// error-pattern: the evaluated program panicked
#[derive(Debug)]
struct A;
fn main() {
// can't use assert_eq, b/c that will try to print the pointer addresses with full MIR enabled
assert!(&A as *const A == &A as *const A);
}
|
// Generated by `scripts/generate.js`
pub type VkCopyAccelerationStructureMode = super::super::khr::VkCopyAccelerationStructureMode;
#[doc(hidden)]
pub type RawVkCopyAccelerationStructureMode = super::super::khr::RawVkCopyAccelerationStructureMode; |
//! Zero-capacity channel.
//!
//! Also known as *rendezvous* channel.
use std::time::Instant;
use err::{RecvTimeoutError, SendTimeoutError, TryRecvError, TrySendError};
use exchanger::{Exchanger, ExchangeError};
use select::CaseId;
/// A zero-capacity channel.
pub struct Channel<T> {
/// The internal two-sided ... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// LogsGeoIpParser : The GeoIP parser takes an IP address attribute and extracts if available the Conti... |
use proc_macro2::TokenStream;
use quote::quote;
use chom_ir::{
Namespace,
Constant,
Context
};
use super::{
Generate
};
impl<T: Namespace> Generate<T> for Constant {
fn generate(&self, _: &Context<T>) -> TokenStream {
match self {
Constant::Unit => quote! { () },
Constant::Bool(b) => quote! { #b },
Con... |
pub struct TrainStation {}
pub struct TrainTrip {}
pub trait BikeSharingStation{
fn get_position(&self) -> super::Coord;
fn get_name(&self) -> Option<String>;
fn get_id(&self) -> String;
fn has_bikes(&self) -> Option<bool>;
}
pub trait TrainServiceProvider {
fn get_name(&self) -> &str;
fn get_id(&self) -> Strin... |
//! Component for the Murata CMWX1ZZABZ-078 LoRa Module
use capsules::virtual_spi::{MuxSpiMaster, VirtualSpiMasterDevice};
use core::mem::MaybeUninit;
use kernel::component::Component;
use kernel::hil;
use kernel::static_init_half;
use capsules::lora::driver::RadioDriver;
use capsules::lora::radio::Radio;
use capsule... |
use ::mantle;
use ::memory;
use mantle::kernel;
use mantle::kernel::BootInfo;
use ::crust;
use ::core;
use ::kobject::*;
use core::fmt::Write;
#[no_mangle]
pub extern fn mantle_main(bootinfo: &BootInfo, executable_start: usize) {
set_bootinfo(bootinfo, executable_start);
::main(bootinfo);
}
pub fn print_booti... |
use std::iter::Step;
use std::ops::Neg;
use std::f64::consts::PI as PI_64;
use std::f32::consts::PI as PI_32;
use cgmath::{
BaseNum, BaseFloat,
num_traits::{FromPrimitive, ToPrimitive},
num_traits::int::PrimInt,
prelude::*,
};
impl BaseFloatExt for f32 {
const PI: Self = PI_32;
const TWO: Self... |
use crate::types::{keyword_type::KeywordType, schema::Schema, schema_error::SchemaError, scope_builder::ScopeBuilder, validator_error_iterator::ValidationErrorIterator};
use json_trait_rs::JsonType;
use std::{any::Any, fmt::Debug};
pub(in crate) trait Validator: Debug + Sync + Send {
fn compile<T: 'static + JsonTy... |
use crate::features::Feature;
use crate::loader;
use crate::trust;
use atty::{is, Stream};
use failure::{format_err, Error};
use regex::Regex;
use std::collections::HashSet;
use std::env;
use std::fs::{self, OpenOptions};
use std::path::PathBuf;
use std::time::{Duration, SystemTime};
// "shadowenv" in a gradient of l... |
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(test)]
mod mock;
#[cfg(test)]
mod tests;
use frame_support::Parameter;
use primitives::{
MillisecsPerBlock as MillisecsPerBlockPrimitive, SessionPeriod as SessionPeriodPrimitive,
UnitCreationDelay as UnitCreationDelayPrimitive,
};
use sp_std::prelude::*;
use f... |
pub struct ThreadSafe<'a, T> {
pub(crate) t: &'a T,
}
unsafe impl<'a, T> Sync for ThreadSafe<'a, T> {}
|
/*!
# Advent of Code 2020 - Day 04
[Link to task.](https://adventofcode.com/2020/day/4)
Detect which passports are valid eq. have all required
fields with some limitations.
Passport data is validated in batch files (your puzzle input).
Each passport is represented as a sequence of key:value pairs
separated by spaces ... |
// iterative vs functional
// Calculate Harmonic series:
// 1 + (1/2)^2 + (1/3)^3 + (1/4)^4 + ...
fn harmonic(n: i32) -> f64 {
let mut sum: f64 = 0.0;
for i in 1..n {
sum += 1.0 / f64::from(i);
}
return sum;
}
fn harmonic_functional(n: i32) -> f64 {
(1..n).map(f64::from).map(|i| 1.0 / i)... |
use super::{LoadAll, LoadArgs, ProviderContainer};
use crate::{BoxFuture, Entity, Result};
use std::ops::Deref;
pub struct TransactionProvider<'a>(pub(super) &'a ProviderContainer);
impl<'a> TransactionProvider<'a> {
pub fn commit(&self) -> BoxFuture<'_, Result<()>> {
Box::pin(async move {
let... |
#![no_std]
#![no_main]
#![feature(slice_fill)]
use panic_halt as _;
use embedded_graphics::fonts::{Font6x8, Text};
use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::*;
use embedded_graphics::text_style;
use gd32vf103xx_hal::delay::McycleDelay;
use gd32vf103xx_hal::pac;
use gd32vf103xx_hal::pr... |
use maat_graphics::math;
use maat_graphics::DrawCall;
use crate::modules::scenes::Scene;
use crate::modules::scenes::SceneData;
use crate::modules::scenes::{LoadScreen};
use crate::cgmath::{Vector2, Vector3, Vector4};
use crate::modules::collisions;
use crate::rand::Rng;
use rand::prelude::ThreadRng;
use rand::thre... |
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{CanonicalAddr, Decimal, ReadonlyStorage, StdResult, Storage, Uint128};
use cosmwasm_storage::{
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, Singleton,
};
static KEY_CONFIG: &[u8] = b"config";
#[derive(Def... |
use super::*;
use counter::Counter;
use indicatif::ParallelProgressIterator;
use indicatif::ProgressIterator;
use rand::rngs::SmallRng;
use rand::seq::SliceRandom;
use rand::SeedableRng;
use rayon::iter::IndexedParallelIterator;
use rayon::iter::IntoParallelIterator;
use rayon::iter::ParallelIterator;
use roaring::{Roa... |
extern crate nom;
use crate::types::{Attributes, GraphAST, Stmt};
use nom::branch::alt;
use nom::bytes::complete::{escaped_transform, tag, tag_no_case};
use nom::character::complete::{
char, digit0, digit1, multispace0, none_of, one_of, satisfy, space0,
};
use nom::combinator::{eof, map, opt, recognize, value};
us... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.