text stringlengths 8 4.13M |
|---|
// Copyright 2014 nerd-games.com.
//
// Licensed under the Apache License, Version 2.0.
// See: http://www.apache.org/licenses/LICENSE-2.0
// This file may only be copied, modified and distributed according to those terms.
use gl;
use gl::types::*;
use std::mem;
#[experimental]
pub struct BufferObject {
pub id: GLu... |
pub use super::dvec2::*;
#[derive(Debug)]
pub struct Particle {
pub pos: dvec2,
pub vel: dvec2,
pub mass: f64,
}
|
use std::time::Duration;
use bson::RawDocumentBuf;
use serde::{Deserialize, Serialize};
use crate::{
bson::{doc, oid::ObjectId, DateTime, Document, Timestamp},
client::{
options::{ServerAddress, ServerApi},
ClusterTime,
},
cmap::{Command, Connection},
error::Result,
sdam::{Serv... |
#![no_std]
#![cfg_attr(feature = "inline-asm", feature(asm))]
#[macro_use]
mod macros;
#[export_name = "error: bumblebee-core appears more than once in the dependency graph"]
#[doc(hidden)]
pub static __ONCE__: () = ();
pub mod register;
|
use actix_web::ResponseError;
use async_trait::async_trait;
use deadpool_postgres::Pool;
use drogue_cloud_database_common::{
auth::authorize,
error::ServiceError,
models::{app::*, Lock},
DatabaseService,
};
use drogue_cloud_service_api::auth::user::{UserDetails, UserInformation};
use drogue_cloud_servic... |
// 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 std::{
cell::RefCell,
cmp,
collections::{HashMap, HashSet},
ops::Range,
ptr,
};
use rayon::slice::ParallelSliceMut;
use crate::{
... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ManagementLockOwner {
#[serde(rename = "applicationId", default, skip_serializing_if = "Option::is_none")]
... |
// Copyright 2019 EinsteinDB Project Authors. Licensed under Apache-2.0.
use criterion::{Bencher, Criterion};
use violetabft::Progress;
pub fn bench_progress(c: &mut Criterion) {
bench_progress_default(c);
}
pub fn bench_progress_default(c: &mut Criterion) {
let bench = |b: &mut Bencher| {
// No setu... |
use clap::{App as args, Arg, ArgMatches};
use failure::Error;
use std::string::String;
// general configuration across all the app.
#[derive(Clone, Debug)]
pub struct Configuration {
pub redis_address: String,
pub server: Server,
}
// configuration for the underlying http(s) server.
#[derive(Clone, Debug)]
pu... |
diesel::table! {
subscriptions (id) {
id -> BigInt,
hub -> Text,
topic -> Text,
secret -> Text,
expires_at -> Nullable<BigInt>,
}
}
// XXX: We need to manually implement this until the following patch lands:
// <https://github.com/diesel-rs/diesel/pull/3400>
impl Default... |
use crate::errors::*;
use crate::types::*;
use uuid::Uuid;
/// Describes a message
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Message {
#[doc(hidden)]
#[serde(rename(serialize = "@type", deserialize = "@type"))]
td_name: String,
#[doc(hidden)]
#[serde(rename(serialize = "@e... |
extern crate imghdr;
use imghdr::Type;
use std::fs::File;
use std::io::Read;
use std::string::String;
use std::option::Option;
/// Returns a file's extension based on the its hexidecimal representation.
fn get_file_extension(vec: &[u8]) -> Option<&'static str> {
match imghdr::from_bytes(vec) {
// Gif 87a a... |
pub struct Solution;
impl Solution {
pub fn min_path_sum(grid: Vec<Vec<i32>>) -> i32 {
let (m, n) = (grid.len(), grid[0].len());
let mut dp: Vec<Vec<i32>> = vec![vec![std::i32::MAX; n]; m];
dp[0][0] = grid[0][0];
for i in 0..m-1 {
for j in 0..n-1 {
dp[i+1... |
use assert_cmd::prelude::*;
use std::path::PathBuf;
use std::process::Command;
/// Get a `Command` for this crate's `sightglass-cli` executable.
pub fn sightglass_cli() -> Command {
drop(env_logger::try_init());
Command::cargo_bin("sightglass-cli").unwrap()
}
/// Get the path to the engine we are testing with.... |
//! IO functions
use super::core::{Relationship, SysDiagram, Table};
use super::parser;
use std::convert::TryFrom;
use std::io::Error as IoError;
use std::io::{Cursor, Read, Seek};
use base64::decode as base64_decode;
use base64::DecodeError as Base64DecodeError;
use cfb::CompoundFile;
use displaydoc::Display;
use ms_... |
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Configuration Register"]
pub cfg: CFG,
#[doc = "0x04 - Restart the watchdog timer."]
pub rstrt: RSTRT,
#[doc = "0x08 - Locks the WDT"]
pub lock: LOCK,
#[doc = "0x0c - Current Counter Value for WDT"]
pub cou... |
//! # Freedesktop Desktop Entry Specification
//!
//! This crate provides a library for efficiently generating valid desktop entries.
//!
//! - [Specification](https://specifications.freedesktop.org/desktop-entry-spec/latest/index.html)
//!
//! ```
//! use freedesktop_desktop_entry::{Application, DesktopEntry, DesktopT... |
#![macro_use]
mod deictics;
mod helper_macros;
mod offsets;
use nom;
use self::deictics::{indexical, weekday};
use self::offsets::offset;
use super::ParsedDate;
named!(pub date_token <&[u8], ParsedDate>,
ws!(
alt_complete!(
indexical | weekday | offset
)
)
);
pub fn parse_date(da... |
use std::collections::HashSet;
fn contains_sum(slice: &[i64], number: i64) -> bool {
let mut table = HashSet::new();
for s in slice {
let diff = number - s;
if table.contains(&diff) {
return true;
}
table.insert(s);
}
false
}
fn find_weakness(data: &[i64], ... |
#[doc = "Register `EXTI_SWIER3` reader"]
pub type R = crate::R<EXTI_SWIER3_SPEC>;
#[doc = "Register `EXTI_SWIER3` writer"]
pub type W = crate::W<EXTI_SWIER3_SPEC>;
#[doc = "Field `SWI65` reader - SWI65"]
pub type SWI65_R = crate::BitReader;
#[doc = "Field `SWI65` writer - SWI65"]
pub type SWI65_W<'a, REG, const O: u8> ... |
#[doc = "Register `UR4` reader"]
pub type R = crate::R<UR4_SPEC>;
#[doc = "Register `UR4` writer"]
pub type W = crate::W<UR4_SPEC>;
#[doc = "Field `BCM4_ADD1` reader - Mass Erase Protected Area Disabled for bank 1"]
pub type BCM4_ADD1_R = crate::FieldReader<u16>;
#[doc = "Field `BCM4_ADD1` writer - Mass Erase Protected... |
use crate::uses::*;
use core::sync::atomic::{AtomicUsize, Ordering};
use core::ops::DerefMut;
use alloc::sync::Arc;
use alloc::collections::BTreeMap;
use bitflags::bitflags;
use crate::util::FutexGuard;
use crate::make_id_type;
use crate::mem::{PAGE_SIZE, VirtRange};
use crate::sched::proc_c;
use crate::mem::virt_alloc... |
pub mod user;
pub mod topic;
pub mod comment;
pub mod message;
pub mod topic_vote;
pub mod comment_vote;
pub mod category;
pub mod collection; |
use dotenv;
use tokio_postgres::{Error, NoTls};
fn config(name: &str, default_value: &str) -> String {
dotenv::var(name).unwrap_or(default_value.to_owned())
}
#[tokio::main]
async fn main() -> Result<(), Error> {
let conn_string = format!(
"host={} port={} user={} password={} dbname={} applicatio... |
//! This library provides easy api for key management for key-value storages
//!
//! # Example
//! ```
//! use the_key::*;
//! // Define key parts
//! define_key_part!(Users, &[11, 11]);
//! define_key_part!(Profiles, &[22, 22]);
//! define_key_part!(Photos, &[33, 33]);
//!
//! // Define keys sequences
//! define_key_s... |
#![feature(inclusive_range_syntax)]
fn get_hasher_from_input(input: &str) -> String {
let mut lengths = input.as_bytes().iter().cloned().collect::<Vec<_>>();
lengths.extend(vec![17u8, 31, 73, 47, 23]);
let mut curr_pos = 0;
let mut skip_size = 0;
let mut sparse_hash = (0..=255).into_iter().collect... |
use byteorder::{ByteOrder, NativeEndian};
use crate::{
traits::{Emitable, Parseable},
DecodeError, Field,
};
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct NeighbourCacheInfo {
pub confirmed: u32,
pub used: u32,
pub updated: u32,
pub refcnt: u32,
}
const CONFIRMED: Field = 0..4;
cons... |
use std::error::Error as StdError;
use duck_dns::{Client, TxtOptions};
use structopt::StructOpt;
use crate::opts::Account;
#[derive(StructOpt, Debug)]
pub struct Txt {
#[structopt(short = "x", long)]
pub txt: String,
#[structopt(flatten)]
pub account: Account,
#[structopt(skip)]
pub verbose: ... |
#[doc = "Register `RXDR` reader"]
pub type R = crate::R<RXDR_SPEC>;
#[doc = "Field `RXDR` reader - CEC Rx Data Register"]
pub type RXDR_R = crate::FieldReader;
impl R {
#[doc = "Bits 0:7 - CEC Rx Data Register"]
#[inline(always)]
pub fn rxdr(&self) -> RXDR_R {
RXDR_R::new((self.bits & 0xff) as u8)
... |
// Copyright 2018 Vlad Yermakov
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
use std::{num, fmt, error::Error};
use crate::{
ContextHandle, Contextual, Polarity, DotId, AtomId, PortId, LinkId, ForkId, JoinId, FusetId,
Multiplicity, Capacity, domain::DotsetId,
};
#[derive(Clone, Debug)]
pub enum AcesErrorKind {
ContextMismatch,
FramePolarityMismatch,
WedgeNotAForkMismatch(Jo... |
use std::iter::once;
pub fn build_proverb(list: Vec<&str>) -> String {
if list.is_empty() { return String::new() }
let last_line = format!("And all for the want of a {}.", list[0]);
(0..list.len() - 1)
.map(|i| format!("For want of a {} the {} was lost.", list[i], list[i+1]))
.chain(once(... |
//! This module derives an trait [`VerifierApi`] from the runtime api `SettlementApi`
//! as well as the implementation to provide convenient interfaces used in the fraud
//! proof verification.
// TODO: Remove once fraud proof v2 is implemented.
#![allow(unused)]
use codec::{Decode, Encode};
use domain_runtime_primi... |
use wasmer_runtime_core::{
backend::RunnableModule,
module::ModuleInfo,
structures::Map,
types::{FuncIndex, FuncSig, SigIndex},
};
use wasmparser::{Operator, Type as WpType};
pub trait ModuleCodeGenerator<FCG: FunctionCodeGenerator, RM: RunnableModule> {
fn check_precondition(&mut self, module_info... |
use clap::{Parser, Subcommand, ValueEnum};
#[derive(Parser)]
pub struct Cli {
#[command(subcommand)]
pub cmd: Cmd,
#[arg(short, long)]
/// Disable the keyring integration
pub no_keyring: bool,
}
#[derive(Subcommand)]
pub enum Cmd {
/// Initialize the password store
Init,
/// Add a new... |
use std::{
collections::HashMap,
env,
sync::{Arc, Mutex},
};
use eyre::{eyre, Context};
use oauth2::{
basic::BasicClient, reqwest::async_http_client, url::Url, AuthUrl, AuthorizationCode, ClientId,
ClientSecret, CsrfToken, PkceCodeChallenge, PkceCodeVerifier, RedirectUrl, RevocationUrl,
Scope, ... |
#![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)]
SparkBatch_GetSparkBatchJobs(#[from] ... |
use std::cell::RefCell;
use std::rc::Rc;
use crate::treenode::TreeNode;
pub fn invert_tree(root: Option<Rc<RefCell<TreeNode>>>) -> Option<Rc<RefCell<TreeNode>>> {
root.map(|root| {
{
let mut r = root.borrow_mut();
let left = r.left.take();
let right = r.right.take();
... |
// Some temporary libuv hacks for servo
#[cfg(target_os = "linux")];
#[cfg(target_os = "macos")];
#[cfg(target_os = "freebsd")];
#[nolink]
native mod rustrt {
fn rust_uvtmp_create_thread() -> thread;
fn rust_uvtmp_start_thread(thread: thread);
fn rust_uvtmp_join_thread(thread: thread);
fn rust_uvtmp_... |
mod hash;
mod eq;
mod samplefitness;
use std::hash::Hash;
use std::rc::Rc;
use std::collections::BTreeMap;
use std::collections::HashMap;
struct SampleFitness<T> {
sample: T,
fitness: f64
}
|
use ferris_base;
mod utils;
#[test]
fn pushed_by_user() {
let start = vec![
"........🦀🚩",
"..🦀🚩🚩....",
"............",
"Fe==U Fg==Pu",
];
let inputs = vec![ferris_base::core::direction::Direction::RIGHT];
let end = vec![
"........🦀🚩",
"....🦀🚩🚩.... |
use std;
use std::marker::PhantomData;
use futures::{Async, Future, Poll};
use futures::unsync::oneshot::{Canceled, Receiver};
use futures::sync::oneshot::{Receiver as SyncReceiver};
use fut::ActorFuture;
use actor::Actor;
use handler::{Handler, ResponseType};
enum RequestIo<M: ResponseType> {
Local(Receiver<Res... |
#[doc = "Reader of register RCC_SPI6CKSELR"]
pub type R = crate::R<u32, super::RCC_SPI6CKSELR>;
#[doc = "Writer for register RCC_SPI6CKSELR"]
pub type W = crate::W<u32, super::RCC_SPI6CKSELR>;
#[doc = "Register RCC_SPI6CKSELR `reset()`'s with value 0"]
impl crate::ResetValue for super::RCC_SPI6CKSELR {
type Type = ... |
#[doc = "Reader of register INTR_CAUSE"]
pub type R = crate::R<u32, super::INTR_CAUSE>;
#[doc = "Reader of field `COUNTER_INT`"]
pub type COUNTER_INT_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - Counters interrupt signal active. If the counter is disabled through CTRL.COUNTER_ENABLED, the associated interr... |
use crate::uses::*;
use core::sync::atomic::{AtomicBool, AtomicU8, AtomicUsize, Ordering};
use core::convert::TryInto;
use core::slice;
use core::time::Duration;
use alloc::collections::BTreeMap;
use modular_bitfield::BitfieldSpecifier;
use crate::kdata::cpud;
use crate::mem::virt_alloc::{VirtMapper, VirtLayoutElement,... |
#[doc="
Destructively copies an extent from one array of bits to another. Bits are represented by `[u64]`, 64 per element in little-engian order, numbered from zero. If `src` overlaps with `dst` in anyway, it is undefined. If the corresponding offset plus `count` exceeds the bounds of the `[u64]` slice, it is undefine... |
extern crate onig;
use std::fmt;
use self::onig::*;
/// A display command
trait Command {
/// Apply a command to the display.
fn apply(&self, display: &mut PixelBuffer);
}
/// A pixel buffer
trait PixelBuffer {
fn get(&self, x: usize, y: usize) -> bool;
fn set(&mut self, x: usize, y: usize, value: b... |
/// An enum to represent all characters in the KanaExtendedA block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum KanaExtendedA {
/// \u{1b100}: '𛄀'
HentaiganaLetterReDash3,
/// \u{1b101}: '𛄁'
HentaiganaLetterReDash4,
/// \u{1b102}: '𛄂'
HentaiganaLetterRoDash1,
/// \u{1b103... |
use lazy_static::lazy_static;
use pulldown_cmark as cmark;
use regex::Regex;
use crate::context::RenderContext;
use crate::table_of_contents::{make_table_of_contents, Heading};
use config::highlighting::highlight_code;
use errors::{Error, Result};
use front_matter::InsertAnchor;
use utils::site::resolve_internal_link;... |
#[doc = "Register `FDCAN_RXF0S` reader"]
pub type R = crate::R<FDCAN_RXF0S_SPEC>;
#[doc = "Field `F0FL` reader - Rx FIFO 0 fill level Number of elements stored in Rx FIFO 0, range 0 to 3."]
pub type F0FL_R = crate::FieldReader;
#[doc = "Field `F0GI` reader - Rx FIFO 0 get index Rx FIFO 0 read index pointer, range 0 to ... |
use serenity::framework::standard::{macros::check, Reason};
use serenity::model::prelude::Message;
use serenity::prelude::Context;
use super::consts::OWNER_ID;
#[check]
#[name = "Owner"]
async fn owner_check(_: &Context, msg: &Message) -> Result<(), Reason> {
if msg.author.id == OWNER_ID {
return Ok(());
... |
use settimeout::set_timeout;
use std::path::Path;
pub enum CommandType {
Sh,
Node,
None,
}
#[macro_export]
macro_rules! command_from_string {
($ss: expr) => {
match $ss {
"sh" => $crate::runner::CommandType::Sh,
"node" => $crate::runner::CommandType::Node,
_... |
use std::fs;
use std::ffi::OsStr;
use std::path::Path;
use std::io::{ self, Read, Write };
use smallvec::SmallVec;
use rayon::prelude::*;
use bstr::{ ByteVec, ByteSlice };
use fast_floats::Fast;
use fast_lines::ReadLine;
fn filesize(size: isize) -> SmallVec<[u8; 8]> {
const UNITS: [u8; 4] = [b'K', b'M', b'G', b'T... |
use crate::metrics::utils::graphemes;
use crate::metrics::utils::Array2D;
use std::cmp;
use std::collections::HashMap;
use std::hash::Hash;
pub fn distance(a: &str, b: &str, ignore_case: bool) -> i64 {
if ignore_case {
return distance_impl(&graphemes(&a.to_lowercase()), &graphemes(&b.to_lowercase()));
... |
use crate::coordinates::{CoordinateSystem, Point};
use crate::tensors::{Covector, InvTwoForm, Matrix, Scalar, TwoForm, Vector};
use crate::typenum::consts::{U0, U1, U2, U4};
use crate::{inner, mul};
use generic_array::arr;
use generic_array::GenericArray;
struct Test2;
impl CoordinateSystem for Test2 {
type Dimens... |
use super::content::FileContent;
use std::fmt;
use colors::*;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum TokenType {
Error,
StartOfInput,
EndOfInput,
Identifier,
Value,
OpenBracket,
AtOpenBracket,
CloseBracket,
Colon,
}
pub struct Token<'a> {
pub token_type: TokenTyp... |
/**
* Day 8 - Handheld Halting
*/
use std::fmt;
use parse_display::{Display, FromStr};
// ---------------------------------------------------------------------------
// Data types
// ---------------------------------------------------------------------------
#[derive(Clone, Debug, FromStr, Display)]
enum Operation ... |
use std::collections::BTreeMap;
use std::fs::{create_dir, File};
use std::io::{self, BufRead, Seek};
use std::path::Path;
use sections::apploader::{Apploader, APPLOADER_OFFSET};
use sections::dol::DOLHeader;
use sections::dol::segment::Segment;
use sections::fst::{
entry::DirectoryEntry,
FST,
};
use sections::... |
use generator::GeneratorType;
use maze::Coord;
use solver::SolverType;
pub const COLOR_BACKGROUND: (u8, u8, u8) = (7, 16, 19);
pub const COLOR_START: (u8, u8, u8) = (149, 198, 35);
pub const COLOR_END: (u8, u8, u8) = (229, 88, 18);
pub const COLOR_WALL: (u8, u8, u8) = (239, 231, 218);
pub const COLOR_EXPLORED: (u8, ... |
#![allow(non_snake_case, non_camel_case_types)]
use libc::{c_char, c_int, c_void};
use crate::buffer::ssh_buffer;
use crate::session::ssh_counter;
use crate::session::ssh_session;
use crate::timeval;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct ssh_channel_struct {
_unused: [u8; 0],
}
pub type ssh_channe... |
//! MIPS CP0 EntryHi register
#[derive(Clone, Copy, Debug)]
pub struct EntryHi {
pub bits: u32,
}
impl EntryHi {
register_field!(get_vpn2, set_vpn2, 13, 19);
register_field!(get_asid, set_asid, 0, 8);
}
register_rw!(10, 0);
register_struct_rw!(EntryHi);
#[inline]
pub fn set_entry(vpn2: u32, asid: u32) {... |
use std::borrow::Borrow;
fn main() {
let arr: [i32; 2] = [1, 2];
println!("{}", arraySum(arr.borrow()));
}
#[allow(non_snake_case)]
fn arraySum(arr: &[i32]) -> i32 {
let mut num = 0;
for x in arr {
num += *x;
}
num
}
|
// Copyright 2014 Felix S. Klock II. 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>, at your
// opt... |
use super::ClientState;
use crate::terrain::block::Block;
use crate::{comp, ChatType};
use vek::*;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ClientMsg {
Register {
player: comp::Player,
password: String,
},
Character {
name: String,
body: comp::Body,
m... |
use super::MapArchitect;
use crate::prelude::*;
pub struct RoomsArchitect {}
impl MapArchitect for RoomsArchitect {
fn new(&mut self, rng: &mut RandomNumberGenerator) -> MapBuilder {
let mut mb = MapBuilder::empty();
mb.fill(TileType::Wall);
mb.build_random_rooms(rng);
mb.build_co... |
#[macro_use]
extern crate diesel;
extern crate juniper;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate validator_derive;
extern crate validator;
#[macro_use]
extern crate lazy_static;
use crate::serde::ser::Error as SerdeError;
use actix_cors::Cors;
use a... |
use amethyst::ecs::{storage::DenseVecStorage, Component, Entity};
#[derive(Component)]
#[storage(DenseVecStorage)]
pub struct OwnedBy {
pub entity: Entity,
}
|
#[doc = "Reader of register C1MR"]
pub type R = crate::R<u32, super::C1MR>;
#[doc = "Writer for register C1MR"]
pub type W = crate::W<u32, super::C1MR>;
#[doc = "Register C1MR `reset()`'s with value 0xffff_ffff"]
impl crate::ResetValue for super::C1MR {
type Type = u32;
#[inline(always)]
fn reset_value() ->... |
//! Library for parsing OpenGEX formatted files.
#![deny(missing_docs)]
#![feature(non_ascii_idents)]
pub mod structure;
|
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Identity {
#[serde(flatten)]
pub tracked_resource: TrackedResource,
#[serde(default, skip_serializing_i... |
//! The state machine of the program.
use std::sync::mpsc::Receiver;
mod client;
mod offline;
mod server;
use input::Input;
/// The state the program is in.
#[derive(Debug)]
pub enum State {
/// The program is offline. This is the initial state.
Offline,
/// The program is in client mode. This state c... |
fn next_sequence(in_seq: &[i8]) -> Vec<i8> {
assert!(!in_seq.is_empty());
let mut result = Vec::new();
let mut current_number = in_seq[0];
let mut current_runlength = 1;
for i in &in_seq[1..] {
if current_number == *i {
current_runlength += 1;
} else {
res... |
use atlas::{Error, Result, battery, efoy};
use atlas::scanner::{ScanStop, ScannerPowerOn};
use chrono::{DateTime, Utc};
use regex::Regex;
use sbd::mo::Message;
use std::cmp::Ordering;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use std::vec::IntoIter;
lazy_static! {
static ref RE: Regex = Regex... |
use super::{EthereumRPC, FilterRPC, DebugRPC, Either, RPCTransaction, RPCTrace, RPCStep, RPCBlock, RPCLog, RPCReceipt, RPCLogFilter, RPCBlockTrace, RPCDump, RPCDumpAccount, RPCTraceConfig};
use super::util::*;
use super::filter::*;
use super::serialize::*;
use super::solidity::*;
use error::Error;
use miner::MinerStat... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - LPTIM interrupt and status register"]
pub lptim_isr: LPTIM_ISR,
#[doc = "0x04 - LPTIM interrupt clear register"]
pub lptim_icr: LPTIM_ICR,
#[doc = "0x08 - LPTIM interrupt enable register"]
pub lptim_ier: LPTIM_IER,
... |
#[doc = "Register `BDMUPDR` reader"]
pub type R = crate::R<BDMUPDR_SPEC>;
#[doc = "Register `BDMUPDR` writer"]
pub type W = crate::W<BDMUPDR_SPEC>;
#[doc = "Field `MCR` reader - MCR"]
pub type MCR_R = crate::BitReader;
#[doc = "Field `MCR` writer - MCR"]
pub type MCR_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, ... |
pub fn game_of_life(board: &mut Vec<Vec<i32>>) {
let m = board.len();
let n = board[0].len();
let mut helper = vec![vec![0; n]; m];
let ds = [[-1, 0], [-1, -1], [0, -1], [1, -1], [1, 0], [1, 1], [0, 1], [-1, 1]];
for i in 0..m {
for j in 0..n {
let mut neighbours = 0;
... |
use poise::serenity_prelude::{OAuth2Scope, Permissions};
use crate::{
types::{Error, PoiseContext},
utils::discord::{get_meta_info, get_rest_latency, reply_embed, MetaInfoResult},
};
/// Register application commands in this guild or globally
///
/// Run with no arguments to register in guild, run with argume... |
/// CreateBranchProtectionOption options for creating a branch protection
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct CreateBranchProtectionOption {
pub approvals_whitelist_teams: Option<Vec<String>>,
pub approvals_whitelist_username: Option<Vec<String>>,
pub block_on_outdated_branc... |
use ::common::*;
use ::lib::unionfind::UnionFind;
use ::State;
#[derive(Serialize, Deserialize, Debug, Default)]
struct AI {
dist: Vec<Vec<usize>>
}
pub fn setup(state: &mut State) {
eprintln!("randw");
let g = state.graph.iter().map(|u| u.iter().map(|&(v, _)| v).collect()).collect();
state.ai = ::serde_json::to_... |
#![deny(clippy::all, clippy::pedantic)]
pub fn is_leap_year(year: u64) -> bool {
// A leap year is every 4 years, provided the year is not also divisible by 100 and indivisble by 400.
(year % 4 == 0) && !(year % 100 == 0 && year % 400 > 0)
}
|
use crate::errors::Errcode;
use std::path::PathBuf;
use std::fs::{create_dir_all, remove_dir};
use nix::mount::{mount, umount2, MsFlags, MntFlags};
use nix::unistd::{chdir, pivot_root};
use rand::Rng;
pub fn random_string(n: usize) -> String {
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
... |
pub mod components;
use crate::components::card::*;
use crate::components::player::*;
use crate::components::util::Util;
use rand::Rng;
pub const WIZARD: Card = Card {
rank: Rank::Wizard,
suit: Suit::Suitless,
};
pub const JESTER: Card = Card {
rank: Rank::Jester,
suit: Suit::Suitless,
};
pub fn get_... |
use crate::uses::*;
use crate::mem::{VirtRange, PAGE_SIZE};
use crate::sched::proc_c;
use crate::consts::KERNEL_VMA;
// this trait represents data structures that can be fetched from user controlled memory by syscalls
// safety: because the user controls the memory, the structre shold be defined for all bit patterns
/... |
u2se std::error::Error;
use std::io::{self, prelude::*};
use std::collections::BinaryHeap;
/// Return the minimum "difficulty score" of any workout.
///
/// We are allowed to insert up to `k` extra sessions.
fn min_workout(minutes: &[u32], k: usize) -> u32 {
let n = minutes.len();
assert!(n >= 2);
// Max-... |
use super::Sorter;
use std::fmt::Debug;
pub struct Quicksort;
impl Sorter for Quicksort {
fn sort<T: Ord + Clone + Debug>(self, slice: &mut [T]) {
if slice.len() == 0 {
return;
}
quicksort(slice, 0, slice.len() - 1);
}
}
fn quicksort<T: Ord + Clone + Debug>(slice: &mut [T]... |
extern crate serenity;
use serenity::http::Http;
use std::{error::Error, fs};
pub async fn execute_webhook(contents: &str) -> Result<(), Box<dyn Error>> {
let (id, token) = get_webhook_data()?;
let http = Http::new_with_token(&token[..]);
let webhook = http.get_webhook_with_token(id, &token[..]).await?;
... |
mod helpers;
use jsonprima;
// Empty string.
test!(test_0, "\"\"", vec![]);
// A single space as only value within string.
test!(test_1, "\" \"", vec![]);
// Multiple spaces as only values within string.
test!(test_2, "\" \"", vec![]);
// Reverse solidus.
test!(test_3, "\"\\\\\"", vec![]);
// Multiple reverse... |
// Basically #include <patronus/patronus-provider.h>
extern crate patronus_provider;
// Import some names into the scope so we do not have to type
// qualified names all the time
use patronus_provider::*;
use std::borrow::Cow;
use std::ffi::CStr;
use std::os::raw::{c_char, c_int, c_void};
// Rust, like C++ uses name ... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use core::fmt;
// ASSERTION ERROR
// ================================================================================================
///... |
//! This is a simple client API for Sonnerie, a timeseries database.
//!
//! It lets you do a variety of insertions and reads.
//!
//! # Example
//!
//! ```no_run
//! extern crate sonnerie_api;
//! fn main() -> std::io::Result<()>
//! {
//! let stream = std::net::TcpStream::connect("localhost:5599")?;
//! let m... |
use std::fs::OpenOptions;
use std::fs::File;
use std::io::prelude::*;
use std::io::Error;
use std::io::{BufRead, BufReader};
use aes::cipher::generic_array::GenericArray;
use aes::cipher::{BlockCipher, NewBlockCipher};
use aes::Aes256;
pub fn make_ascii_titlecase(s: String) -> String {
let mut s = s.clone();
let s... |
use serde::{Serialize, Deserialize};
use std::io::{Read, BufReader, Write, BufWriter};
use std::fs::File;
use std::path::PathBuf;
use super::Error;
/// codicのコンフィグファイルのデータ
#[derive(Serialize, Deserialize, Debug)]
pub struct Config {
token: String,
casing: String,
}
impl Config {
/// コンフィグファイルの初期生成時のcasin... |
use cocoa::base::id;
use cocoa::foundation::NSUInteger;
use {MTLClearColor, MTLOrigin, MTLRegion, MTLSize};
#[link(name = "Metal", kind = "framework")]
extern "C" {
pub fn MTLCopyAllDevices() -> id;
pub fn MTLCreateSystemDefaultDevice() -> id;
}
#[no_mangle]
#[inline(always)]
pub extern "C" fn MTLOriginMake(x... |
#[doc = "Register `C2APB2ENR` reader"]
pub type R = crate::R<C2APB2ENR_SPEC>;
#[doc = "Register `C2APB2ENR` writer"]
pub type W = crate::W<C2APB2ENR_SPEC>;
#[doc = "Field `TIM1EN` reader - CPU2 TIM1 timer clock enable"]
pub type TIM1EN_R = crate::BitReader;
#[doc = "Field `TIM1EN` writer - CPU2 TIM1 timer clock enable"... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Resource {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(d... |
extern crate hyper;
extern crate tokio;
use futures::stream;
use hyper::client::HttpConnector;
use hyper::rt::{Future, Stream};
use hyper::{Body, Client, Request, StatusCode, Uri};
fn decode_hex(string: &str) -> Result<Vec<u8>, &str> {
string
.chars()
.map(|character| character.to_digit(16))
... |
use std::io;
use crate::base::Part;
pub fn part1(r: &mut dyn io::Read) -> Result<String, String> {
solve(r, Part::One)
}
pub fn part2(r: &mut dyn io::Read) -> Result<String, String> {
solve(r, Part::Two)
}
fn solve(r: &mut dyn io::Read, part: Part) -> Result<String, String> {
let mut input = String::new... |
use std::collections::HashMap;
use std::fmt::{Debug, Error, Formatter};
use std::sync::atomic::{AtomicUsize, Ordering};
use crate::common::{self, Const, Id, Op2};
use crate::env;
use crate::explicit::{self, Type};
use crate::hindley_milner;
use crate::implicit;
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone)]
p... |
use std::{mem, sync::Arc};
use crate::{
binary::{Encoder, ReadEx},
errors::Result,
types::{
column::{
array::ArrayColumnData, nullable::NullableColumnData, ArcColumnWrapper, ColumnWrapper,
},
Marshal, SqlType, StatBuffer, Unmarshal, Value, ValueRef, HasSqlType,
},
};... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.