text stringlengths 8 4.13M |
|---|
#[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::STAT {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... |
use ::json_to_final_ast;
use ::spec_type_to_final_ast;
use super::super::size_of::generate_size_of;
fn test_size_of(spec: &str) {
let ir = spec_type_to_final_ast(spec).unwrap();
let size_of = generate_size_of(ir).unwrap();
println!("{:?}", size_of);
}
#[test]
fn simple_scalar() {
test_size_of(r#"
def_... |
#![allow(clippy::vec_box)]
use spdk_sys::spdk_bdev_module;
use crate::bdev::nexus::{nexus_bdev::Nexus, nexus_fn_table::NexusFnTable};
/// Allocate C string and return pointer to it.
/// NOTE: The resulting string must be freed explicitly after use!
macro_rules! c_str {
($lit:expr) => {
std::ffi::CString:... |
use std::io::prelude::*;
use std::io::Result;
use std::fs::File;
use std::env;
fn read_all(path : String) -> Result<String> {
let mut buffer = String::new();
return File::open(path)
.and_then(|mut f| f.read_to_string(&mut buffer))
.map(|_| buffer);
}
fn main() {
for path in env::args().ski... |
mod r#trait;
pub(crate) use r#trait::*;
#[cfg(test)]
pub(crate) mod mock;
|
pub mod atom;
pub mod color;
pub mod comment;
pub mod error;
pub mod func_call;
pub mod input;
pub mod name;
pub mod num;
pub mod op;
pub mod stat_expr;
pub mod stat_expr_types;
pub mod state;
pub mod string;
pub mod syntax_type;
pub mod trans;
pub mod utils;
|
#[doc = "Reader of register SYNC"]
pub type R = crate::R<u32, super::SYNC>;
#[doc = "Writer for register SYNC"]
pub type W = crate::W<u32, super::SYNC>;
#[doc = "Register SYNC `reset()`'s with value 0"]
impl crate::ResetValue for super::SYNC {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
use geometry::Vertex;
pub fn from_fractal_plant(s: String) -> Vec<Vertex> {
// Example 7, wikipedia.
const ANGLE_SIZE: f32 = 0.43; // about 25 degrees in rads.
const STEP_SIZE: f32 = 0.05;
#[derive(Copy, Clone)]
struct State {
pub x: f32,
pub y: f32,
pub theta: f32,
};... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
#[repr(C)]
pub struct BackgroundDownloadProgress {
pub BytesReceived: u64,
pub TotalBytesToReceive: u64,
pub Status: BackgroundTransferStatus,
p... |
fn main() {
println!("Hello, able!");
}
|
use base64;
use failure::Error;
use serde::ser::Serialize;
use serde_derive::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Deserialize, Serialize, PartialEq, Clone)]
#[serde(untagged)]
/// Possible data values
pub enum Data {
/// Represents a string or binary value. As a binary value is base64 e... |
//! Types for handling information about C++ types.
use crate::cpp_data::CppPath;
use ritual_common::errors::{bail, Result};
use serde_derive::{Deserialize, Serialize};
use std::hash::{Hash, Hasher};
#[derive(Debug, PartialEq, Eq, Clone, Hash, Serialize, Deserialize)]
pub enum CppPointerLikeTypeKind {
Pointer,
... |
use crate::APool;
use actix_web::{post, web, HttpResponse};
use serde::Deserialize;
use crate::dump;
use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header};
use crate::error::{
customer_error,
ApiError::{self, *},
};
#[derive(Deserialize)]
pub struct Reg {
pub username: String,
... |
use crate::{
lens::Lens,
math::{Size, Vector2},
Backend, BoxConstraints,
};
use super::{TypedWidget, Widget};
pub struct LensWrap<T, U, L: Lens<T, U>, W: TypedWidget<U, B>, B: Backend> {
lens: L,
widget: W,
_t: std::marker::PhantomData<T>,
_u: std::marker::PhantomData<U>,
_b: std::mark... |
//! TODO docs
#![no_std]
#![deny(
clippy::correctness,
clippy::indexing_slicing,
clippy::option_unwrap_used,
clippy::result_unwrap_used,
clippy::unimplemented,
clippy::wrong_pub_self_convention,
clippy::wrong_self_convention
)]
#![warn(
clippy::complexity,
clippy::pedantic,
clipp... |
// 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 ... |
use opengl_graphics::{Texture, GlGraphics};
use graphics::Context;
use super::renderable::Renderable;
use super::camera::CameraDependentObject;
use super::config;
pub struct Background {
background_texture: Texture,
foreground_texture: Texture,
pub x: f64,
y: f64,
repeat: i8,
width: f64,
pu... |
// todo: encapsule
use tokio::prelude::*;
use tokio::net::TcpListener;
#[allow(unused)]
fn main() {
// Bind the server's socket.
let addr = "127.0.0.1:12345".parse().unwrap();
let listener = TcpListener::bind(&addr)
.expect("unable to bind TCP listener");
// Pull out a stream of sockets for i... |
// Copyright 2017 Dasein Phaos aka. Luxko
//
// 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 distributed
// except a... |
use eval::eval;
use expr::Expr;
use sample::signal::Signal;
#[derive(Clone)]
pub struct ExprSignal {
pub time: i32,
expression: Expr,
}
impl From<Expr> for ExprSignal {
fn from(expr: Expr) -> ExprSignal {
ExprSignal {
time: 0,
expression: expr,
}
}
}
impl Signa... |
use crate::result::{KvsError, Result};
use crate::storage::{BatchStore, Store};
use sled::{Db, Tree};
use std::fmt::Display;
/// Wrapper of `sled::Db`
#[derive(Clone)]
pub struct SledStore(Db);
impl SledStore {
/// Creates a `SledKvsEngine` from `sled::Db`.
pub fn open(db: Db) -> Self {
SledStore(db... |
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let k: usize = rd.get();
let s: Vec<char> = rd.get_chars();
let t: Vec<char> = rd.get_chars();
let s: Vec<usize> = s[..4].iter().map(|&c| c as usize - '0' as usize).collect();
let t: Vec<usize> = t[..4]... |
use crate::ui::screens::{menu::hook::*, notifications::*};
use oxygengine::{prelude::*, user_interface::raui::core::widget::WidgetId};
#[derive(Debug, Default)]
pub struct GameState {
camera: Option<Entity>,
player: Option<Entity>,
menu: Option<WidgetId>,
notifications: Option<WidgetId>,
change: Sc... |
use crate::ray::Ray;
use crate::{
rtweekend::degrees_to_radians,
vec3::{random_in_unit_disk, Point3, Vec3},
};
#[derive(Clone, Copy, Debug)]
pub struct Camera {
origin: Point3,
lower_left_corner: Point3,
horizontal: Vec3,
vertical: Vec3,
u: Vec3,
v: Vec3,
w: Vec3,
lens_radius: f... |
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
use std::collections::HashMap;
fn main() {
run();
}
fn run() {
let start = std::time::Instant::now();
// code goes here
let mut collatz = Collatz::default();
let res = (1..1_000_000)
.enumerate()
.map(|(i, v)| (i, collatz.find(v)))
.max_by_key(|... |
pub fn hamming_distance(s1: &str, s2: &str) -> Result<usize, ()> {
if s1.len() != s2.len() {
return Err(());
}
Ok(s1.chars()
.zip(s2.chars())
.filter(|&(c1, c2)| c1 != c2)
.count())
}
|
use std::fmt::Display;
pub trait Drawable {
fn update(&mut self);
fn pause(&mut self);
fn draw(&mut self);
}
pub trait Window: Drawable + Display {}
impl <T: Drawable + Display> Window for T {}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[doc(hidden)]
pub struct IPdfDocument(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPdfDocument {
type Vtable = IPdfDocument_abi;
... |
//! Provides the input struct.
use shape::coord::Coord;
use shape::polygon::Polygon;
/// The input for deserialization.
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Input {
/// The start of the path.
pub start: Coord,
/// The end of the path.
pub end: Coord,
/// Points that must be... |
use mode_map::ModeMap;
use op::{NormalOp, PendingOp, InsertOp};
use typeahead::{Parse, RemapType, Typeahead};
use client;
use xrl;
pub struct State<K>
where
K: Ord,
K: Copy,
K: Parse,
{
pub typeahead: Typeahead<K>,
pub normal_mode_map: ModeMap<K, NormalOp>,
pub pending_mode_map: ModeMap<K, Pend... |
//! Provides the Polygon struct.
use shape::coord::Coord;
use shape::segment::Segment;
/// Represents a polygon.
#[derive(Serialize, Deserialize, Debug, Eq, PartialEq, Clone, Hash)]
pub struct Polygon {
/// The set a points that make up the polygon, ordered counterclockwise.
#[serde(rename = "point")]
pub... |
use colour::BLACK;
use point::Point;
use image::Rgb;
use complex::Complex;
const MAX_ITERS: u32 = 512;
use image::Luma;
use image::Pixel;
use std::u8;
enum MandelbrotResult {
ProbablyInSet,
NotInSet(u32)
}
fn assess_mandelbrot_membership(c: Complex) -> MandelbrotResult {
let mut z = c;
for iterat... |
use crate::marker_type::NonOwningPhantom;
use std::fmt::{self,Debug};
/// Type-level equivalent of the `Option::None` variant.
#[derive(Debug,Copy,Clone)]
pub struct None_;
pub struct Some_<T>(NonOwningPhantom<T>);
///////////////////////////////////////////////////////////////
impl None_{
pub const NEW:Self... |
// 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 agreed to ... |
use std::ops::Drop;
use std::os::raw::{c_int, c_void};
pub type LamePtr = *mut c_void;
#[link(name = "mp3lame")]
extern "C" {
pub fn lame_init() -> LamePtr;
pub fn lame_close(ptr: LamePtr) -> c_int;
pub fn lame_set_in_samplerate(ptr: LamePtr, in_samplerate: c_int) -> c_int;
pub fn lame_get_in_samplera... |
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashMap};
use std::mem::size_of;
use std::ops::{Index, IndexMut};
use std::{f64, usize};
use crate::env::{Direction, Vec2D, HAZARD_DAMAGE};
use crate::util::OrdPair;
#[derive(Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum CellT {
Free,
Food,
Own... |
//! Binary format for varisat proofs.
use std::io::{self, BufRead, Write};
use anyhow::Error;
use varisat_formula::{Lit, Var};
use crate::vli_enc::{read_u64, write_u64};
use super::{ClauseHash, DeleteClauseProof, ProofStep};
macro_rules! step_codes {
($counter:expr, $name:ident, ) => {
const $name: u64... |
// Copyright 2020-2021, The Tremor Team
//
// 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 agr... |
#![allow(dead_code)]
extern crate paste;
extern crate terminus;
use std::rc::Rc;
use terminus::devices::bus::TerminusBus;
use terminus::devices::clint::*;
use terminus::global::*;
use terminus::memory::{region::*, MemInfo};
use terminus::processor::Processor;
use terminus::processor::ProcessorCfg;
mod bus;
use bus::{C... |
struct User {
username: String,
email: String,
sign_in_count: i64,
active: bool,
}
#[derive(Debug)]
struct Rect {
width: i32,
height: i32,
}
impl Rect {
fn new(width: i32, height: i32) -> Rect {
Rect { width, height }
}
fn area(&self) -> i32 {
self.height * self.wi... |
use crate::client::Client;
use crate::partial::Progress;
use crate::utils::queue::Queue;
use crate::utils::serialize_bytes;
use byteorder::{BigEndian, ReadBytesExt};
use serde::{Deserialize, Serialize};
use serde_bytes::ByteBuf;
use std::collections::VecDeque;
use std::io::Cursor;
use std::sync::Arc;
use std::time::Dur... |
//! Functions and types related to the layout checking.
use std::{cmp::Ordering, fmt, mem};
#[allow(unused_imports)]
use core_extensions::{matches, SelfOps};
use std::{
borrow::Borrow,
cell::Cell,
collections::hash_map::{Entry, HashMap},
};
use crate::{
abi_stability::{
extra_checks::{
... |
use crate::assets::prefab::PrefabManager;
use crate::assets::Handle;
use crate::core::animation::AnimationController;
use crate::core::colors;
use crate::core::random::RandomGenerator;
use crate::core::timer::Timer;
use crate::core::transform::Transform;
use crate::event::GameEvent;
use crate::gameplay::bullet::{spawn_... |
//! Config program
use log::*;
use morgan_interface::account::KeyedAccount;
use morgan_interface::instruction::InstructionError;
use morgan_interface::pubkey::Pubkey;
use morgan_helper::logHelper::*;
pub fn process_instruction(
_program_id: &Pubkey,
keyed_accounts: &mut [KeyedAccount],
data: &[u8],
_t... |
// Copyright 2013 The Servo 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>, at ... |
// 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.
//! Schedule pings when they need to be scheduled, provide an estimation of round trip time
use std::collections::{HashMap, VecDeque};
use std::time::{Dur... |
pub mod errors;
pub use errors::*;
pub mod title;
pub use title::*;
pub mod author;
pub use author::*;
pub mod category;
pub use category::*;
pub mod description;
pub use description::*;
pub mod content_type;
pub use content_type::*;
pub mod question_type;
pub use question_type::*;
|
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// https://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT o... |
use std::os::raw::c_char;
#[macro_export]
macro_rules! cstr {
($s:expr) => {
concat!($s, "\0") as *const str as *const [::std::os::raw::c_char]
as *const ::std::os::raw::c_char
};
}
/// Metamod interface version.
/// Declaration copy of META_INTERFACE_VERSION.
/// Description copied from m... |
use zoon::*;
use crate::{router::Route, theme::Theme};
pub fn root() -> impl Element {
Column::new()
.s(Height::fill().min_screen())
.on_viewport_size_change(super::on_viewport_size_change)
.item(header())
.item_signal(super::page_id().signal().map(page))
}
fn header() -> impl Elem... |
use std::prelude::v1::*;
use super::address::{self, CryptoType};
use super::json_key;
use crate::errors::{Error, ErrorKind, Result};
use crate::hdwallet::{rand as wallet_rand, Language};
use crate::sign::ecdsa::EcdsaKeyPair;
use crate::sign::ecdsa::KeyPair;
use num_integer::Integer;
use num_traits::Num;
use std::ops::... |
mod zmq_helper;
use std::env;
use std::io::Result;
use std::pin::Pin;
use aesm_client::AesmClient;
use enclave_runner::usercalls::{AsyncStream, UsercallExtension};
use enclave_runner::EnclaveBuilder;
use futures::future::{Future, FutureExt};
use log::{error, info};
use sgxs_loaders::isgx::Device as IsgxDevice;
use s... |
use conrod::color::{self, Color};
#[doc = "Configuration for the GUI. Check source for what the defaults are.
**Note**: ALWAYS add `..Default::default()` when creating a Config
since I may add more configuration options and I will consider it a non breaking change."]
pub struct Config {
#[doc = "Background color"... |
use std::{fs, path};
use crate::fs::{LllDirEntry, LllMetadata};
use crate::sort;
use crate::window::LllPageState;
#[derive(Debug)]
pub struct LllDirList {
pub index: Option<usize>,
path: path::PathBuf,
outdated: bool,
pub metadata: LllMetadata,
pub contents: Vec<LllDirEntry>,
pub pagestate: Ll... |
use futures::executor::block_on;
use std::collections::HashMap;
use std::io::Write;
use reqwest::redirect::Policy;
use reqwest::{StatusCode, Response};
use std::process::exit;
use std::time::SystemTime;
use std::thread::Thread;
use reqwest::header::HeaderMap;
const samf_ticket_url: &'static str = "https://billettsalg.... |
#[macro_use]
extern crate hcl_parser;
#[macro_use]
extern crate pretty_assertions;
use hcl_parser::hcl2::ast::*;
use hcl_parser::hcl2::parser::*;
macro_rules! test_productions {
($testname:ident, $func:ident, $cases:expr) => {
#[test]
fn $testname() {
for (text, expected) in $cases {
... |
#[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... |
extern crate serde_json;
use std::fs::File;
use std::io::BufReader;
use super::data_set_sli_manifest::DataSetSLIManifest;
#[derive(Debug, Serialize, Deserialize)]
pub struct Manifest {
#[serde(rename = "dataSetSLIManifest")]
pub manifest: Option<DataSetSLIManifest>
}
impl Manifest {
pub fn from_file(pat... |
// 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.
//! A networking stack.
#![deny(missing_docs)]
#![deny(unreachable_patterns)]
#![recursion_limit = "256"]
// TODO(joshlf): Remove this once the old packet... |
use crate::mechanics::damage::Damage;
use crate::types::MonsterType;
pub struct Attack {
monster_type: MonsterType,
base_damage: Damage,
}
impl Attack {
pub fn new(base_damage: Damage, monster_type: MonsterType) -> Self {
Attack {
base_damage,
monster_type,
}
}
... |
// Reconstruct Original Digits from English
// https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/591/week-4-march-22nd-march-28th/3687/
pub struct Solution;
impl Solution {
pub fn original_digits(s: String) -> String {
let mut counts = [0; (b'z' - b'e') as usize + 1];
for... |
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
use std::f32::consts::PI;
#[derive(PartialEq, Copy, Clone, Debug)]
pub enum WaveType {
Square,
Sawtooth,
Sine,
Noise,
Triangle,
}
pub struct Oscillator {
wave_type: WaveType,
rng: SmallRng,
period: u32,
phase: u32,
noise_b... |
use async_trait::async_trait;
use data_types::{NamespaceName, NamespaceSchema};
use hashbrown::HashMap;
use iox_time::{SystemProvider, TimeProvider};
use mutable_batch::MutableBatch;
use observability_deps::tracing::*;
use std::sync::Arc;
use thiserror::Error;
use trace::ctx::SpanContext;
use super::DmlHandler;
/// E... |
use otspec::types::*;
use otspec::{deserialize_visitor, read_field};
use otspec_macros::tables;
use serde::de::SeqAccess;
use serde::de::Visitor;
use serde::Deserializer;
use serde::{Deserialize, Serialize};
tables!(
maxp05 {
uint16 numGlyphs
}
maxp10 {
uint16 numGlyphs
uint16 maxPoints
uint16 max... |
#[doc = "Reader of register DOUTR"]
pub type R = crate::R<u32, super::DOUTR>;
#[doc = "Reader of field `DOUTR`"]
pub type DOUTR_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - Data output"]
#[inline(always)]
pub fn doutr(&self) -> DOUTR_R {
DOUTR_R::new((self.bits & 0xffff_ffff) as u32)
}
... |
use std::io::{self, Write};
use ast::*;
use ast::{Expr::*, Statement::*};
// Convert a PizzaML function name to an SML one.
pub fn translate_function_call(func_name: &str) -> &str {
match func_name {
"print" => "TextIO.print",
s => s,
}
}
// Convert a PizzaML operator into an SML one.
fn trans... |
// Copyright 2012 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 ... |
use std::io::{self, copy, BufRead, Write};
use std::sync::{Arc, RwLock};
use std::thread;
use chainerror::*;
use serde_json::{from_slice, from_value, to_string};
use varlink::{
Call, Connection, ErrorKind, GetInterfaceDescriptionArgs, Reply, Request, VarlinkStream,
};
use varlink_stdinterfaces::org_varlink_resolv... |
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: [u8; 32]| {
let constified = stark_hash::Felt::from_be_bytes(data);
let orig = stark_hash::Felt::from_be_bytes_orig(data);
assert_eq!(constified, orig);
});
|
use actix_http::Method;
use actix_web::{dev::Service, guard, test, web, web::Data, App};
use async_graphql::*;
use serde_json::json;
use test_utils::*;
mod test_utils;
#[actix_rt::test]
async fn test_playground() {
let srv = test::init_service(
App::new().service(
web::resource("/")
... |
use proconio::input;
fn main() {
input! {
n: usize,
_a: [u32; n],
};
if n % 2 == 0 {
println!("Second");
} else {
println!("First");
}
}
|
use crate::error::{EncryptionErrorType, QuocoError};
use crate::object::{Key, CHUNK_LENGTH, ENCRYPTED_CHUNK_LENGTH};
use crate::Result;
use libsodium_sys::{
crypto_secretstream_xchacha20poly1305_HEADERBYTES,
crypto_secretstream_xchacha20poly1305_TAG_FINAL,
crypto_secretstream_xchacha20poly1305_init_pull, cr... |
use itertools::Itertools;
use std::fs;
use std::str;
pub fn run() {
// F,L -> 0, B,R -> 1
let content: std::string::String = fs::read_to_string("src/day_5/input.txt")
.unwrap()
.chars()
.map(|x| match x {
'F' => '0',
'L' => '0',
'B' => '1',
... |
extern crate clap;
extern crate serde_bencode;
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use serde_bencode::de::from_bytes;
use serde_bencode::value::Value;
#[derive(Eq, PartialEq)]
enum StrValue {
Dict(HashMap<String, StrValue>),
List(Vec<StrValue>),
Str(String),
Int(... |
// 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 agreed to ... |
use krnl::gdt;
use krnl::idt;
use krnl::port::Port;
use krnl::port;
use spin::Mutex;
extern "C" {
fn irq_handler0();
fn irq_handler1();
fn irq_handler2();
fn irq_handler3();
fn irq_handler4();
fn irq_handler5();
fn irq_handler6();
fn irq_handler7();
fn irq_handler8();
fn irq_handler9();
fn irq_ha... |
//! [SPARQL](https://www.w3.org/TR/sparql11-overview/) implementation.
mod algebra;
mod eval;
mod json_results;
mod model;
mod parser;
mod plan;
mod plan_builder;
mod xml_results;
use crate::sparql::algebra::QueryVariants;
use crate::sparql::eval::SimpleEvaluator;
use crate::sparql::parser::read_sparql_query;
use cra... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {
#[cfg(feature = "Win32_Foundation")]
pub fn ChooseColorA(param0: *mut CHOOSECOLORA) -> super::super::super::Foundation::BOOL;
#[cfg(feature = "Win32_... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qurlquery.h
// dst-file: /src/core/qurlquery.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// ... |
#![feature(macro_rules)]
#[deriving(Show, PartialEq)]
enum Fart<T> {
Butt(T),
Turd,
}
macro_rules! test {
($($fart:expr),+) => (
{
$(
println!("{} = {}", stringify!($fart), $fart);
)+
}
)
}
fn main() {
test!(1i + 1, 0i + 10, "a" == "b");
... |
use crate::context::RpcContext;
use crate::v04::types::TransactionWithHash;
use crate::v02::method::get_transaction_by_hash as v02_get_transaction_by_hash;
crate::error::generate_rpc_error_subset!(GetTransactionByHashError: TxnHashNotFoundV04);
pub async fn get_transaction_by_hash(
context: RpcContext,
input... |
use std::{
fs::File,
io::{Read, Write},
path::PathBuf,
};
pub fn read_file(path: PathBuf) {
let mut file = File::open(path).unwrap();
let mut name_len: [u8; 4] = [0; 4];
file.read_exact(&mut name_len).unwrap();
let name_len = u32::from_le_bytes(name_len) as usize;
let mut name: Vec<u8> ... |
fn main() {
let s = "パタトクカシーー";
let res: String = odd_ch(s);
println!("{}", res);
}
fn odd_ch(s: &str) -> String {
s.chars().step_by(2).collect()
}
|
use proconio::{input, marker::Chars};
fn main() {
input! {
h: usize,
w: usize,
s: [Chars; h],
t: [Chars; h],
};
let mut s_cols = Vec::new();
let mut t_cols = Vec::new();
for j in 0..w {
let mut s_col = Vec::new();
let mut t_col = Vec::new();
... |
#![cfg(feature = "integration")]
use grapl_observe::metric_reporter::MetricReporter;
use sqs_executor::cache::Cache;
#[tokio::test]
async fn redis_cache() {
const LRU_SIZE: usize = 5;
const TOTAL_SIZE: usize = 10;
// Create a set of cacheables that we'll store in the cache
let all_cacheables: Vec<Str... |
use super::rocket;
use rocket::http::Status;
use rocket::local::Client;
#[test]
fn test_get_events() {
let client = Client::new(rocket()).unwrap();
// Test default response
let mut response = client.get("/events").dispatch();
let mut expected_body = r#"{"events":{"1":{"id":1,"title":"First Event"},"2"... |
extern crate succinct;
use succinct::bit;
use succinct::bit::*;
extern crate rand;
use rand::Rng;
const CNT: usize = 10;
const CAP: usize = 64 << 20;
// const CAP: usize = 100_000;
#[test]
fn test_bits_poppy() {
let mut rng = rand::thread_rng();
let num = rng.gen::<u64>();
let len = CAP * rng.gen_range(0... |
use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let n: usize = rd.get();
let k: u64 = rd.get();
let ab: Vec<(u64, u64)> = (0..n)
.map(|_| {
let a: u64 = rd.get();
let b: u64 = rd.get();
... |
use std::mem::{align_of, size_of};
use std::str::FromStr;
use debugid::DebugId;
use uuid::Uuid;
#[test]
fn test_is_nil() {
assert!(DebugId::default().is_nil());
}
#[test]
fn test_parse_zero() {
assert_eq!(
DebugId::from_str("dfb8e43a-f242-3d73-a453-aeb6a777ef75").unwrap(),
DebugId::from_parts... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type ISpiControllerProvider = *mut ::core::ffi::c_void;
pub type ISpiDeviceProvider = *mut ::core::ffi::c_void;
pub type ISpiProvider = *mut ::core::ffi::c_... |
//! Provides utility functions to manipulate [chrono](https://github.com/chronotope/chrono/) dates.
//! Only [NaiveDate](https://docs.rs/chrono/0.4.11/chrono/naive/struct.NaiveDate.html) is
//! supported as of now. Support for naive and timezone aware DateTime coming soon.
//!
//! The crate provides the following:
//!
... |
use crate::Vertex;
use wgpu::util::DeviceExt;
#[derive(Debug)]
pub struct Mesh {
pub vertex_buffer: wgpu::Buffer,
pub index_buffer: wgpu::Buffer,
pub material: usize,
pub num_indices: u32,
}
impl Mesh {
pub fn new(device: &wgpu::Device, mesh: &tobj::Mesh, name: &str) -> Self {
let vertices... |
use std::fs;
use color_eyre::eyre::WrapErr;
use color_eyre::Result;
use serde::Deserialize;
use crate::workflow::Workflow;
#[derive(Deserialize, Debug)]
pub(crate) struct Config {
/// The list of defined workflows that are selectable
pub(crate) workflows: Vec<Workflow>,
/// Optional configuration for Jir... |
use super::downcast::downcast_ref;
use super::error::RuntimeErr;
use super::pine_ref::PineRef;
use super::ref_data::RefData;
use crate::runtime::Ctx;
use std::fmt;
use std::hash::{Hash, Hasher};
#[derive(Debug, PartialEq)]
pub enum SecondType {
Simple,
Array,
Series,
}
#[derive(Debug, PartialEq)]
pub enum... |
//! Helper functions
// Limit float resolution down to 3 decimal places
pub(crate) fn format_floats<T: std::fmt::Display>(floats: Vec<T>) -> Vec<String> {
floats.iter()
.map(|float| format!("{:.5}", float.to_string()))
.collect()
}
// Convert coords to iiif parameter string
pub(crate) fn join_coords... |
#[derive(Debug, Eq, PartialEq)]
enum OpCode {
Nop,
}
impl From<&&str> for OpCode {
fn from(s: &&str) -> Self {
match *s {
"nop" => OpCode::Nop,
_ => panic!("uknown string for opcode"),
}
}
}
fn string_to_op_pair(input: &str) -> (OpCode, i64) {
let string_list = ... |
use std::fs;
fn main() {
let content = fs::read_to_string("input.txt").expect("Error reading file");
let values: Vec<u32> = content
.split(',')
.map(|x| x.parse::<u32>().unwrap())
.collect();
match zero_value_of_intcode(&values, 12, 3) {
Ok(v) => println!("{}", v),
... |
pub mod menu;
use hexacore::grid::Coords;
use hexacore::ui::gridview;
use ggez::*;
use ggez::graphics::*;
use ggez::nalgebra::Point2;
pub mod mesh {
use super::*;
use std::borrow::Borrow;
pub fn hexagons<C: Coords, T: Borrow<C>>(
view: &gridview::State<C>,
mesh: &mut MeshBuilder,
... |
extern crate iron;
extern crate mount;
extern crate time;
extern crate rustc_serialize;
use std::io::{Read, Write};
use std::sync::RwLock;
use std::collections::{HashMap, BTreeMap};
use rustc_serialize::json::{self, Json, ToJson};
use time::precise_time_ns;
use iron::status;
use iron::headers::{self, ContentType};
u... |
use Body;
use flush::Flush;
use futures::{Future, Poll};
use h2::client::Connection;
use tokio_connect::Connect;
/// Task that performs background tasks for a client.
///
/// This is not used directly by a user of this library.
pub struct Background<C, S>
where C: Connect,
S: Body,
{
task: Task<C, S>,
}
//... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.