text stringlengths 8 4.13M |
|---|
#[doc = "Reader of register ENABLED0"]
pub type R = crate::R<u32, super::ENABLED0>;
#[doc = "Reader of field `clk_sys_sram3`"]
pub type CLK_SYS_SRAM3_R = crate::R<bool, bool>;
#[doc = "Reader of field `clk_sys_sram2`"]
pub type CLK_SYS_SRAM2_R = crate::R<bool, bool>;
#[doc = "Reader of field `clk_sys_sram1`"]
pub type ... |
use chrono::Datelike;
use serde_derive::{Deserialize, Serialize};
#[derive(PartialEq, PartialOrd, Eq, Ord, Serialize, Deserialize, Debug, Clone)]
pub(crate) struct CalendarMonth {
year: i32,
month: Month,
}
impl CalendarMonth {
pub fn new(year: i32, month: Month) -> CalendarMonth {
CalendarMonth {... |
use std::collections::BTreeMap;
extern crate rust_htslib;
extern crate bio;
use rust_htslib::bam;
use rust_htslib::bam::Read;
use std::io;
use std::env;
use std::string;
use bio::io::fasta;
const FASTA_SEQS: &'static [ &'static str ] = &[
"1 dna:chromosome chromosome:GRCh37:1:1:249250621:1",
"2 dna:chromoso... |
pub struct Solution {}
/**
https://leetcode.com/problems/repeated-string-match/
**/
impl Solution {
pub fn repeated_string_match(a: String, b: String) -> i32 {
let mut s = String::new();
let mut repeated = 0;
let a_str = a.as_str();
let b_str = b.as_str();
let b_len = b.len... |
/* What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9?
Where lexicographic permutation is defined the ordered sequence of permutations, ie 01, 10, or 012, 021, 102,...
Observe that we may simply find the solution with a factorial function.
*/
fn factorial(a: u8) -> i64 {
... |
#![cfg(test)]
use super::*;
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
use sp_core::H256;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
Perbill,
};
impl_outer_origin! {
pub enum Origin for Test where system = frame_system {}
}
#[derive(Clone, Eq, Debug,... |
/*
zk-paillier
Copyright 2018 by Kzen Networks
zk-paillier is free software: you can redistribute
it and/or modify it under the terms of the GNU General Public
License as published by the Free Software Foundation, either
version 3 of the License, or (at your option) any later version.
@li... |
//! Transport from SQLite Source to Arrow2 Destination.
use crate::{
destinations::arrow2::{
typesystem::Arrow2TypeSystem, Arrow2Destination, Arrow2DestinationError,
},
impl_transport,
sources::sqlite::{SQLiteSource, SQLiteSourceError, SQLiteTypeSystem},
typesystem::TypeConversion,
};
use c... |
extern crate gcc;
fn main() {
let mut cfg = gcc::Config::new();
cfg.file("src/task_info.c");
cfg.compile("libtask_info.a");
}
|
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::serde::{Deserialize, Serialize};
use near_sdk::serde_json::json;
use near_sdk::{env, json_types::U128, near_bindgen, AccountId, Promise, *};
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize)]
pub struct MakeWallets {}
impl Default f... |
use std::char;
use std::string::String;
use std::iter::Iterator;
use std::collections::HashSet;
#[derive(Debug)]
pub struct Token {
str: String,
line_num: usize,
line_pos: usize,
}
#[derive(Debug)]
pub struct Scanner<'a, 'b> {
file: &'a Vec<char>,
cur_pos: usize,
line_num: usize,
cur_lin... |
use crate::linalg::*;
use std::mem::{self, MaybeUninit};
#[derive(Clone,Copy,PartialEq,Eq,Debug)]
pub enum Color {Yellow, Red, Blue, White, Orange, Green}
#[derive(Clone,Copy,PartialEq,Eq,Debug)]
pub enum Direction {CW, CCW}
#[derive(Clone,Copy,PartialEq,Eq,Debug)]
pub enum Face {Front, Back, Left, Right, Up, Down}
... |
pub use linux_macros::{kstr_pub as kstr};
use crate::kty::{c_char};
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct KStr(*const c_char);
impl KStr {
pub unsafe fn new(ptr: *const c_char) -> KStr {
KStr(ptr)
}
pub fn as_ptr(self) -> *const c_char {
self.0
}
}
|
use std;
use std::io::Read;
use rustc_serialize::json;
#[derive(RustcDecodable)]
pub struct Credentials {
pub username: String,
pub password: String,
}
pub fn root_dir() -> std::path::PathBuf {
let mut path = std::env::home_dir().unwrap();
path.push(".config/neubauten/");
return path;
}
pub fn spotify_path... |
//!
//! Test whether, when using bb8_diesel, database queries starve execution of
//! the rest of the current task. We'd expect so, based on the docs. This
//! example shows the behavior using `tokio::select!`.
//!
use bb8_diesel_test::sleep_using_db_pool;
use bb8_diesel_test::sleep_using_tokio;
use std::time::Durat... |
use std::ops::BitXor;
use std::cmp;
use std::iter;
use num_rational::Ratio;
pub fn block_xor<T>(block1: &[T], block2: &[T]) -> Vec<T::Output>
where T: BitXor + Clone + Copy {
let block_size = cmp::min(block1.len(), block2.len());
let mut new_block = Vec::with_capacity(block_size);
for i in 0..bloc... |
//mod level;
//use level;
use graphics::{self, Transformed};
use opengl_graphics::GlGraphics;
use piston::event::*;
use piston::input::keyboard::Key;
use level::Level;
const DARK : [f32; 4] = [0.4, 0.4, 0.4, 0.8];
const WHITE: [f32; 4] = [0.8, 0.8, 0.8, 0.8];
pub struct Game {
level: Level,
player: Player,... |
use crate::{
opcode::{execute_alu_8, execute_pop_16, execute_push_16, LoadOperand8, Opcode, Prefix},
smallnum::{U1, U2, U3},
tables::{
lookup16_r12, lookup8_r12, F3F5_TABLE, HALF_CARRY_ADD_TABLE, HALF_CARRY_SUB_TABLE,
SZF3F5_TABLE, SZPF3F5_TABLE,
},
RegName16, RegName8, Regs, Z80Bus,... |
use smol::Timer;
use std::time::Duration;
/// Sleep for any number of seconds.
pub async fn sleep(seconds: u32) {
Timer::after(Duration::from_secs(seconds.into())).await;
}
|
//! Unique keys and key paths.
use std::hash::Hash;
use std::panic::Location;
/// A unique call location.
///
/// These come from `#[track_caller]` annotations. It is a newtype
/// so we can use it as a key in various contexts; the traits we
/// want are not implemented on the inner type.
#[derive(Clone, Copy, Debug)... |
#[test]
fn t24_outline_basic_render() {
use agg::{Pixfmt,Rgb8,Rgba8};
use agg::{RendererPrimatives,RasterizerOutline};
let pix = Pixfmt::<Rgb8>::new(100,100);
let mut ren_base = agg::RenderingBase::new(pix);
ren_base.clear( Rgba8::new(255, 255, 255, 255) );
let mut ren = RendererPrimatives::wit... |
//! blci
/// Isolate lowest clear bit
pub trait Blci {
/// Sets all bits of `self` to 1 except for the least significant zero bit.
///
/// If there is no zero bit in `self`, it sets all bits.
///
/// # Instructions
///
/// - [`BLCI`](http://support.amd.com/TechDocs/24594.pdf):
/// - D... |
use crate::error::Error;
use crate::poseidon::SimplePoseidonBatchHasher;
use crate::{Arity, BatchHasher, Strength, DEFAULT_STRENGTH};
use generic_array::GenericArray;
use paired::bls12_381::Fr;
use std::marker::PhantomData;
#[derive(Clone, Copy, Debug)]
pub enum BatcherType {
GPU,
CPU,
}
#[cfg(not(target_os =... |
use std::fmt::Display;
use std::str::FromStr;
use std::path::Path;
pub fn arg_err(idx: usize, str: &str, message: impl Display) {
println!("Error in arg {} \"{}\": {}", idx + 1, str, message)
}
pub trait ArgParser<'a, T> {
/// Possible names, including any "-"
const NAMES: &'static [&'static str];
///... |
use assert_cmd::prelude::*;
use std::env::set_current_dir;
use std::error::Error;
use std::fs::read_to_string;
use std::fs::remove_dir_all;
use std::path::Path;
use std::process::Command;
mod test_utilities;
use test_utilities::{create_toml_config, ensure_correct_dir, ConfigToml, ConfigV03X};
/// Upgrades a v0.1.x c... |
use crate::header_verifier::{NumberVerifier, PowVerifier, TimestampVerifier, VersionVerifier};
use crate::{BlockErrorKind, NumberError, PowError, TimestampError, ALLOWED_FUTURE_BLOCKTIME};
use ckb_error::assert_error_eq;
use ckb_pow::PowEngine;
use ckb_test_chain_utils::MockMedianTime;
use ckb_types::{constants::BLOCK_... |
//! The definition of session backends
mod cookie;
mod redis;
pub use self::cookie::CookieSessionBackend;
pub use self::imp::Backend;
#[cfg(feature = "redis-backend")]
pub use self::redis::RedisSessionBackend;
pub(crate) mod imp {
use futures::{Future, Poll};
use tsukuyomi::error::Error;
use tsukuyomi::... |
use std::io::Read;
use bayard_client::client::client::{create_client, Clerk};
use clap::ArgMatches;
use iron::headers::ContentType;
use iron::prelude::*;
use iron::typemap::Key;
use iron::{status, Chain, Iron, IronResult, Request, Response};
use logger::Logger;
use persistent::Write;
use router::Router;
use serde_json... |
mod map_union;
mod my_last_write_wins;
mod point;
mod with_bot;
pub use map_union::{MapUnionHashMapDeserializer, MapUnionHashMapWrapper};
|
use mongodb::Client;
use bson::{Document,Bson,oid};
use std::sync::Arc;
use std::sync::{Mutex,MutexGuard};
use mongodb::db::{ThreadedDatabase,Database};
use mongodb::ThreadedClient;
use iron::typemap::Key;
use model;
use service;
use serde::{Deserialize, Serialize, Deserializer};
use rustc_serialize::json;
use chrono::... |
// local imports
use charts::SourceSeries;
/// Utility functions.
/// Get lowest value among `length` data points in given `source`.
pub fn lowest(source: SourceSeries, length: usize) -> Option<f64> {
if length <= 0 {
return None;
}
let lowest = source.get(0);
if lowest.is_none() {
... |
use std::fmt::Display;
pub trait Summary {
fn author(&self) -> String;
fn summarize(&self) -> String {
format!("Similar articles by {}", self.author())
}
}
pub struct NewsArticle {
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary f... |
#![cfg_attr(RUSTC_WITH_SPECIALIZATION, feature(min_specialization))]
#![allow(clippy::integer_arithmetic)]
#![allow(clippy::mut_from_ref)]
mod bucket;
mod bucket_item;
pub mod bucket_map;
mod bucket_stats;
mod bucket_storage;
mod index_entry;
pub type MaxSearch = u8;
pub type RefCount = u64;
|
//! Render utilities which don't belong anywhere else.
use std::fmt::{Display, Formatter, Result};
pub fn as_display<F: Fn(&mut Formatter<'_>) -> Result>(f: F) -> impl Display {
struct ClosureDisplay<F: Fn(&mut Formatter<'_>) -> Result>(F);
impl<F: Fn(&mut Formatter<'_>) -> Result> Display for ClosureDisplay<... |
use core::{
convert::TryFrom,
fmt,
};
use std::io;
use crate::version::Version;
use crate::consts::*;
/// A handle of a device connection.
///
/// The connection between the programmer and the system may break at any time.
/// When this happens, methods of `Handle` should return `Err` values other than
///... |
extern crate glutin_window;
extern crate graphics;
extern crate opengl_graphics;
extern crate piston;
use ::piston::event_loop::*;
use ::piston::window::WindowSettings;
use glutin_window::GlutinWindow;
use opengl_graphics::{GlGraphics, OpenGL};
use piston::input::*;
use std::collections::LinkedList;
use std::iter::Fro... |
use crate::geometry::{FDisplacement, FPoint};
use crate::input::cursor::CursorManager;
use crate::input::keyboard::Keyboard;
use std::rc::Rc;
use wlroots_sys::*;
use xkbcommon::xkb;
// NOTE Taken from linux/input-event-codes.h
// TODO Find a way to automatically parse and fetch from there.
pub const BTN_LEFT: u32 = 0x... |
// Copyright 2017 tokio-jsonrpc Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except accord... |
#[doc = "Reader of register EP_ACTIVE"]
pub type R = crate::R<u32, super::EP_ACTIVE>;
#[doc = "Writer for register EP_ACTIVE"]
pub type W = crate::W<u32, super::EP_ACTIVE>;
#[doc = "Register EP_ACTIVE `reset()`'s with value 0"]
impl crate::ResetValue for super::EP_ACTIVE {
type Type = u32;
#[inline(always)]
... |
use std::iter::repeat;
fn rec_can_make_word(index: usize, word: &str, blocks: &[&str], used: &mut[bool]) -> bool {
let c = word.chars().nth(index).unwrap().to_uppercase().next().unwrap();
for i in 0..blocks.len() {
if !used[i] && blocks[i].chars().any(|s| s == c) {
used[i] = true;
... |
#[doc = "Register `HDP1R_CUR` reader"]
pub type R = crate::R<HDP1R_CUR_SPEC>;
#[doc = "Field `HDP1_STRT` reader - HDPL barrier start set in number of 8 Kbytes sectors"]
pub type HDP1_STRT_R = crate::FieldReader;
#[doc = "Field `HDP1_END` reader - HDPL barrier end set in number of 8 Kbytes sectors"]
pub type HDP1_END_R ... |
use crate::{
Parser,
ParseRule,
OwnedParse,
ParseContext,
expressions::ExpressionParser,
type_::TypeParser,
};
use core::pos::BiPos;
use ir::{
Chunk,
hir::HIRInstruction
};
use ir_traits::WriteInstruction;
use lexer::tokens::{
TokenType,
TokenData,
};
use notices::{
Diag... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use std::borrow::Borrow;
use std::borrow::Cow;
use std::cell::Cell;
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::col... |
use aes::{Aes128, BlockEncrypt, NewBlockCipher, cipher::{generic_array::GenericArray}};
use rand_core::OsRng;
use x25519_dalek::{EphemeralSecret, PublicKey};
use super::status::Status;
use std::{fs::File, io::{self, Read, Write}, net::TcpStream};
pub struct Client {
stream: TcpStream,
cipher: Aes128,
buff... |
//! Defines the `Value` type and its related constants.
/// Evaluation value in centipawns.
///
/// Positive values mean that the position is favorable for the side
/// to move. Negative values mean the position is favorable for the
/// other side (not to move). A value of `0` means that the chances
/// are equal. Fo... |
extern crate dotenv;
use crate::errors::ServiceError;
use crate::graphql::Context;
use crate::models::character::Character;
use diesel::prelude::*;
pub fn characters(context: &Context) -> Result<Vec<Character>, ServiceError> {
use crate::schema::characters::dsl::*;
let conn: &MysqlConnection = &context.db.lock... |
//Temporary warning disables for development
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
//use std::ptr;
use trees::{tr, Node};
//Struct representing a node
#[derive(Copy, Clone)]
struct CraftingNode{
test_id: i16, //Temporary ID for testing known graphs
is_goal: bool,
progress: i16... |
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// 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>,... |
// q0062_unique_paths
struct Solution;
impl Solution {
pub fn unique_paths(m: i32, n: i32) -> i32 {
if m * n == 0 {
return 0;
}
let m = m as usize;
let n = n as usize;
let mut map = Vec::with_capacity(m);
for _ in 0..n - 1 {
map.push(vec![0; ... |
use std::collections::HashSet;
fn main() {
let input = include_str!("../data/2015-03.txt");
println!("Part 1: {}", part1(input));
println!("Part 2: {}", part2(input));
}
fn part1(input: &str) -> usize {
let mut santa = Santa::new();
for m in input.chars() {
santa.go(m);
}
santa.hou... |
use super::ui::*;
use std::collections::HashMap;
use std::io::Error as IoError;
use std::path::Path;
use std::{fmt, fs};
use toml_document::ParserError as TomlError;
#[derive(Debug, Default)]
pub struct Config {
pub server: String,
pub nick: String,
pub user: String,
pub real: String,
pub pass: S... |
mod env;
mod eval;
mod ops;
mod parser;
mod tree;
use env::Env;
use eval::*;
use parser::*;
fn main() {
let mut global_env = Env::new();
let program = "(+ (/ (- 5 2) 3) (* 2 5.1))";
match parse(program) {
Ok(tree) => match eval(&tree, &mut global_env) {
Ok(val) => println!("{:?}", val)... |
//! Methods for dumping serializable structs to a compressed binary format,
//! used to allow fast startup times
//!
//! Currently syntect serializes [`SyntaxSet`] structs with [`dump_to_uncompressed_file`]
//! into `.packdump` files and likewise [`ThemeSet`] structs to `.themedump` files with [`dump_to_file`].
//!
//!... |
use crate::http::{delete_step_page, create_step_page, update_step_page, read_step_page};
use crate::storage::{
storage_actor::StorageExecutor,
storage_driver::StorageDriver,
};
use actix::{SyncArbiter, System, SystemRunner};
use actix_files::Files;
use actix_web::{
middleware,
web::{delete, get, post, p... |
pub fn is_subsequence(s: String, t: String) -> bool {
fn core(s: &str, t: &str) -> bool {
if s.len() == 0 {
return true
}
if t.len() == 0 {
return false
}
if s.len() > t.len() {
return false
}
// Now we can safely assume 1 <... |
use crate::{
automata::{
eliminate_epsilon_transitions, reachable_states, TyAlphabet, TyAutomaton, TyAutomatonData,
TypeAutomataEdgesVisitor, TypeStateData, TypeStateVisitor,
},
error::TyError,
fold::TyFoldable,
polarity::{CorrectPolarityFolder, Polarity, PolarityVisitor},
scope:... |
use std::fs::File;
use std::io::Read;
fn main() {
let mut file = File::open("d02-input").unwrap();
let mut input = String::new();
file.read_to_string(&mut input).unwrap();
let mut valid_pass = 0;
for line in input.lines() {
let line2 = &line.replace(":", " ");
let chunks: Vec<_> = line2.split_whitespace().co... |
#![doc(test(attr(deny(warnings))))]
//! Joachim Henke's basE91 encoding implementation for Rust
//! http://base91.sourceforge.net
use std::iter::Iterator;
const ENTAB: [u8; 91] = [
b'A', b'B', b'C', b'D', b'E', b'F', b'G', b'H', b'I', b'J', b'K', b'L', b'M',
b'N', b'O', b'P', b'Q', b'R', b'S', b'T', b'U', b'... |
use std::error::Error;
#[macro_use] extern crate text_io;
extern crate clap;
use clap::{Arg, App, SubCommand, value_t};
mod modules;
pub use modules::day1;
pub use modules::day2;
pub use modules::day3;
pub use modules::day4;
pub use modules::day5;
pub use modules::day6;
fn main() -> Result<(), Box<dyn Error>> {
... |
use failure::Error;
use rocket::State;
use rocket_contrib::json::{Json, JsonValue};
use crate::Context;
use crate::model::link::{ LinkDAO, Link };
#[get("/all")]
pub fn all(ctx: State<Context>) -> Result<JsonValue, Error> {
let link_dao = LinkDAO::new(ctx.db.clone())?;
match link_dao.get_latest() {
... |
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn deser_header_add_layer_version_permission_retry_after_seconds(
header_map: &http::HeaderMap,
) -> Result<std::option::Option<std::string::String>, smithy_http::header::ParseError> {
let headers = header_map.get_all("Retry-Af... |
use crate::decoder::decoder::{Decoder, DecoderResult};
use crate::decoder::instructions::decode_expression;
use crate::decoder::types::{
decode_function_type, decode_global_type, decode_limits, decode_memory_type, decode_value_type,
};
use crate::decoder::values::{decode_name, decode_u32};
use crate::structure::*;
... |
extern crate extended_collections;
extern crate rand;
use extended_collections::bp_tree::{BpMap, Result};
use self::rand::{thread_rng, Rng};
use std::fs;
use std::panic;
use std::vec::Vec;
fn teardown(test_name: &str) {
fs::remove_file(format!("{}.dat", test_name)).ok();
}
fn run_test<T>(test: T, test_name: &str... |
use std::sync::Arc;
use vulkano::device::{Device, DeviceExtensions, QueuesIter};
use vulkano::instance::{self, Features, Instance, InstanceExtensions, PhysicalDevice, QueueFamily,
debug::DebugCallback};
use vulkano::swapchain::Surface;
use vulkano_win::{self, VkSurfaceBuild};
use winit;
pub fn ... |
use std::collections::HashMap;
use std::ffi::c_void;
use std::os::raw::c_char;
use std::slice;
use opendp::data::Column;
use crate::core::{FfiObject, FfiOwnership, FfiResult, FfiSlice, FfiError};
use crate::util;
use crate::util::{Type, TypeContents, c_bool, parse_type_args};
use std::fmt::Debug;
use opendp::error::F... |
use std::process;
use colored::*;
pub fn error_bomb( arg : &str )
{
println!( "{}", "\n!!! ERROR !!!\n".red() );
match arg {
"seq_title_not_same" => println!( "Inadequate format in Multi-FASTA file." ),
"seq_len_not_same" => println!( "The length of all the sequences must be same." ),
"site_ent_len_n... |
mod collada;
mod image_namer;
mod gltf;
use cli::Args;
use errors::Result;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use util::namers::UniqueNamer;
use util::OutDir;
use db::Database;
use convert::image_namer::ImageNamer;
use connection::{Connection, ConnectionOptions};
pub fn main(args: &Args) -... |
#![feature(cfg_target_feature)]
#![cfg_attr(feature = "strict", deny(warnings))]
#![cfg_attr(feature = "cargo-clippy", allow(option_unwrap_used))]
extern crate cupid;
#[macro_use]
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
extern crate stdsimd;
#[test]
#[cfg(any(target_arch = "x86", target_arch = "x86_... |
// TODO: Import those from libc, see https://github.com/rust-lang/libc/pull/1638
const AT_HWCAP: u64 = 16;
const HWCAP_SHA2: u64 = 64;
#[inline(always)]
pub fn sha2_supported() -> bool {
let hwcaps: u64 = unsafe { libc::getauxval(AT_HWCAP) };
(hwcaps & HWCAP_SHA2) != 0
}
|
use async_trait::async_trait;
use common::result::Result;
use crate::domain::contract::{Contract, ContractId};
use crate::domain::publication::PublicationId;
#[async_trait]
pub trait ContractRepository {
async fn next_id(&self) -> Result<ContractId>;
async fn find_by_id(&self, contract_id: &ContractId) -> R... |
use log::*;
use std::collections::{BTreeMap, BTreeSet};
use std::fmt;
use std::ops::{Index, IndexMut};
use crate::row::Row;
pub type State = BTreeSet<usize>;
pub type Alphabet = Vec<usize>;
pub struct Table {
row_assignments: Vec<usize>,
rows: Vec<Row>,
}
impl Table {
pub fn new(rows: Vec<Row>, num_rows... |
use crate::{
grid::{
config::{Border as GBorder, ColoredConfig, Entity},
records::{ExactRecords, Records},
},
settings::CellOption,
};
/// Border represents a border of a Cell.
///
/// ```text
/// top border
/// |
/// ... |
pub mod captcha;
pub mod extitem;
pub mod item;
pub mod search;
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::Write;
#[derive(Clone, Deserialize, Serialize)]
pub struct Config {
pub cookie: String,
pub base_url: String,
}
impl Config {
pub fn dump_config(&self) {
let json =... |
use super::pherepherial::gpioa;
use super::pherepherial::rcc;
use super::pherepherial::usart1;
pub fn init() {
// PA9, PA10
rcc::apb2enr::iopaen::set(1);
rcc::apb2enr::afioen::set(1);
gpioa::crh::mode9::set(1);
gpioa::crh::cnf9::set(2);
gpioa::crh::mode10::set(0);
gpioa::crh::cnf10::set(1);
... |
use azure_core::prelude::*;
use azure_identity::token_credentials::DefaultAzureCredential;
use azure_identity::token_credentials::TokenCredential;
use azure_storage::core::prelude::*;
use azure_storage::data_lake::prelude::*;
use chrono::Utc;
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn ... |
use std::{fmt::Display, ops::Sub};
use derive_more::From;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, From)]
pub enum ClientMessage {
Init(ClientInit),
Update(ClientUpdate),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ClientInit {
pub video_hash: S... |
use crate::set::Set;
use std::collections::btree_set::BTreeSet;
impl<A> Set<A> for BTreeSet<A>
where
A: Ord,
{
fn size(&self) -> usize {
self.len()
}
fn contains(&self, value: &A) -> bool {
BTreeSet::contains(self, value)
}
fn is_subset<R: Set<A>>(&self, other: R) -> bool {
... |
extern crate tplinker;
use std::net::SocketAddr;
use clap::{App, Arg, SubCommand};
use tplinker::{
capabilities::Switch,
datatypes::DeviceData,
devices::Device,
};
fn command_discover(json: bool) {
for (addr, data) in tplinker::discover().unwrap() {
let device = Device::from_data(addr, &data... |
extern crate app_dirs;
extern crate clap;
extern crate rand;
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde;
pub mod shared;
pub mod librarian;
pub mod planner;
pub mod cli;
|
fn row_sum_odd_numbers(n:i64) -> i64 {
return n * n * n;
}
|
mod framework;
mod app;
fn main() {
let mut settings = framework::WindowSettings::new();
settings.gl_version = (4, 5);
settings.window_size = (1920, 1080);
settings.title = String::from("Main");
framework::Runner::new(app::App::default(), settings).run();
}
|
use bitwise::bitwiseops;
use bitwise::hex_rep::ToHexRep;
use challengeinfo::challenge::{Challenge, ChallengeInfo};
pub const INFO2: ChallengeInfo<'static> = ChallengeInfo {
set_number: 2,
challenge_number: 2,
title: "Fixed XOR",
description: "",
url: "http://cryptopals.com/sets/1/challenges/2",
};... |
pub mod api_error;
pub mod client;
pub mod downloads;
pub mod query;
pub mod request_counter;
pub mod sso;
pub mod update_checker;
pub use api_error::*;
pub use client::*;
pub use downloads::*;
pub use query::*;
pub use request_counter::RequestCounter;
pub use update_checker::*;
|
use clap::{Arg, App};
use err_derive::Error;
use serde::{Serialize, Deserialize};
use shell_macro::shell;
use std::ffi::OsString;
use std::env;
use std::fs::File;
use std::path::Path;
pub const BUILD_VERSION: &str = shell!("git describe --tags $(git rev-list --tags --max-count=1)");
pub const BUILD_COMMIT_ID: &str = s... |
//! This module contains a collection of various tools to use to manipulate
//! and control messages and data associated with raft.
// Copyright 2017 PingCAP, Inc.
//
// 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... |
pub fn max_area_ori(height: Vec<i32>) -> i32 {
use std::cmp::{max, min};
let mut largest = min(height[1], height[0]);
for i in 0..height.len()-1 {
if height[i] == 0 {
continue
}
for j in max(i+1, (largest / height[i]) as usize)..height.len() {
let volume = (j... |
use std::{borrow::Cow, iter, ops, slice};
use crate::{
bit_set,
bit_set::ops::*,
bit_set::private,
bit_set::{BoxWords, CowWords, Words},
};
/// Trait for an unsigned int; seen as a bit vector with fixed size
/// or an element of bit vector.
///
/// This trait is public but sealed.
pub trait Word:
... |
use ethabi::{Function, Token, Uint};
use crate::utils::contract_builder::ContractBuilder;
#[derive(Debug, Clone)]
pub struct ExampleContract {
send_fn: Function,
request_fn: Function,
}
#[derive(Debug, Clone)]
pub enum ExampleContractError {
InvalidArgument(String),
FailedConversion(String),
Unkno... |
pub mod microvm;
pub mod risc_v_emu;
pub mod r650x;
fn main() {
}
|
use crate::{EntryTrigger, Hidden, Name, PeriodicHiding};
use specs::prelude::*;
pub struct PeriodicHidingSystem {}
impl<'a> System<'a> for PeriodicHidingSystem {
type SystemData = (
Entities<'a>,
WriteStorage<'a, PeriodicHiding>,
WriteStorage<'a, Hidden>,
WriteStorage<'a, EntryTrig... |
use libc::c_int;
use libc::c_void;
use crate::generated::{spdk_poller, spdk_poller_register /*spdk_poller_unregister*/};
pub struct PollerHandle {
#[allow(dead_code)]
pub(crate) poller: *mut spdk_poller,
#[allow(dead_code)]
pub(crate) closure: Box<dyn Fn() -> bool>,
}
impl Drop for PollerHandle {
... |
#![feature(plugin, box_syntax, box_patterns, slice_patterns, advanced_slice_patterns, exit_status)]
#[macro_use] extern crate ast;
#[macro_use] extern crate middle;
extern crate getopts;
extern crate rbtree;
use ast::ast::CompilationUnit;
use ast::context::{Context, CONTEXT};
use ast::error::{FatalError, ERRORS};
use... |
//! Program state processor
use crate::access_control;
use fund::{
accounts::{
fund::{Fund, FundType},
vault::TokenVault,
},
error::{FundError, FundErrorCode},
};
use serum_common::pack::Pack;
use solana_program::{
account_info::{next_account_info, AccountInfo},
msg,
program_op... |
//! #290. 单词规律
//! 给定一种规律 pattern 和一个字符串 str ,判断 str 是否遵循相同的规律。
//! 这里的 遵循 指完全匹配,例如, pattern 里的每个字母和字符串 str 中的每个非空单词之间存在着双向连接的对应规律。
//! #解题思路
//! 分别进行hash,匹配出现的位置是否相同
use std::collections::HashMap;
pub struct Solution;
impl Solution {
pub fn word_pattern(pattern: String, s: String) -> bool {
if pattern.i... |
// Copyright (c) 2018 The rust-gpio-cdev Project Developers.
//
// 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. This file may not be copied, modified, or dist... |
use crate::StorageExecutor;
use actix_web::{
web::{Data, Json},
Error, HttpResponse,
};
use proger_core::protocol::{request::CreateStepPage, response::PageAccess};
use crate::storage::storage_driver::{StorageCmd, StorageDriver};
use actix::Addr;
pub async fn create_step_page<T: StorageDriver>(
payload: Js... |
use std::marker::PhantomData;
use necsim_core_bond::{NonNegativeF64, PositiveF64};
use priority_queue::PriorityQueue;
use necsim_core::{
cogs::{
Backup, CoalescenceSampler, DispersalSampler, EmigrationExit, GloballyCoherentLineageStore,
Habitat, ImmigrationEntry, LineageReference, RngCore, Speciat... |
import!(vsl_ast);
import!(vsl_decl);
import!(vsl_entity);
import!(vsl_typealias);
import!(vsl_type);
|
//std::slice::from_raw_parts;
#[repr(packed)]
pub struct Deposit{
pub_key: [i8;48],
withdrawal_credentials: [i8;48],
amount: u64,
}
#[repr(packed)]
#[allow(dead_code)]
pub struct Args {
pre_state: [i8;32],
post_state: [i8;32],
deposit_count: u32,
deposits: *mut Deposit,
block_size: u32,
block_... |
//! Tests auto-converted from "sass-spec/spec/non_conformant/parser/interpolate/44_selector/double_escape"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/non_conformant/parser/interpolate/44_selector/double_escape/12_double_escaped_interpolated_value_todo.hrx"
#[test]
fn t12_double_escaped_interpolated_val... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.