text stringlengths 8 4.13M |
|---|
use rocket::form::Form;
use rocket::fs::TempFile;
use rocket::response::{Debug, Flash, Redirect};
use rocket::Route;
use crate::db::schema::files;
use crate::db::user::UserId;
use crate::db::Connection;
use diesel;
use diesel::prelude::*;
use std::error::Error;
use std::fs;
use std::path::Path;
#[derive(Insertable)]... |
use colored::*;
use crate::input;
pub struct Board {
pub field: Vec<Vec<&'static str>>,
pub display: Vec<Vec<&'static str>>,
width: usize,
height: usize,
mine_count: usize
}
impl Board {
pub fn create(width: usize, height: usize, mine_count: usize) -> Board {
let mut field: Vec<Vec<&'static str>> = ve... |
use crate::{algorithms::Translate, CanvasSpace, DrawingSpace, Point, Vector};
use euclid::Scale;
use specs::prelude::*;
use specs_derive::Component;
#[derive(Debug, Clone, PartialEq, Component)]
#[storage(HashMapStorage)]
pub struct Viewport {
/// The location (in drawing units) this viewport is centred on.
pu... |
extern crate hacl_star;
use hacl_star::hmac;
const KEY: &[u8] = b"key";
const INPUT: &[u8] = b"The quick brown fox jumps over the lazy dog";
const OUTPUT: [u8; 32] = [0xf7, 0xbc, 0x83, 0xf4, 0x30, 0x53, 0x84, 0x24, 0xb1, 0x32, 0x98, 0xe6, 0xaa, 0x6f, 0xb1, 0x43, 0xef, 0x4d, 0x59, 0xa1, 0x49, 0x46, 0x17, 0x59, 0x97, ... |
//! Companies Service, presents CRUD operations
use diesel::connection::AnsiTransactionManager;
use diesel::pg::Pg;
use diesel::Connection;
use r2d2::ManageConnection;
use failure::Error as FailureError;
use stq_types::{Alpha3, CompanyId};
use models::companies::{Company, NewCompany, UpdateCompany};
use repos::Repos... |
use std::{fmt, thread, time::Duration};
use crate::System;
/// A helper wrapper to run test actors for a certain period.
///
/// # Example
///
/// ```ignore
/// use actor::testing::SystemThread;
///
/// SystemThread::run_for(Duration::from_millis(100), |system| {
/// system.spawn(SomeActor::new())?;
/// });
/// `... |
#![cfg(feature = "stream")]
#[macro_use]
extern crate nom;
use nom::{Producer,Consumer,ConsumerState,Input,Move,MemProducer,IResult,HexDisplay};
#[derive(PartialEq,Eq,Debug)]
enum State {
Beginning,
Middle,
End,
Done,
Error
}
struct TestConsumer {
state: State,
c_state: ConsumerState<usize,(),Move>,... |
use actionable::Permissions;
use custodian_password::{
LoginFinalization, LoginRequest, LoginResponse, RegistrationFinalization, RegistrationRequest,
RegistrationResponse,
};
use schema::SchemaName;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use crate::{
connection::{AccessPolicy, Database,... |
// 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 criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
use rand::Rng;
use std::time::Duration;
use winter_ma... |
use std::net::{TcpStream};
use std::io::{Read, Write};
use std::str::from_utf8;
fn main() {
match TcpStream::connect("localhost:5044") {
Ok(mut stream) => {
println!("Successfully connected");
let msg = b"Hello";
stream.write(msg).unwrap();
let mut data = [0... |
// SPDX-FileCopyrightText: 2020-2021 HH Partners
//
// SPDX-License-Identifier: MIT
use serde::{Deserialize, Serialize};
use crate::SPDXExpression;
/// https://spdx.github.io/spdx-spec/5-snippet-information/
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct Snippet {
/// https://spdx.github.io/spdx-... |
pub struct Task {
pub name: &'static str,
}
pub struct TaskStatus;
#[cfg(test)]
mod test {
} |
use crate::asset::*;
use crate::reader::*;
use crate::util::*;
use anyhow::*;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::io::Cursor;
#[derive(Debug)]
pub struct Name {
pub index: u32,
pub name: String, // Size as a uint32, then null terminated string
pub non_case_preser... |
const DNS_CLASS_IN: u16 = 1;
const DNS_HEADER_SIZE: usize = 12;
const DNS_MAX_HOSTNAME_LEN: usize = 256;
const DNS_MAX_PACKET_SIZE: usize = 65_535;
const DNS_OFFSET_QUESTION: usize = DNS_HEADER_SIZE;
const DNS_TYPE_OPT: u16 = 41;
#[inline]
fn qdcount(packet: &[u8]) -> u16 {
(u16::from(packet[4]) << 8) | u16::from(... |
extern crate chrono;
use std::process::Command;
use worker::{Request, Response, Period};
use self::chrono::UTC;
pub struct Processor;
impl Processor {
pub fn run (request: Request) -> Response {
// starting process
let started_at = UTC::now();
let mut command = Command::new("sh");
command.arg("-c... |
#[macro_use]
extern crate lazy_static;
extern crate html5ever;
extern crate regex;
extern crate reqwest;
extern crate url;
pub mod html;
pub mod http;
pub mod utils;
|
use num_traits::Float;
use crate::solver::{SliceLike, SliceRef, Operator};
use crate::{LinAlgEx, splitm};
//
/// Matrix type and size
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum MatType
{
/// General matrix with a number of rows and a number of columns.
General(usize, usize),
/// Symmetr... |
pub mod simple;
pub mod spsc;
|
struct Complex { real: i32, imaginary: i32 }
//fn add_complex(c1: Complex, c2: Complex) -> Complex {
fn add_complex(c1: &Complex, c2: &Complex) -> Complex {
let r = c1.real + c2.real;
let i = c1.imaginary + c2.imaginary;
return Complex { real: r, imaginary: i };
}
fn square_complex_inplace(c: &mut Complex) {
... |
//! Functions and types related to windows.
use controls::Control;
use ffi_utils::{self, Text};
use libc::{c_int, c_void};
use std::cell::RefCell;
use std::ffi::CString;
use std::mem;
use ui_sys::{self, uiControl, uiWindow};
thread_local! {
static WINDOWS: RefCell<Vec<Window>> = RefCell::new(Vec::new())
}
define... |
// 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.
///! This module defines the `Uuid` type which represents a 128-bit Bluetooth UUID. It provides
///! convenience functions to support 16-bit, 32-bit, and 1... |
use serde::{Deserialize, Serialize};
#[derive(Copy, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, Debug)]
pub struct StoreConfig {
pub header_cache_size: usize,
pub cell_data_cache_size: usize,
pub block_proposals_cache_size: usize,
pub block_tx_hashes_cache_size: usize,
pub block_uncles_cach... |
#![no_std]
use serde_big_array::BigArray;
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize)]
struct S {
#[serde(with = "BigArray")]
arr: [SerOnly; 64],
}
#[derive(Debug, Clone, Copy, Serialize)]
struct SerOnly(u8);
#[derive(Deserialize)]
struct D {
#[serde(with = "BigArray")]
arr: [DeO... |
use itertools::Itertools;
use scan_fmt::scan_fmt;
#[aoc::main(11)]
pub fn main(input: &str) -> (u64, u64) {
solve(input)
}
#[aoc::test(11)]
pub fn test(input: &str) -> (String, String) {
let res = solve(input);
(res.0.to_string(), res.1.to_string())
}
#[derive(Clone, Debug)]
struct Operation {
op: ch... |
//! A simple Driver for the Waveshare 4.2" E-Ink Display via SPI
//!
//!
//! Build with the help of documentation/code from [Waveshare](https://www.waveshare.com/wiki/4.2inch_e-Paper_Module),
//! [Ben Krasnows partial Refresh tips](https://benkrasnow.blogspot.de/2017/10/fast-partial-refresh-on-42-e-paper.html) and
//! ... |
mod token;
mod tokenize;
pub use self::token::Token;
pub use self::token::Dictionary;
pub use self::token::Operator;
pub use self::token::Bracket;
pub use self::token::BracketSide;
pub use self::token::ReservedWord;
pub use self::tokenize::tokenize; |
use std::path::PathBuf;
use actix_cors::Cors;
use actix_web::{App, HttpServer, Responder, web, http::header};
use serde_derive::*;
use structopt::StructOpt;
use crate::dictionary::Dictionary;
use crate::errors::AppError;
use crate::screen::{Screen, Opt as ScreenOpt};
#[derive(StructOpt, Debug)]
#[structopt(name ... |
use std::collections::HashMap;
fn main(){
// //Vec
let mut vec = vec![1,2,3,4,5];
// show the contents of vec
for x in vec.iter() {
println!("{}",x);
}
println!("--------------------------------------");
// iter_mut :an iterator of mutable reference
for x in vec.iter_m... |
// Robert "Skipper" Gonzaelz <sgonzalez@hmc.edu>
// Starter code for HMC's MemorySafe, week 1
//
// The implementation of SinglyLinkedList
use Stack;
use std::mem;
pub struct SinglyLinkedList<T> {
head: Option<Box<Node<T>>>,
length: usize
}
struct Node<T> {
data: T,
next: Option<Box<Node<T>>>,
}
... |
use std::process::Command;
/// Spawn "youtube-dl" from PATH
#[cfg(target_os = "linux")]
pub fn spawn_command() -> Command {
return Command::new("youtube-dl");
}
/// Spawn "youtube-dl" for non-linux systems
#[cfg(not(target_os = "linux"))]
pub fn spawn_command() -> Command {
use std::env::current_exe;
use std::fs::... |
#[doc = "Register `CR` reader"]
pub type R = crate::R<CR_SPEC>;
#[doc = "Register `CR` writer"]
pub type W = crate::W<CR_SPEC>;
#[doc = "Field `EN` reader - AES enable"]
pub type EN_R = crate::BitReader;
#[doc = "Field `EN` writer - AES enable"]
pub type EN_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc ... |
/// Permute an integer pseudorandomly.
///
/// This is a bijective function emitting chaotic behavior. Such functions are used as building
/// blocks for hash functions.
pub fn sigma(mut x: u8) -> u8 {
x = x.wrapping_mul(211);
x ^= x >> 4;
x = x.wrapping_mul(211);
}
const INITIAL_STATE: u64 = 0x8a;
stru... |
use std::fmt::Display;
/// A specific [KDL Value](https://github.com/kdl-org/kdl/blob/main/SPEC.md#value).
#[derive(Debug, Clone, PartialEq)]
pub enum KdlValue {
/// A [KDL Raw String](https://github.com/kdl-org/kdl/blob/main/SPEC.md#raw-string).
RawString(String),
/// A [KDL String](https://github.com/kd... |
//! Functions related to parsing of input
#![deny(unused_must_use)]
use value::{Value, StringValue};
use error::{ParseError, ParseResult};
use std::io::{Read, BufRead, BufReader};
use std::str::FromStr;
use std::cmp::max;
use std::collections::VecDeque;
use unescape::unescape;
macro_rules! parse_err {
( $name:i... |
use super::colors::*;
use std::collections::BTreeMap;
// TODO: use new types so they can be converted into intermediate outputs automatically
pub trait Outputter {
fn output(&self, output: Output, eol: bool);
fn clear(&self);
}
impl<'a> From<&'a str> for Output {
fn from(s: &'a str) -> Self {
Outp... |
use super::super::pystring::{PyString, StringInfo};
use super::{check_dtype, HasPandasColumn, PandasColumn, PandasColumnObject, GIL_MUTEX};
use crate::constants::PYSTRING_BUFFER_SIZE;
use crate::errors::ConnectorXPythonError;
use anyhow::anyhow;
use fehler::throws;
use itertools::Itertools;
use ndarray::{ArrayViewMut2,... |
#[doc = "Reader of register RCC_MP_APB1ENSETR"]
pub type R = crate::R<u32, super::RCC_MP_APB1ENSETR>;
#[doc = "Writer for register RCC_MP_APB1ENSETR"]
pub type W = crate::W<u32, super::RCC_MP_APB1ENSETR>;
#[doc = "Register RCC_MP_APB1ENSETR `reset()`'s with value 0"]
impl crate::ResetValue for super::RCC_MP_APB1ENSETR ... |
struct Solution;
impl Solution {
// 题解中没有使用滚动数组优化的动态规划解法。
pub fn is_interleave(s1: String, s2: String, s3: String) -> bool {
let (s1, s2, s3) = (s1.as_bytes(), s2.as_bytes(), s3.as_bytes());
let (m, n) = (s1.len(), s2.len());
if m + n != s3.len() {
return false;
}
... |
use {
onex_loader::job_object::create_process_in_job_object,
std::{
env,
fs::{self, File},
path::PathBuf,
process,
},
util::{get_temp_dir, OffsetSeeker, OnexFile, ProjfsProvider, ReadSeek, Result},
uuid::Uuid,
winapi::um::wincon::FreeConsole,
zip::ZipArchive,
... |
use crate::estimate::Statistic;
use crate::plot::gnuplot_backend::{gnuplot_escape, Colors, DEFAULT_FONT, LINEWIDTH, SIZE};
use crate::plot::Size;
use crate::plot::{FilledCurve as FilledArea, Line, LineCurve, Rectangle};
use crate::report::BenchmarkId;
use crate::stats::univariate::Sample;
use criterion_plot::prel... |
use hocon::Error;
use hocon::Hocon;
use hocon::HoconLoader;
use std::time::Duration;
pub struct Config {
pub wait_timeout: Duration,
pub num_threads: usize,
pub num_nodes: usize,
pub ble_hb_delay: u64,
pub ble_initial_delay_factor: Option<u64>,
pub num_proposals: u64,
pub num_elections: u6... |
use std::{
sync::{Arc, Mutex},
time::Duration,
};
use futures::TryStreamExt;
use futures_util::{future::try_join_all, FutureExt};
use crate::{
bson::{doc, Document},
client::options::ClientOptions,
error::{ErrorKind, Result},
event::command::{CommandEvent, CommandEventHandler, CommandStartedEv... |
/// A LaTeX fragment.
///
/// # Semantics
///
/// # Syntax
///
/// Follows one of these patterns:
///
/// ```text
/// \NAME BRACKETS
/// \(CONTENTS\)
/// \[CONTENTS\]
/// $$CONTENTS$$
/// PRE$CHAR$POST
/// PRE$BORDER1 BODY BORDER2$POST
/// ```
///
/// `NAME` can contain any alphabetical character and can end with an as... |
#[doc = "Register `GPIOA_HWCFGR2` reader"]
pub type R = crate::R<GPIOA_HWCFGR2_SPEC>;
#[doc = "Field `AFRL_RES` reader - AFRL_RES"]
pub type AFRL_RES_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - AFRL_RES"]
#[inline(always)]
pub fn afrl_res(&self) -> AFRL_RES_R {
AFRL_RES_R::new(self.bi... |
use super::utils::parse_string;
use crate::ast::rules;
#[test]
fn test_exp_terminals() {
assert_eq!(parse_string("nil", rules::exp), "[Single(Nil)]");
assert_eq!(
parse_string("false", rules::exp),
"[Single(Boolean(false))]"
);
assert_eq!(parse_string("true", rules::exp), "[Single(Boole... |
use crate::infinite_memory_intcomputer::*;
pub fn one() {
let mut computer = IntcodeComputer::new_from_file("input/day_nine.txt");
computer.provide_input(1);
loop {
match computer.run().unwrap() {
IntcodeComputerState::Halted => break,
IntcodeComputerState::OutputProduced(ou... |
#![feature(use_extern_macros)]
#[macro_use]
extern crate serde_derive;
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
mod mandelbrot;
use mandelbrot::get_mandelbrot_set;
#[derive(Deserialize)]
pub struct Configuration {
pub iterations: usize,
pub width: u32,
pub height: u32,
pub xmin: f64,... |
fn main() {
println!("{}", chessboard_cell_color("A1", "A2"));
}
fn chessboard_cell_color(cell1: &str, cell2: &str) -> bool {
let b1 = cell1.chars().nth(0).unwrap();
let b2 = cell1.chars().nth(1).unwrap();
let p1 = cell2.chars().nth(0).unwrap();
let p2 = cell2.chars().nth(1).unwrap();
(b1 as i16 + b2 as i16)... |
use std::fmt;
use std::env::var;
use std::process::Command;
pub mod colors;
pub use crate::colors::Colors;
#[derive(Debug)]
pub struct Title {
username: String,
hostname: String
}
pub fn username() -> String {
var("USERNAME").unwrap()
}
#[cfg(target_family = "unix")]
pub fn hostname() -> Result<String, ()> {
Ok... |
use crate::demo::data::DemoTick;
use bitbuffer::{BitRead, BitReadStream, BitWrite, BitWriteStream, Endianness};
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct StopPacket {
pub tick: DemoTick,
}... |
// Copyright 2018 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.
#![deny(warnings)]
#[macro_use] extern crate bitfield;
extern crate byteorder;
extern crate failure;
extern crate fuchsia_app as app;
extern crate fuchsia... |
use super::data::{ Object, Game, Tcod, UseResult, MessageLog, Item };
use super::spellcasting;
use super::equipment;
use crate::PLAYER;
use crate::app::equipment::get_equipped_in_slot;
pub fn pick_item_up(
object_id: usize,
objects: &mut Vec<Object>,
game: &mut Game,
) {
if game.inventory.len() >= 26 {... |
// Handles conversion from/to string
use super::u512;
impl std::str::FromStr for u512 {
type Err = &'static str;
fn from_str(number_str: &str) -> Result<u512, &'static str> {
let mut result = u512::zero();
for digit_char in number_str.chars() {
let cur_digit: u32 = match digit_cha... |
fn main() {
let n: usize = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end().parse().unwrap()
};
let mut sum: u64 = 0;
(0..n).for_each(|_| {
let (a, b) = {
let mut line = String::new();
std::io::stdin()... |
/** A container for aspects of a Portage Category
A portage [`Category`](crate::atom::Category) is a unique qualifier of a *class* of [`Package`](crate::atom::Package)'s,
but without an actual package name or version and does not support range or requality specifiers
### Usage
```rust
use grease::atom::Category;
let... |
use super::super::{head, navbar, scripts};
use maud::{DOCTYPE, Markup};
pub fn index() -> Markup {
html! {
(DOCTYPE)
html .no-js lang="en" dir="ltr" {
(head())
body {
(navbar())
div .grid-container {
div .grid-x .grid-padding-x {
div class="large-12 cell" {
h1 "Create a Build"
... |
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
#[allow(dead_code)]
struct Scanner<'a> {
cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
fn new(cin: StdinLock<'a>) -> Scanner<'a> {
Scanner { cin: cin }
}
fn read<T: FromStr>(&mut self) -> Option<T> {
let t... |
/// Error structure representing the basic error scenarios for `pg_query`.
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum Error {
ParseError(String),
InvalidAst(String),
InvalidJson(String),
}
/// Convenient Result alias for returning `pg_query::Error`.
pub type Result<T> = core::result::Result<T, Error>;... |
use Error;
use regex;
use std;
use tempdir;
// RAII wrapper for a child process that kills the process when dropped.
struct AutoKillProcess(std::process::Child);
impl Drop for AutoKillProcess {
fn drop(&mut self) {
let AutoKillProcess(ref mut process) = *self;
process.kill().unwrap();
proc... |
use ::Result;
extern "C" {
pub fn SOC_Initialize(context_addr: *mut u32, context_size: u32) -> Result;
pub fn SOC_Shutdown() -> Result;
}
|
mod calendar;
mod common;
mod events;
mod venues;
fn main() {
println!(
"
__________ .____ ______________________ _________ .__ .__
\\______ \\| | \\__ ___/\\_ _____/ \\_ ___ \\ | | |__|
| ___/| | | | | __)_ ______ / \\ \\/ | ... |
struct Solution;
impl Solution {
// bfs
pub fn solve(board: &mut Vec<Vec<char>>) {
if board.is_empty() || board[0].is_empty() {
return;
}
let (m, n) = (board.len(), board[0].len());
let mut queue = Vec::new();
// 上下边界
for i in 0..m {
if boa... |
use crate::network::{ Network };
use std::hash::{Hash};
use crate::cell::{Merge};
use std::collections::HashSet;
use std::rc::{Rc};
use std::cell::RefCell;
use std::fmt::Debug;
pub type Premise = String;
#[derive(Clone)]
pub struct TruthManagementSystem<A> {
network: Rc<RefCell<Network<A>>>,
invalid: HashSet<... |
use anyhow::Result;
use crate::Challenge;
pub struct Day06;
impl Challenge for Day06 {
const DAY_NUMBER: u32 = 6;
type InputType = Vec<Vec<u32>>;
type OutputType = u32;
fn part1(input: &Self::InputType) -> Result<Self::OutputType> {
Ok(input
.iter()
.map(|group| grou... |
pub mod controller;
pub mod cron_job;
pub mod model;
pub mod service;
|
use super::expressions::*;
use super::lex_token::{Token, TokenType};
use super::statements::*;
use super::LangConfig;
use bitflags;
type StmtBox<'a> = Box<StatementWrapper<'a>>;
const SPACE: &str = " ";
const TAB: &str = "\t";
const NEWLINE: &str = "\n";
const LPAREN: &str = "(";
const RPAREN: &str = ")";
const LBRAC... |
/// Known identifiers for the types of packets that might be captured in a `pcap` file. This tells
/// you how to interpret the packets you receive.
///
/// Look at [tcpdump.org](http://www.tcpdump.org/linktypes.html) for the canonical list with
/// descriptions.
#[derive(Copy, Clone, Debug, PartialEq, FromPrimitive, T... |
extern crate wasmer_runtime;
extern crate wasmer_runtime_core;
use libc::{uint32_t, uint8_t};
pub mod error;
pub mod export;
pub mod global;
pub mod import;
pub mod instance;
pub mod memory;
pub mod module;
pub mod table;
pub mod value;
#[allow(non_camel_case_types)]
#[repr(C)]
pub enum wasmer_result_t {
WASMER_... |
fn is_prime(i: &u32) -> bool {
let mut temp: u32 = 2;
while i > &temp {
if i % &temp == 0 {
return false;
}
temp += 1;
}
true
}
pub fn nth(n: u32) -> Option<u32> {
let mut init_vec: Vec<u32> = Vec::new();
let mut i: u32 = 2;
let mut counter: u32 = 0;
... |
pub use crate::{
ApplyLog, AsyncOnceCell, Ctx, Entity, Get, HashTable, Insert, InsertMut, OnceCell,
ProviderContainer, QueueRwLock, Remove, Tag, Transaction, VecTable,
};
#[cfg(feature = "derive")]
pub use crate::indexing;
|
// q0103_binary_tree_zigzag_level_order_traversal
struct Solution;
use crate::util::TreeNode;
use std::cell::RefCell;
use std::rc::Rc;
impl Solution {
pub fn zigzag_level_order(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<Vec<i32>> {
if let Some(rrc_root) = root {
let mut ret = vec![];
... |
use serde::{Deserialize, Serialize};
/// Version number.
#[derive(Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Serialize, Deserialize)]
pub struct VersionNumber(u64);
impl VersionNumber {
pub(crate) fn initial() -> Self {
Self(1)
}
pub(crate) fn next(&self) -> Self {
Self(self.0 + ... |
#[doc = "Register `CR` reader"]
pub type R = crate::R<CR_SPEC>;
#[doc = "Register `CR` writer"]
pub type W = crate::W<CR_SPEC>;
#[doc = "Field `RNGEN` reader - Random number generator enable"]
pub type RNGEN_R = crate::BitReader<RNGEN_A>;
#[doc = "Random number generator enable\n\nValue on reset: 0"]
#[derive(Clone, Co... |
mod query_grammar;
mod query_parser;
mod user_input_ast;
pub mod logical_ast;
pub use self::query_parser::QueryParser;
pub use self::query_parser::QueryParserError;
|
//! Types used to deserialize and work with data received from the API.
use std::fmt;
use chrono::{DateTime, NaiveDate, NaiveTime, Utc};
use optfield::optfield;
use serde::{Deserialize, Serialize};
use url::Url;
use crate::error::*;
use crate::params::{EpisodeParams, EpisodeQuery, EpisodeQueryParams};
use crate::ser... |
// PowerPC uses the following registers for args 1-6:
//
// arg1: r3
// arg2: r4
// arg3: r5
// arg4: r6
// arg5: r7
// arg6: r8
//
// Register r0 specifies the syscall number.
// Register r3 is also used for the return value.
// Registers r0, r3-r12, and cr0 are always clobbered.
//
// The `sc` instruction is used to ... |
fn main() {
tonic_build::compile_protos("proto/plugin/plugin.proto").unwrap();
} |
use core::ptr;
//Page flags
pub const PF_PRESENT: usize = 1;
pub const PF_WRITE: usize = 1 << 1;
pub const PF_USER: usize = 1 << 2;
pub const PF_WRITE_THROUGH: usize = 1 << 3;
pub const PF_CACHE_DISABLE: usize = 1 << 4;
pub const PF_ACCESSED: usize = 1 << 5;
pub const PF_DIRTY: usize = 1 << 6;
pub const PF_SIZE: usize... |
// Copyright (c) 2016, <daggerbot@gmail.com>
// This software is available under the terms of the zlib license.
// See COPYING.md for more information.
use std::cell::RefCell;
use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::ffi::{CStr, CString};
use std::mem;
use std::os::raw::*;
use std::ptr;
use ... |
#[macro_use]
extern crate lazy_static;
mod component_manager;
mod constants;
mod easyhash;
mod filesystem;
mod globals;
mod heartbeat;
mod locks;
mod modular;
mod operation;
use async_std;
use std::{env, error, thread, time};
use std::process::exit;
use std::sync::{mpsc};
// Types
pub type BoxedError = Box<dyn error::... |
//! Utilities for window handling of game engine.
use egui::CtxRef;
use crate::app::DeltaTime;
/// General event of game engine window.
pub enum Event {
/// Called when game window was created.
Created,
/// Called when game window was resized.
Resized(Size),
/// Called when game window needs up... |
use crate::tokenizer::ExprToken;
type Error = &'static str;
#[derive(PartialEq, Debug, Clone)]
pub enum ProcessedExprToken {
VarName(String),
Number(f64),
String(String),
Bool(bool),
Null,
//FnCall(&'a str, Vec<ProcessedToken<'a>>),
//Dot
VecAccess(String, Vec<Vec<ProcessedExprToken>>),... |
#[cfg(test)]
mod tests;
mod utils;
/// If we list all the natural numbers below 10 that are multiples of 3 or 5, we
/// get 3, 5, 6 and 9. The sum of these multiples is 23.
///
/// Find the sum of all the multiples of 3 or 5 below 1000.
#[allow(dead_code)]
fn problem_001() -> i32 {
let mut acc: i32 = 0;
fo... |
#[doc = "Reader of register DDRPHYC_BISTMSKR1"]
pub type R = crate::R<u32, super::DDRPHYC_BISTMSKR1>;
#[doc = "Writer for register DDRPHYC_BISTMSKR1"]
pub type W = crate::W<u32, super::DDRPHYC_BISTMSKR1>;
#[doc = "Register DDRPHYC_BISTMSKR1 `reset()`'s with value 0"]
impl crate::ResetValue for super::DDRPHYC_BISTMSKR1 ... |
extern crate rand;
use rand::{thread_rng, Rng};
use std::fs::File;
use std::io::BufReader;
use std::io::prelude::*;
#[derive(PartialEq, Eq, PartialOrd)]
struct Group {
size: usize,
quantum_entanglement: u64,
}
// 3 groups, A B C
// sum A == sum B == sum C
// A has fewest # of packages (use product of items i... |
use core::ptr;
pub unsafe fn init_bss() {
extern {
static mut __bss_start: u8;
static mut __bss_end: u8;
}
let bss_start = &mut __bss_start as *mut u8;
let bss_end = &mut __bss_end as *mut u8;
let bss_length = bss_end as usize - bss_start as usize;
ptr::write_bytes(bss_start, 0, bss_length);
}
pub unsafe f... |
#[doc = "Reader of register MMMS_ADVCH_NI_VALID"]
pub type R = crate::R<u32, super::MMMS_ADVCH_NI_VALID>;
#[doc = "Writer for register MMMS_ADVCH_NI_VALID"]
pub type W = crate::W<u32, super::MMMS_ADVCH_NI_VALID>;
#[doc = "Register MMMS_ADVCH_NI_VALID `reset()`'s with value 0"]
impl crate::ResetValue for super::MMMS_ADV... |
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use testcore::*;
use consts::*;
use wasmlib::*;
mod testcore;
mod consts;
#[no_mangle]
fn on_load() {
let exports = ScExports::new();
exports.add_func(FUNC_CALL_ON_CHAIN, func_call_on_chain);
exports.add_func(FUNC_CHECK_CONTEXT_FROM_F... |
//! Main application class module
//! Handles all platform-related, hardware-related stuff
//! and command-line interface
use crate::{
app::{
events::{Event, EventDevice, EventsSdl},
settings::{Settings, SoundBackend},
sound::{SoundDevice, DEFAULT_SAMPLE_RATE},
video::{Rect, Texture... |
mod helpers;
use helpers as h;
#[test]
fn pipeline_helper() {
let actual = h::pipeline(
r#"
open los_tres_amigos.txt
| from-csv
| get rusty_luck
| str --to-int
| sum
| echo "$it"
"#,
);
assert_eq!(
actual,
... |
use crate::camera::{Camera, CameraConfig};
use crate::color::color;
use crate::hittable::{
box3d::Box3D,
bvh::BvhNode,
flip_face::FlipFace,
hittable_list::HittableList,
rect::{XyRect, XzRect, YzRect},
rotate::RotateY,
sphere::Sphere,
translate::Translate,
Hittables,
};
use crate::mat... |
use crate::common::*;
pub(crate) trait RangeExt<T> {
fn range_contains(&self, i: &T) -> bool;
}
impl<T> RangeExt<T> for Range<T>
where
T: PartialOrd,
{
fn range_contains(&self, i: &T) -> bool {
i >= &self.start && i < &self.end
}
}
impl<T> RangeExt<T> for RangeInclusive<T>
where
T: PartialOrd,
{
fn r... |
use token;
pub trait WithPrefix<U> {
type Output;
fn with_prefix(self, prefix: U) -> Self::Output;
}
impl<T, A, B, U> WithPrefix<U> for token::Token<T, (A, B)>
where U: Clone,
A: Clone,
B: Clone
{
type Output = token::Token<T, (U, A, B)>;
fn with_prefix(self, prefix: U) -> to... |
#[doc = "Register `FLTCNVTIMR` reader"]
pub type R = crate::R<FLTCNVTIMR_SPEC>;
#[doc = "Field `CNVCNT` reader - 28-bit timer counting conversion time t = CNVCNT\\[27:0\\]
/ fDFSDMCLK The timer has an input clock from DFSDM clock (system clock fDFSDMCLK). Conversion time measurement is started on each conversion start ... |
#[allow(unused_imports)]
use log::{debug, error, info, warn};
use crate::{shader::ShaderInfo, Framebuffer};
use js_sys::Error;
use regex::Regex;
use std::collections::HashMap;
use web_sys::{
WebGl2RenderingContext as Context, WebGlBuffer, WebGlProgram, WebGlShader, WebGlTexture,
WebGlVertexArrayObject,
};
#[d... |
use ast::Ast;
#[allow(unused_imports)]
use nom::*;
use datatype::Datatype;
use std::str::FromStr;
use std::str;
named!(number_raw<i32>,
do_parse!(
number: map_res!(
map_res!(
recognize!(
digit
),
str::from_utf8
),
... |
use std::collections::VecDeque;
use std::iter::FromIterator;
use anyhow::Result;
use itertools::Itertools;
fn main() -> Result<()> {
let input: Vec<u32> = INPUT.chars().map(|l| l.to_string().parse().unwrap()).collect();
let result = crab_cups(&input, 100);
dbg!(result[1..].iter().join(""));
let mut ... |
#[doc = "Register `ISR` reader"]
pub type R = crate::R<ISR_SPEC>;
#[doc = "Register `ISR` writer"]
pub type W = crate::W<ISR_SPEC>;
#[doc = "Field `ALRAWF` reader - Alarm A write flag This bit is set by hardware when Alarm A values can be changed, after the ALRAE bit has been set to 0 in RTC_CR. It is cleared by hardwa... |
use crate::Num;
#[derive(Copy, Clone)]
pub struct Image {
pub aspect_ratio: Num,
pub width: usize,
pub height: usize,
}
impl Image {
pub(crate) fn from_width(aspect_ratio: Num, width: usize) -> Self {
Self {
aspect_ratio,
width,
height: (width as Num / aspec... |
fn main() {
// ----------Primitive Types----------
println!("==========Primitive Types==========");
// ----------Booleans----------
println!("----------Booleans----------");
let a = true;
let b: bool = false;
println!("a is: {}", a);
println!("b is: {}", b);
// ----------Char-----... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.