text stringlengths 8 4.13M |
|---|
use std::io::Read;
fn main() -> Result<(), Box<dyn std::error::Error>> {
if std::env::args().count() != 1 {
println!("compute_class_hash -- reads from stdin, outputs a class hash");
println!(
"the input read from stdin is expected to be a class definition, which is a json blob."
... |
//! Ideas for what a generated API might look like.
#[drive(Copy, Clone, PartialEq, Eq, Hash)]
pub struct Key<T> {
index: usize,
phantom: PhantomData<T>,
}
#[drive(Clone, PartialEq, Eq, Hash)]
pub struct KeySet<T> {
set: SetUsize,
phantom: PhantomData<Key<T>>,
}
polygraph!{
struct Person {
/// Biologi... |
pub mod accounts;
pub mod deal;
|
use base64;
use std::io::Read;
use std::str::FromStr;
use xml_rs::reader::{EventReader as XmlEventReader, ParserConfig, XmlEvent};
use {Date, Error, Result, PlistEvent};
pub struct EventReader<R: Read> {
xml_reader: XmlEventReader<R>,
queued_event: Option<XmlEvent>,
element_stack: Vec<String>,
finishe... |
// =========
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use std::process::exit;
const MOD: usize = 1000000007;
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
let mut next = || { iter.next().unwrap() };
input_inner!{nex... |
//! Compile-time reflection of Rust types into GraphQL types.
use std::{rc::Rc, sync::Arc};
use futures::future::BoxFuture;
use crate::{
Arguments as FieldArguments, ExecutionResult, Executor, GraphQLValue, Nullable, ScalarValue,
};
/// Alias for a [GraphQL object][1], [scalar][2] or [interface][3] type's name
... |
use std::ffi::{CString, CStr};
use std::os::raw::{c_char};
pub mod console;
pub mod dom;
pub mod timing;
#[macro_export]
macro_rules! wasmblock_setup {
() => {
#[no_mangle]
pub extern fn alloc(size: usize) -> *mut c_void {
let mut buf = Vec::with_capacity(size);
let ptr = bu... |
use super::*;
#[derive(Debug, PartialEq)]
pub enum Interpolated {
Command(Vec<Node>),
String(Vec<Node>),
Symbol(Vec<Node>),
}
|
use super::*;
#[test]
fn simple_test() {
let query = "dog";
let contents = "\
The quick brown fox
jumped over the lazy dog
and the dog wasn't pleased.";
assert_eq!(search(query, contents),
vec!["1: jumped over the lazy dog",
"2: and the dog wasn't pleased."]
);
} |
use std::collections::HashMap;
fn main() {
let s = "Hi He Lied Because Boron Could Not Oxidize Fluorine. New Nations Might Also Sign Peace Security Clause. Arthur King Can.";
let res = atom(s);
println!("{:?}", res);
}
fn atom(s: &str) -> HashMap<String, usize> {
let mut res = HashMap::new();
s.re... |
// Copyright 2021 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agre... |
use ash::vk;
use ash::prelude::VkResult;
use super::VkInstance;
use super::VkDevice;
use std::ffi::c_void;
use ash::version::EntryV1_0;
use ash::version::DeviceV1_0;
use ash::version::InstanceV1_0;
pub struct VkSkiaContext {
pub context: skia_safe::gpu::Context
}
impl VkSkiaContext {
pub fn new(instance: ... |
use std::fs::File;
fn main() {
let path = "file_open.rs".to_string();
let f = File::open(&path);
println!("{:?}", f);
}
|
fn main() {
let image_width = 256;
let image_height = 256;
let mut r: f64;
let mut g: f64;
let mut b: f64;
let mut ir: i32;
let mut ig: i32;
let mut ib: i32;
println!("P3\n{} {}\n255\n", image_width, image_height);
for j in (0..image_height).rev() {
for i in 0..image_widt... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::VLANTG {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &... |
use crate::cartridge::SnesCartridge;
use crate::memory::Memory;
pub struct Peripherals {
cartridge: SnesCartridge,
wram: Vec<u8>,
// apu, ppu, controllers
}
const WRAM_SIZE: usize = 128 * 1024;
impl Peripherals {
pub fn new(cartridge: SnesCartridge) -> Peripherals {
let wram = vec![0x0; WRAM... |
use crate::slice::Shape2D;
use core::ops::{Bound, RangeBounds};
#[inline(always)]
pub fn calc_2d_index<S: Shape2D>(r: usize, c: usize, slice: &S) -> usize {
r * slice.get_base_col() + c
}
pub fn calc_2d_range<B: RangeBounds<usize>>(len: usize, bound: &B) -> (usize, usize) {
(
match bound.start_bound()... |
use std::fs::File;
use std::io::Read;
use std::vec::Vec;
#[test]
fn test_info() {
let mut file = File::open("tests/data/rust_dxt5.vtf").unwrap();
let mut buf = Vec::new();
file.read_to_end(&mut buf).unwrap();
let vtf = vtf::from_bytes(&mut buf).unwrap();
assert_eq!(512, vtf.header.width);
as... |
use crate::interface::{StakeAccount, YoctoNear};
use near_sdk::json_types::{ValidAccountId, U128};
/// Used to manage user accounts. The main use cases supported by this interface are:
/// 1. Users can register with the contract. Users are required to pay for account storage usage at
/// time of registration. Accou... |
// 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.
// Copied from src/ui/bin/brightness_manager
// TODO(fxb/36843) consolidate usages
use std::path::Path;
use std::{fs, io};
use byteorder::{ByteOrder, Lit... |
#[doc = "Reader of register IER"]
pub type R = crate::R<u32, super::IER>;
#[doc = "Writer for register IER"]
pub type W = crate::W<u32, super::IER>;
#[doc = "Register IER `reset()`'s with value 0"]
impl crate::ResetValue for super::IER {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
use bstr::ByteSlice;
use std::io::{self, Read};
use std::ops::Range;
use memchr::memchr;
use thiserror::Error;
use crate::object::ParseIdError;
use crate::reference::{Direct, ReferenceTarget, Symbolic};
const SYMBOLIC_PREFIX: &[u8] = b"ref: ";
const INVALID_REFERENCE_START: &[u8] = b"\n #";
pub struct Parser<R> {
... |
fn main() {
let s = "u͔n͈̰̎i̙̮͚̦c͚̉o̼̩̰͗d͔̆̓ͥé";
for g in s.graphemes(true) {
println!("{}", g);
}
for c in s.chars() {
println!("{}", c);
}
for b in s.bytes() {
println!("{}", b);
}
}
|
pub mod object;
pub mod reference;
pub mod repository;
pub(crate) mod parse;
|
use crate::prelude::*;
/// Used to fuse the chained systems, such that one doesn't get a compilation
/// error even though the result of the last system isn't used.
///
/// As [SystemStage] requires that the system-chain ends with unit-type `()`
/// we have to use this to fuse the chain.
///
/// Author: @TheRuwuMeatba... |
use crate::level_manager::Level;
#[derive(Clone, Deserialize)]
pub struct LevelManagerSettings {
pub levels: Vec<LevelSettings>,
pub description_text_color: [f32; 4],
pub locked_description_text_color: [f32; 4],
pub default_locked_description: String,
pub default_lo... |
#![allow(unused_imports)]
use std::io::prelude::*;
use std::path::Path;
use proconio::source::auto::AutoSource;
use std::fs;
use std::fs::File;
use std::io::Write;
const NEEDLE: &'static str = "/**===============**/";
mod solve;
use solve::main as solve;
fn read_file(input: &str) -> String {
let path = Path::ne... |
use std::collections::HashMap;
use std::fmt::Debug;
use std::fs::File;
use std::io::{Read, Seek, SeekFrom, Write};
use std::path::{Path, PathBuf};
use crate::signals::collections::Hook;
use crate::vars::mangle;
use anyhow::Result;
use async_trait::async_trait;
use fluent_langneg::{negotiate_languages, NegotiationStra... |
#[doc = "Reader of register RTSR2"]
pub type R = crate::R<u32, super::RTSR2>;
#[doc = "Writer for register RTSR2"]
pub type W = crate::W<u32, super::RTSR2>;
#[doc = "Register RTSR2 `reset()`'s with value 0"]
impl crate::ResetValue for super::RTSR2 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Sel... |
fn main() {
windows::core::build_legacy! {
Windows::Win32::Globalization::{SetThreadPreferredUILanguages, MUI_LANGUAGE_NAME},
};
}
|
#[eosio::action]
fn hi(name: eosio::AccountName) {
eosio_cdt::print!("Hello, ", name, "!");
}
eosio_cdt::abi!(hi);
|
use log::*;
use morgan_interface::account::KeyedAccount;
use morgan_interface::instruction::InstructionError;
use morgan_interface::pubkey::Pubkey;
use morgan_interface::system_instruction::{SystemError, SystemInstruction};
use morgan_interface::system_program;
const FROM_ACCOUNT_INDEX: usize = 0;
const TO_ACCOUNT_IND... |
mod backend;
mod instance;
mod device;
mod surface;
mod command;
mod texture;
mod buffer;
mod pipeline;
mod sync;
mod raw_context;
mod thread;
mod spinlock;
mod rt;
pub use backend::WebGLBackend;
pub use instance::{WebGLInstance, WebGLAdapter};
pub use device::WebGLDevice;
pub use surface::{WebGLSurface, WebGLSwapchai... |
use aoc2018::*;
fn part2(mods: &[i64]) -> Option<i64> {
let mut seen = HashSet::new();
seen.insert(0);
mods.iter()
.cloned()
.cycle()
.scan(0, |a, b| {
*a += b;
Some(*a)
})
.filter(|f| !seen.insert(*f))
.next()
}
fn main() -> Result<... |
use std::slice;
use super::{Si, Ix, Ixs};
use super::zipsl;
/// Calculate offset from `Ix` stride converting sign properly
#[inline]
pub fn stride_offset(n: Ix, stride: Ix) -> isize
{
(n as isize) * ((stride as Ixs) as isize)
}
/// Trait for the shape and index types of arrays.
///
/// `unsafe` because of the as... |
/// Reference: https://github.com/bytecodealliance/wasmtime/blob/master/crates/wast/src/wast.rs
use anyhow::{anyhow, bail, Context as _, Result};
use std::collections::HashMap;
use std::path::Path;
use std::str;
mod spectest;
pub use spectest::instantiate_spectest;
use wasminspect_vm::{simple_invoke_func, FuncAddr, Mod... |
extern crate failure;
mod bedgraph;
//mod errors;
mod runner;
mod snp;
mod stats;
use exitfailure::ExitFailure;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
#[structopt(about = "the stupid content tracker")]
enum Cli {
GC {
#[structopt(parse(from_os_str))]
infile:... |
extern crate rand;
use rand::seq::SliceRandom;
use rand::thread_rng;
use super::cards;
use super::player::Player;
use super::status::{GameRoundResult, State};
pub const DEFAULT_SOFTPOINTS: u8 = 17;
pub struct BlackJack {
state: State,
dealer: Player,
player: Player,
card_deck: Vec<cards::Card>,
... |
/*!
* This crate contains an implementation of an MQTT client.
*/
#![deny(rust_2018_idioms, warnings)]
#![deny(clippy::all, clippy::pedantic)]
#![allow(
clippy::default_trait_access,
clippy::large_enum_variant,
clippy::pub_enum_variant_names,
clippy::similar_names,
clippy::single_match_else,
... |
pub mod data;
pub mod ui;
use druid::{AppLauncher, LocalizedString, WindowDesc};
use data::{AppData, Mod};
use std::io::{Error, ErrorKind, Write};
use std::{env, fs};
const WINDOW_TITLE: &str = "chum_bucket_lab";
#[derive(Clone, Debug)]
struct Config {
check_update: bool,
}
impl Config {
const DEFAULT_CONFI... |
use nardol::bytes::Bytes;
use nardol::bytes::FromBytes;
use nardol::bytes::IntoBytes;
use nardol::prelude::FromRon;
use nardol::prelude::IntoMessage;
use nardol::prelude::ToRon;
use nardol::prelude::Packet;
use nardol::prelude::PacketKind;
use serde::{Serialize, Deserialize};
use ron::ser;
use ron::de;
use nardol::err... |
//! # Snapshot testing toolbox
//!
//! > When you have to treat your tests like pets, instead of [cattle][trycmd]
//!
//! `snapbox` is a snapshot-testing toolbox that is ready to use for verifying output from
//! - Function return values
//! - CLI stdout/stderr
//! - Filesystem changes
//!
//! It is also flexible enoug... |
// Copyright 2022 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
// Copyright 2022 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
use fnv::FnvHashSet;
use rayon::prelude::*;
use std::fmt::Debug;
fn overlap<T: PartialEq + Clone>(a: &Vec<T>, b: &Vec<T>) -> usize {
let mut i = 0;
let index = loop {
if b.starts_with(&a[i..]) {
break i;
} else {
i += 1;
}
};
a.len() - index
}
fn contain... |
extern crate num;
use num::complex::Complex;
use std::io::prelude::*;
use std::fs::File;
use std::io::BufWriter;
fn mandelbrot(c: Complex<f64>, k: f64, lp: i32) -> i32 {
let mut z: Complex<f64> = Complex::new(0.0, 0.0);
for i in 0..lp {
z = z * z + c;
if z.norm_sqr() > k {
return i... |
pub use VkDescriptorPoolResetFlags::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkDescriptorPoolResetFlags {
VK_DESCRIPTOR_POOL_RESET_NULL_BIT = 0,
}
use crate::SetupVkFlags;
#[repr(C)]
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub struct VkDescriptorPoolResetFlagBits(u32);
SetupVkFla... |
fn range_test() {
let mut range = 0..10;
loop {
match range.next() {
Some(x) => {
println!("{}", x);
},
None => { break; }
}
}
}
fn interator_test() {
let nums = vec![1,2,3];
for num in &nums {
println!("{}", num);
}
// same with previous code,
// right here, we use *num explictly indicate n... |
use ocl::{Queue, Buffer, Kernel, Context, Program, builders::DeviceSpecifier, error::Result};
#[derive(PartialEq, Eq)]
/// An operation that can be used to map over data
pub enum Op {
Add,
Min,
Mul,
Div,
Mod,
None
}
/// A safe wrapper type for Program
pub struct MapProgram(Program);
/// A safe wrapper type for ... |
fn main() {
let result = match rand::random() {
false => "Heads",
true => "Tails",
};
println!("{}", result);
}
|
use super::VecMutator;
use crate::mutators::mutations::{Mutation, RevertMutation};
use crate::{Mutator, SubValueProvider};
pub struct Arbitrary;
#[derive(Clone)]
pub struct ArbitraryStep;
pub struct ConcreteArbitrary<T> {
value: Vec<T>,
cplx: f64,
}
pub struct RevertArbitrary<T> {
value: Vec<T>,
}
impl<... |
use chrono_tz::Tz;
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
#[Scalar(
internal,
name = "TimeZone",
specified_by_url = "http://www.iana.org/time-zones"
)]
impl ScalarType for Tz {
fn parse(value: Value) -> InputValueResult<Self> {
match value {
Valu... |
use coruscant_nbt::{from_slice, to_vec, Result};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug)]
struct TestStruct {
#[serde(rename = "byteTest")]
byte_test: i8,
#[serde(rename = "shortTest")]
short_test: i16,
#[serde(rename = "intTest")]
int_test: i32,
#[serde... |
extern crate merkle;
mod channel;
use merkle::prelude::*;
use std::sync::{Arc, RwLock};
use rayon::prelude::*;
use std::time::Instant;
use rand::prelude::*;
use std::sync::atomic::{AtomicI64, Ordering};
use timer;
use chrono::Duration;
use crate::channel::{ContextAction, ContextActionJson};
use std::io::{Cursor, Read... |
use std::mem;
#[allow(dead_code)]
#[derive(Debug, Clone, Copy)]
struct Point {
x: f64,
y: f64,
}
#[allow(dead_code)]
struct Rectangle {
p1: Point,
p2: Point,
}
fn origin() -> Point {
Point { x: 0.0, y: 0.0 }
}
fn boxed_origin() -> Box<Point> {
// allocate on heap
Box::new(Point { x: 0.0,... |
//! Filesystem paths in Windows are a total mess. This crate normalizes paths to the most
//! compatible (but still correct) format, so that you don't have to worry about the mess.
//!
//! In Windows the regular/legacy paths (`C:\foo`) are supported by all programs, but have
//! lots of bizarre restrictions for backwar... |
use std::convert::TryFrom;
use std::time::Duration;
use tokio::process::Child;
use tokio::process::Command;
use sysinfo::{ProcessExt, System, SystemExt};
const CPU_VOLTAGE: f32 = 1.2;
const AMP_MAX: f32 = 0.98;
async fn watch_process(
pid: i32,
mut child: Child,
mut interval: tokio::time::Interval,
) ->... |
use super::*;
use std::fmt;
use std::fmt::Display;
use rand::Rng;
#[derive(Debug, Clone)]
pub struct PlayerMat {
pub tiles: Vec<FarmTile>
}
impl PlayerMat {
pub fn new() -> PlayerMat {
let mut player_mat = Vec::new();
for i in 0..15 {
let mut new_tile = FarmTile::new(i);
... |
// Copyright 2020 The xi-editor Authors.
//
// 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 ag... |
use coordinate_compression::CoordinateCompression;
use input_i_scanner::{scan_with, InputIScanner};
use join::Join;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
let n = scan_with!(_i_i, usize);
let ab = scan_with!(_i_i, (usize, usize); n);
let mut va... |
#[derive(Debug, Clone, Queryable)]
// #[table_name="ground_tiles_with_deleted"]
pub struct GroundTile {
pub id: i64,
pub type_: String,
}
|
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use fuchsia_hyper;
use futures::compat::Future01CompatExt;
use hyper;
use lazy_static::lazy_static;
use rustls::Certificate;
use std::cell::RefCell;
use st... |
use super::VarResult;
use crate::ast::syntax_type::{FunctionType, FunctionTypes, SimpleSyntaxType, SyntaxType};
use crate::helper::err_msgs::*;
use crate::helper::str_replace;
use crate::helper::{
move_element, pine_ref_to_bool, pine_ref_to_color, pine_ref_to_i64, pine_ref_to_string,
};
use crate::runtime::context:... |
extern crate proc_macro;
use proc_macro::TokenStream;
use quote::{quote};
use serde::{Deserialize, Serialize};
use syn::{parse_macro_input, Expr, ExprIf, ItemImpl, ImplItem, Stmt};
#[derive(Debug, Deserialize, Serialize)]
struct EventRule {
event_expression: String,
event_routine: EventRoutine,
}
#[derive(De... |
//! Supported underlying libraries for arbitrary precision arithmetic.
pub mod traits;
pub mod rampimpl;
pub mod frampimpl;
pub mod numimpl;
pub mod gmpimpl;
pub mod primes;
|
pub mod config;
mod ping;
pub use ping::ping;
|
//! A watcher that adds instrumentation.
use super::watcher::{self, Watcher};
use crate::internal_events::kubernetes::instrumenting_watcher as internal_events;
use futures::{future::BoxFuture, stream::BoxStream, FutureExt, StreamExt};
use k8s_openapi::{WatchOptional, WatchResponse};
/// A watcher that wraps another w... |
use druid::{Color, Key};
/// Setting up color env
pub const PRIMARY: Key<Color> = Key::new("druid-components.material.color.primary");
pub const PRIMARY_VARIANT: Key<Color> = Key::new("druid-components.material.color.primary-variant-color");
pub const SECONDARY: Key<Color> = Key::new("druid-components.material.color.s... |
#![feature(backtrace)]
#![feature(proc_macro_hygiene, decl_macro)]
#![feature(try_trait)]
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate shells;
use yansi::Paint;
use chrono::Local;
use std::env;
use std::path::PathBuf;
use ... |
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Start HFXO crystal oscillator"]
pub tasks_hfclkstart: TASKS_HFCLKSTART,
#[doc = "0x04 - Stop HFXO crystal oscillator"]
pub tasks_hfclkstop: TASKS_HFCLKSTOP,
#[doc = "0x08 - Start LFCLK"]
pub tasks_lfclkstart: TASKS... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type FrameNavigationOptions = *mut ::core::ffi::c_void;
pub type LoadCompletedEventHandler = *mut ::core::ffi::c_void;
pub type NavigatedEventHandler = *mut... |
use std::cell::RefCell;
use self_cell::self_cell;
struct Bar<'a>(RefCell<(Option<&'a Bar<'a>>, String)>);
self_cell! {
struct Foo {
owner: (),
#[not_covariant]
dependent: Bar,
}
}
fn main() {
let mut x = Foo::new((), |_| Bar(RefCell::new((None, "Hello".to_owned()))));
x.wit... |
use super::Vessel;
use crate::codec::{Decode, Encode};
use crate::{remote_type, RemoteEnum, RemoteObject};
remote_type!(
/// Used to interact with CommNet for a given vessel. Obtained by calling `Vessel::comms()`.
object SpaceCenter.Comms {
properties: {
{
CanCommunicate {
/// R... |
use regex::Regex;
use std::{collections::HashMap, collections::HashSet, fs};
const FILENAME: &str = "inputs/inputday4";
pub fn solve() {
let input = fs::read_to_string(FILENAME).expect("Failed to read file");
let re = Regex::new(r"([a-z]+:[^\s]+)").unwrap();
let mut total: i32 = 0;
let mut total_par... |
extern crate cg_tracing;
use cg_tracing::prelude::*;
fn main() {
let (w, mut p, path) = utils::from_json("./example/test.json", register! {});
w.render(&mut p);
p.save_png(&path);
}
|
use input_i_scanner::InputIScanner;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.scan::<$t>() as $t
};
(($($t: ty),... |
#[derive(Copy, Clone)]
pub enum TextureDimensionality {
Zero,
One,
Two,
Three,
}
pub struct BTexImageFormat<'a> {
pub name: &'a str,
pub compatible_1d: bool,
pub compatible_2d: bool,
pub compatible_3d: bool,
}
impl<'a> BTexImageFormat<'a> {
pub fn is_dimensionality_compatible(&self, dimensionality: TextureD... |
#![allow(clippy::too_many_arguments)]
#![warn(clippy::cast_lossless, clippy::match_ref_pats)]
#[cfg(feature = "profiler")]
#[macro_use]
extern crate thread_profiler;
#[macro_use]
extern crate log;
use std::path::Path;
use crow::{
glutin::{
dpi::LogicalSize,
event::Event,
event_loop::{Con... |
use projecteuler::digits;
use projecteuler::helper;
fn main() {
helper::check_bench(|| solve(99));
assert_eq!(solve(99), 1587000);
dbg!(solve(99));
}
fn solve(percent: usize) -> usize {
let mut total = 1;
let mut count = 0;
while count * 100 != total * percent {
total += 1;
if ... |
use winapi::shared::{
windef::HBRUSH,
minwindef::{UINT, WPARAM, LPARAM}
};
use winapi::um::{
winuser::{WS_VISIBLE, WS_DISABLED, ES_NUMBER, ES_LEFT, ES_CENTER, ES_RIGHT, WS_TABSTOP, ES_AUTOHSCROLL},
wingdi::DeleteObject,
};
use crate::win32::window_helper as wh;
use crate::win32::base_helper::{check_hwn... |
use proconio::input;
fn main() {
input! {
n: usize,
lr: [(usize, usize); n],
};
const M: usize = 2_000_00;
let mut cum_sum = vec![0_i64; M + 2];
for (l, r) in lr {
cum_sum[l] += 1;
cum_sum[r] -= 1;
}
for i in 1..=(M + 1) {
cum_sum[i] += cum_sum[i - 1... |
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
#[cfg(feature = "runtime-benchmarks")]
mod benchmarks;
mod crypto;
#[cfg(any(feature = "runtime-benchmarks", test))]
mod mock;
mod module_impl;
mod offchain_error;
#[cfg(test)]
mod tests;
mod weights;
use alloc::vec::Vec;
use frame_support::{
debug, ... |
use cell_gc::with_heap;
#[test]
fn add_in_lambda() {
with_heap(|hs| {
let mut env = Nil;
env.push_env(
hs,
Rc::new("+".to_string()),
Builtin(GCLeaf::new(BuiltinFnPtr(add))),
);
let program = lisp!(
((lambda (x y z) (+ x (+ y z))) 3 4 5... |
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
//[base] check-fail
//[nll] check-pass
// known-bug
// This should pass, but we end up with `A::Iter<'ai>: Sized` for some specific
// `'ai`. We also know that `for<'at> A::Iter<'at>: Sized` from the definition,
// but we prefer ... |
pub mod cache;
pub mod entry;
pub mod entry_tag;
pub mod tag;
|
use projecteuler::digits;
use projecteuler::helper;
use projecteuler::square_roots;
fn main() {
helper::check_bench(|| {
solve();
});
assert_eq!(solve(), 1389019170);
dbg!(solve());
}
fn solve() -> usize {
let (mut low, _) = square_roots::sqrt(1020304050607080900);
let (_, high) = squa... |
//! Represents the response to FlightSQL `GetSqlInfo` requests and
//! handles the conversion to/from the format specified in the
//! [Arrow FlightSQL Specification].
//!
//! <
//! info_name: uint32 not null,
//! value: dense_union<
//! string_value: utf8,
//! bool_value: bool,
//! ... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::SMIS {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w... |
use std::collections::HashMap;
use lazy_static::lazy_static;
use proc_macro2::TokenStream;
use syn::{
parse::{Parse, ParseStream},
token, ItemEnum, Path,
};
use crate::utils::*;
pub(crate) fn attribute(args: TokenStream, input: TokenStream) -> TokenStream {
expand(args, input).unwrap_or_else(|e| e.to_com... |
//!
//! Traits for trait bounds
//!
use crate::internal::TraitBounds;
/// Provides methods to add trait bounds to elements.
pub trait TraitBoundExt {
/// Add a single trait bound.
fn add_trait_bound(&mut self, trait_bound: impl ToString) -> &mut Self;
/// Add multiple trait bounds at once.
fn add_tra... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// 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 ... |
use std::fmt;
/// Represents what type of file will be codegen'd
///
/// Currently supports two output types:
///
/// * Textual assembly (i.e. `foo.s`)
/// * Object code (i.e. `foo.o`)
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub enum CodeGenFileType {
Assembly = 0,
Object,
}
/// Represents the speed optimiza... |
//! A [`PartitionProvider`] implementation that hits the [`Catalog`] to resolve
//! the partition id and persist offset.
use std::sync::Arc;
use async_trait::async_trait;
use backoff::{Backoff, BackoffConfig};
use data_types::{NamespaceId, Partition, PartitionKey, TableId};
use iox_catalog::interface::Catalog;
use ob... |
use serde::{de::DeserializeSeed, Deserialize, Deserializer};
use std::{
io::{Read, Seek},
marker::PhantomData,
};
pub fn from_read_seek<'de, Source: Read + Seek, T: Deserialize<'de>>(
data: &'de mut Source,
) -> Result<T, <de::Deserializer<Source> as Deserializer>::Error> {
from_read_seek_seed(data, Ph... |
#![allow(dead_code)]
use crate::{aocbail, utils};
use utils::{AOCResult, AOCError};
pub fn day13() {
let input = utils::get_input("day13");
println!("shuttle_search part 1: {:?}", find_schedule(input).unwrap());
let input = utils::get_input("day13");
println!("shuttle_search part 2: {:?}", chinese_rem... |
use bitflags::bitflags;
use std::{cell::RefCell, collections::VecDeque, rc::Rc};
bitflags! {
/// flags defining what part of the app need to update
pub struct NeedsUpdate: u32 {
/// app::update
const ALL = 0b001;
/// diff may have changed (app::update_diff)
const DIFF = 0b010;
... |
use std::fmt;
use std::collections::HashMap;
use std::collections::hash_map::RandomState;
use async_std::io::{Read};
use crate::{Error, read_head, read_headers, validate_size_constraint};
#[derive(Debug)]
pub struct Response {
status_code: usize,
status_message: String,
version: String,
headers: HashMa... |
pub struct Solution;
impl Solution {
pub fn trap(height: Vec<i32>) -> i32 {
let n = height.len();
if n == 0 {
return 0;
}
let mut a = vec![0; n];
a[0] = height[0];
for i in 1..n {
a[i] = a[i - 1].max(height[i]);
}
let mut b =... |
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
extern crate csv;
use serde::Serialize;
use std::env;
use std::error::Error;
use std::ffi::OsString;
use std::fs::File;
use std::fs::OpenOptions;
use std::io::{BufWriter, Write};
use std::process;
//use serde_json::{json, Value};
use std::collections::BTreeMap;
type Record = BTreeMap<String, String>;
#[derive(Defau... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.