text stringlengths 8 4.13M |
|---|
use clap::{App, SubCommand};
use crate::Tool;
pub fn tool() -> Tool {
Tool::new()
.name("update")
.help("Updates runtime components")
}
|
mod bench;
mod scm_boxed;
mod scm_enum;
use bench::run_benchmark;
trait DType: Sized {
fn int(i: i64) -> Self;
fn flt(f: f64) -> Self;
fn vec(v: Vec<Self>) -> Self;
fn as_int(&self) -> Option<i64>;
fn as_flt(&self) -> Option<f64>;
fn as_vec(&self) -> Option<&Vec<Self>>;
fn is_int(&self) ... |
/*!
Registries allow you to define "well-known" processes in the environment that can be looked up by
name and version.
*/
use std::{
collections::HashMap,
sync::{Arc, RwLock},
};
use anyhow::Result;
use semver::{Version, VersionReq};
use crate::Process;
/// A local (belonging to an Environment) registry of... |
use slotmap::SlotMap;
use crate::Tac;
use crate::{BBId, BasicBlock, InstId};
use super::{ImplicitLinkedList, ImplicitLinkedListItem};
impl ImplicitLinkedListItem for Tac {
type Key = InstId;
fn next(&self) -> Option<Self::Key> {
self.next
}
fn set_next(&mut self, key: Option<Self::Key>) {
... |
// This file is part of Substrate.
// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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
//
// ht... |
pub struct State {}
impl chai::State for State {}
|
use crate::lib::core::Feature;
/// A feature based on static strings.
pub struct StaticFeature {
pub facet: &'static str,
pub point: &'static str,
}
impl Feature for StaticFeature {
fn facet(&self) -> &str { self.facet }
fn point(&self) -> &str { self.point }
}
|
use action;
use rustbox;
#[derive(Debug, PartialEq)]
pub enum Action {
NAction(action::Action),
/// When parsing a sequence that partially matches an action, the
/// `IncompleteSequence` variant says that there is a match but not a
/// complete match.
IncompleteSequence,
/// When parsing a sequence that ... |
//! The type generated by the parser. It can then be evaluated by the
//! evaluator.
/// A Ruse value, which at the moment consists only of lists, strings,
/// integers, and floats.
#[derive(Debug)]
pub enum Expr {
/// An ident
Ident(String),
/// An integer
Integer(i64),
/// A float
Float(f64),... |
use crate::FeeRate;
use std::collections::BTreeMap;
#[derive(Default, Debug, Clone)]
struct BucketStat {
total_fee_rate: FeeRate,
txs_count: f64,
old_unconfirmed_txs: usize,
}
impl BucketStat {
// add a new fee rate to this bucket
fn new_fee_rate_sample(&mut self, fee_rate: FeeRate) {
self... |
use byteorder::{ByteOrder, NetworkEndian};
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
use std::net::UdpSocket;
use std::sync::{Arc, Mutex};
use num_traits::Num;
fn print_usage(program: &str, opts: getopts::Options) {
let brief = format!("Usage: {} [options]", program);
print!("{}", opts.usage(&b... |
use cid::Cid;
use sp_ipld::Ipld;
/// This trait describes the interations with
/// externaly stored IPLD structures.
pub trait Store: std::fmt::Debug {
fn put(&self, expr: Ipld) -> Cid;
fn get(&self, link: Cid) -> Option<Ipld>;
}
|
use pages::*;
use rust_tags::attributes::style;
pub fn content() -> String {
page("Contact", "contact", div(&[
div(&[
"Want to get in touch? I have an ".into(),
a(&[
href("mailto:hello@jasonlongshore.com"),
"email address".into()]),
" that you... |
// Reference: https://dl.acm.org/citation.cfm?doid=3077136.3080789
mod dump;
use std::{
borrow::{Borrow, BorrowMut},
collections::hash_map::RandomState,
hash::{BuildHasher, Hash, Hasher},
marker::PhantomData,
};
use compacts::bit;
type Repr = bit::Words<u64>;
// n: 256, fp: 0.06
const DEFAULT_SIZEO... |
use std::cell::RefCell;
use std::rc::Rc;
use crate::treenode::TreeNode;
pub fn binary_tree_paths(root: Option<Rc<RefCell<TreeNode>>>) -> Vec<String> {
fn vec2str(v: &Vec<i32>) -> String {
let mut s = format!("{}", v[0]);
for i in 1..v.len() {
s += format!("->{}", v[i]).as_str();
... |
use std::fs::{self, read_to_string};
use std::path::Path;
#[derive(Debug)]
pub struct InputCapability {
name: String,
raw_value: String,
}
#[derive(Debug)]
pub struct InputDevice {
name: String,
file_name: String,
capabilities: Vec<InputCapability>,
properties: String,
}
#[derive(Debug)]
pub ... |
pub mod delete_queue;
mod directory_lock;
mod doc_opstamp_mapping;
pub mod index_writer;
mod log_merge_policy;
pub mod merge_policy;
pub mod merger;
pub mod operation;
mod prepared_commit;
mod segment_entry;
mod segment_manager;
mod segment_register;
pub mod segment_serializer;
pub mod segment_updater;
mod segment_writ... |
pub mod graph {
use std::fmt;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Graph {
pub edges: Vec<graph_items::edge::Edge>,
pub nodes: Vec<graph_items::node::Node>,
pub attrs: HashMap<String,String>
}
pub mod graph_items {
pub mod edge {
... |
use std::{
env,
fs::OpenOptions,
io::{prelude::*, SeekFrom},
};
use serde::Serialize;
use serde_json::{ser::PrettyFormatter, Serializer, Value};
fn main() {
let filepath = env::args().nth(1).expect("provide a json file");
let mut file = OpenOptions::new()
.read(true)
.write(true)
... |
// Copyright 2021 The Simlin Authors. All rights reserved.
// Use of this source code is governed by the Apache License,
// Version 2.0, that can be found in the LICENSE file.
use std::fs::File;
use std::io::BufReader;
use std::rc::Rc;
use float_cmp::approx_eq;
use simlin_compat::{load_csv, xmile};
use simlin_engine... |
#[doc = "Register `CNT_ALTERNATE5` reader"]
pub type R = crate::R<CNT_ALTERNATE5_SPEC>;
#[doc = "Register `CNT_ALTERNATE5` writer"]
pub type W = crate::W<CNT_ALTERNATE5_SPEC>;
#[doc = "Field `CNT` reader - Most significant part counter value (TIM2) nullLeast significant part of counter value"]
pub type CNT_R = crate::F... |
pub struct Tenv {
pub t_stat: String, // Thread's Status
pub n_stat: String, // Node's Status
pub n_add: String, // Node's Account Hash
pub n_state: String, // Node's State Hash
pub n_nonce: i64, // Node's State Nonce
}
|
use nom::bytes::complete::tag;
use nom::sequence::tuple;
use nom::IResult;
use std::collections::HashMap;
#[derive(Debug, PartialEq, Eq, Ord, PartialOrd, Copy, Clone)]
struct Timestamp {
year: u32,
month: u32,
day: u32,
hour: u32,
minute: u32,
}
impl Timestamp {
fn parse(i: &str) -> IResult<&s... |
//! Graphics utilities and backend based on Vulkan API for game engine.
pub use self::renderer::*;
pub(crate) mod camera;
mod debug_callback;
mod frame;
mod renderer;
mod shader;
mod utils;
mod vertex;
|
use cursive::{Cursive, views::*, view::*, event};
use super::State;
pub fn new(state: State) -> impl View {
let git_project = state.git_project.borrow();
let left_nav = git_project.projects().iter()
.enumerate()
.fold(SelectView::new(), |sel, (i, project)| sel.item(project.name(), i))
... |
mod note_browser;
pub mod error;
use crossbeam_channel::{Receiver, Sender};
use cursive::{Cursive, CursiveExt, View, event::{Event, EventResult}, views::{Dialog, LinearLayout}};
use self::error::NottoViewError;
pub enum UIMessage {
}
pub trait NottoScreen {
fn load_view(&self) -> Result<Box<dyn View>, NottoVie... |
use observable::*;
use std::cell::RefCell;
use std::cell::Ref;
use std::cell::RefMut;
use std::any::{Any};
use std::rc::Rc;
use std::marker::PhantomData;
use unsub_ref::*;
use std::sync::Arc;
use util::*;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
pub struct Subscriber<V, S, VOut=V>
{
pub ... |
// _ _
// | |_| |__ ___ ___ __ _
// | __| '_ \ / _ \/ __/ _` |
// | |_| | | | __/ (_| (_| |
// \__|_| |_|\___|\___\__,_|
//
// licensed under the MIT license <http://opensource.org/licenses/MIT>
//
// crypt.rs
// defintions of the AES encryption, decryption, and PBKDF2 key derivation
// ... |
//! The x86_64 architecture.
//!
//! This module does all the architecture specific things for x86_64.
pub mod context;
mod gdt;
mod interrupts;
pub mod memory;
pub mod sync;
mod syscalls;
pub mod vga_buffer;
#[macro_use]
mod serial;
pub use self::context::Context;
use self::gdt::{GDT, TSS};
use self::interrupts::iss... |
use std;
use std::path::Path;
use std::io::{
Read,
SeekFrom,
Cursor,
};
use rscam;
use av::io::{
AVRead,
AVSeek,
};
use canvas::renderer::{
Canvas,
CanvasError,
};
use glutin::WindowBuilder;
use gfx_device_gl::{
Resources,
CommandBuffer,
};
// V4lConfiguration Requires a Path an... |
pub fn convert_slice8_to_vec32(v8: &[u8]) -> Vec<u32> {
let mut v32 = Vec::new();
let iter = v8.chunks_exact(4);
let r = iter.remainder();
for e in iter {
let w = [e[0], e[1], e[2], e[3]];
v32.push(u32::from_le_bytes(w));
}
if r.len() != 0 {
let mut w = [0; 4];
fo... |
#[doc = "Register `TIM7_CR2` reader"]
pub type R = crate::R<TIM7_CR2_SPEC>;
#[doc = "Register `TIM7_CR2` writer"]
pub type W = crate::W<TIM7_CR2_SPEC>;
#[doc = "Field `MMS` reader - Master mode selection These bits are used to select the information to be sent in master mode to slave timers for synchronization (TRGO). ... |
pub mod db;
pub mod search;
pub mod tag;
// TODO(sirver): This should only be in cfg(test), but since it is used in the binary which is the
// only thing compiled with cfg test, it needs to be always included.
pub mod testing;
pub use crate::tag::{Tag, Tags};
pub use db::{CommonFileKind, Database};
use serde::{Deseri... |
use kuchiki::traits::TendrilSink;
use element::{Document, parse_document};
pub mod element;
#[derive(Default)]
pub struct DocsClient {
client: reqwest::Client,
}
impl DocsClient {
pub async fn get_document(&self, package_name: &str, path: &str) -> Option<Document> {
let url = self.get_path_url(packag... |
pub mod power {
pub mod pwrctrl {
pub fn get() -> u32 {
unsafe {
core::ptr::read_volatile(0x40018000u32 as *const u32) & 0x3
}
}
pub fn set(val: u32) {
unsafe {
let mut reg = core::ptr::read_volatile(0x40018000u32 as *const... |
use std::net::{TcpStream};
extern crate time;
use request;
use response;
use std::fs::File;
use std::io::prelude::*;
use std::time::Duration;
use mime_guess;
use std::path::Path;
use std::ops::Add;
pub struct Stream {
stream: TcpStream,
directory: String,
}
impl Stream {
pub fn new(stream: TcpStream, dire... |
use crate::crypto::multi_party_schnorr::LocalSig;
use crate::net::{ConnectionManager, SignerID};
use crate::rpc::TapyrusApi;
use crate::signer_node::message_processor::{
broadcast_localsig, generate_local_sig, get_valid_block,
};
use crate::signer_node::node_state::builder::{Builder, Master, Member};
use crate::sig... |
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
impl Command for SubCommand {
fn name(&self) -> &str {
"math abs"
}
fn signature(&sel... |
pub mod island_perimeter;
pub mod jewels_and_stones;
pub mod remove_duplicates_from_sorted_array_ii;
pub mod repeated_string_match;
pub mod partition_labels;
pub mod largest_time_for_given_digits;
pub mod number_complement;
pub mod positions_of_large_groups;
pub mod string_compression;
pub mod buddy_strings;
pub mod is... |
pub mod account;
pub mod title;
|
use std::convert::TryInto;
use proc_macro2::{Ident, TokenStream};
use quote::{quote, ToTokens};
use syn::{Attribute, Result};
use crate::utils::{parse_bool, parse_identifier, parse_identifiers, parse_string};
#[derive(Default)]
pub struct Options {
subcommands: Vec<Ident>,
description: Option<String>,
dy... |
#[doc = "Register `SR` reader"]
pub type R = crate::R<SR_SPEC>;
#[doc = "Field `TS1_ITEF` reader - Interrupt flag for end of measurement on temperature sensor 1, synchronized on PCLK. This bit is set by hardware when a temperature measure is done. It is cleared by software by writing 1 to the TS2_CITEF bit in the DTS_I... |
use std::io::prelude::*;
use std::fs::File;
use std::error::Error;
fn main() {
let mut buffer = String::new();
read_file("input.txt", &mut buffer);
// Loop chars
let mut count: i32 = 0;
let mut position: i32 = 0;
for c in buffer.chars() {
position += 1;
match c {
'... |
use super::*;
pub(crate) fn list_buffers_command(ctx: &Context) -> CommandResult {
let buffers = ctx.state.buffers().buffers(); // nice
let len = buffers.len() - 1;
let mut output = Output::new();
output.fg(Color::White).add("buffers: ");
for (n, buffer) in buffers.iter().enumerate() {
ou... |
extern crate sdl2;
use sdl2::Sdl;
use sdl2::pixels::Color;
use sdl2::render::{Canvas, Texture, TextureCreator};
use sdl2::video::{Window, WindowContext};
pub const SCALE_FACTOR: usize = 2;
type RGBColor = [u8; 3];
pub fn init_window(context: &Sdl) -> Result<(Canvas<Window>, TextureCreator<WindowContext>), String> {... |
extern crate clap;
use clap::App;
fn fibo(n: u64, acc: u64) -> u64 {
match n {
65 => panic!("Integer overflow"),
0 => acc,
_ => fibo(n - 1, acc * n),
}
}
fn main() {
let matches = App::new("Fibonacci")
.version("1.0")
.about("Generate nth Fibonacci number")
... |
use anyhow::{format_err, Error};
use async_trait::async_trait;
use checksums::{hash_file, Algorithm};
use log::info;
use stack_string::{format_sstr, StackString};
use std::{
collections::HashMap,
fs::{create_dir_all, remove_file},
path::Path,
};
use stdout_channel::StdoutChannel;
use url::Url;
use gdrive_l... |
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// 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
//
// Unl... |
use std::os::raw::{c_char, c_void};
use num::Float;
use opendp::err;
use opendp::meas::{make_base_laplace, make_base_laplace_vec};
use opendp::samplers::SampleLaplace;
use opendp::traits::DistanceCast;
use crate::core::{FfiMeasurement, FfiResult};
use crate::util::parse_type_args;
#[no_mangle]
pub extern "C" fn ope... |
mod error;
mod key;
mod term;
use error::Error;
use key::{Key, Keyboard};
use term::Terminal;
fn main() -> Result<(), Error> {
let ts = term::size()?;
println!("rows: {}, cols: {}", ts.rows, ts.cols);
let term = Terminal::new()?;
let mut keyb = Keyboard::new(term);
loop {
match keyb.read... |
use std::hash::{Hash, Hasher};
use crate::error::Error;
use crate::result::Result;
#[derive(Debug, Clone, Eq)]
pub struct StringId {
id: String,
}
impl StringId {
pub fn new<S: Into<String>>(id: S) -> Result<Self> {
let id = id.into();
if id.is_empty() {
return Err(Error::new("id... |
// Copyright (c) 2017 Brandon Thomas <bt@brand.io>
// Painting with Lasers
use arguments::Arguments;
use beam::Scaler;
use error::PaintError;
use lase::Point;
use lase::tools::ETHERDREAM_COLOR_MAX;
use std::sync::Mutex;
use std::sync::RwLock;
use std::time::Duration;
use std::time::Instant;
/// Position of the laser ... |
use structopt::StructOpt;
use crate::Server;
/// Execute the server
#[derive(StructOpt, Debug)]
pub struct Serve {
/// The bind address and port. Defaults to 5645
// TODO IANA port reservation for port 5645 has been submitted.
#[structopt(short = "l", long = "listen-on")]
pub listen_on: Option<u16>,
}... |
use vulkano;
use glfw;
use std::sync::mpsc::Receiver;
use std::sync::Arc;
use std::ffi::CString;
use raylib::rgui::DrawResult::Selected;
use vulkano::VulkanObject;
use glfw::{Context};
use std::ptr::null;
use std::borrow::Borrow;
use vulkano::instance::PhysicalDevice;
use vulkano::swapchain::{SupportedPresentModes, Pre... |
use crate::auth::Auth;
use crate::database::DbConn;
use crate::diesel::prelude::*;
use crate::errors::{Errors, FieldValidator};
use crate::models::password::{NewPassword as InsertPassword, PasswordModel, UpdatePassword};
use crate::responses::{ok, APIResponse};
use crate::schema::passwords;
use rocket::request::Form;
u... |
#[doc = "Register `DDRCTRL_ODTCFG` reader"]
pub type R = crate::R<DDRCTRL_ODTCFG_SPEC>;
#[doc = "Register `DDRCTRL_ODTCFG` writer"]
pub type W = crate::W<DDRCTRL_ODTCFG_SPEC>;
#[doc = "Field `RD_ODT_DELAY` reader - RD_ODT_DELAY"]
pub type RD_ODT_DELAY_R = crate::FieldReader;
#[doc = "Field `RD_ODT_DELAY` writer - RD_OD... |
//! CIECAM 02 appearance model. Many thanks to Jordi Vilar for the debugging.
// TODO
|
use std::collections::{HashMap, HashSet};
use std::fmt::Formatter;
use crate::util::time;
pub fn day17() {
println!("== Day 17 ==");
let input = "src/day17/input.txt";
time(part_a, input, "A");
time(part_b, input, "B");
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
struct GridCoord {
x: us... |
use super::*;
use crossbeam_channel;
pub(super) struct Frontend {
client_id: ClientId,
sender: crossbeam_channel::Sender<Request>,
}
impl Frontend {
pub(super) fn new(client_id: ClientId, sender: crossbeam_channel::Sender<Request>) -> Frontend {
Frontend {
client_id: client_id,
... |
#[doc = "Register `ITLINE9` reader"]
pub type R = crate::R<ITLINE9_SPEC>;
#[doc = "Field `DMA1_CH1` reader - DMA1_CH1"]
pub type DMA1_CH1_R = crate::BitReader;
impl R {
#[doc = "Bit 0 - DMA1_CH1"]
#[inline(always)]
pub fn dma1_ch1(&self) -> DMA1_CH1_R {
DMA1_CH1_R::new((self.bits & 1) != 0)
}
}
... |
pub mod bmp280;
pub mod sgp30;
pub mod htu21d;
pub mod geiger;
pub mod sds011;
pub mod radiothermostat;
pub mod as3935; |
extern crate glutin;
extern crate gleam;
extern crate layers;
extern crate geom;
extern crate x11;
use gleam::gl;
use glutin::{Api, Event, GlRequest};
use layers::rendergl;
use layers::platform::surface::NativeCompositingGraphicsContext;
use layers::scene::Scene;
use geom::rect::{Rect};
use geom::point::{Point2D};
use... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// SloTimeframe : The SLO time window options.
/// The SLO time window options.
#[derive(Clone, Copy, ... |
#[path = "support/macros.rs"]
#[macro_use]
mod macros;
mod support;
use criterion::{criterion_group, criterion_main, Criterion};
use glam::Quat;
use std::ops::Mul;
use support::*;
bench_unop!(
quat_conjugate,
"quat conjugate",
op => conjugate,
from => random_quat
);
bench_binop!(
quat_mul_vec3,
... |
//! The currency service.
pub mod api;
pub mod assets;
pub mod configuration;
pub mod error;
pub mod status;
pub mod transactions;
pub mod wallet;
pub mod offers;
mod nats;
mod service;
pub use currency::service::{Service, SERVICE_ID, SERVICE_NAME};
|
#[macro_use]
mod support;
macro_rules! impl_affine3_tests {
($t:ident, $affine3:ident, $quat:ident, $vec3:ident, $mat3:ident, $mat4:ident) => {
const MATRIX1D: [$t; 12] = [
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0,
];
const MATRIX2D: [[$t; 3]; 4] = [
... |
use crate::errors::Error;
use crate::operation::Operation;
use crate::server::{Server, VersionAdd};
use crate::taskstorage::{TaskMap, TaskStorage, TaskStorageTxn};
use failure::Fallible;
use serde::{Deserialize, Serialize};
use std::collections::HashSet;
use std::str;
use uuid::Uuid;
pub struct DB {
storage: Box<d... |
#[doc = "Reader of register ICSR"]
pub type R = crate::R<u32, super::ICSR>;
#[doc = "Writer for register ICSR"]
pub type W = crate::W<u32, super::ICSR>;
#[doc = "Register ICSR `reset()`'s with value 0"]
impl crate::ResetValue for super::ICSR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
//! This example demonstrates using [`Wrap::keep_words()`] to preserve
//! word shape while truncating a table to the specified size. Without
//! this setting enabled, a word could possibly be split into pieces,
//! greatly reducing the legibility of the display.
use tabled::{
settings::{object::Segment, Alignment... |
// Copyright 2016 taskqueue developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according ... |
//! This crate works on git repositories. Currently there are two goals:
//!
//! * Find the four commits that form a three way merge (Origin, A-side, B-side, Merge commit)
//! * Find the fix for a buggy commit.
#[macro_use]
extern crate lazy_static;
pub mod publish;
mod merge;
pub mod debugging;
pub mod find_bug_f... |
//! Provides the building blocks and materials for the game.
use crate::side::Side;
/// A type that represents the index of a block texture tile
/// in the texture atlas.
type BlockTextureID = u32;
/// All types of voxels in the game.
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Block {
Air,
TestBlo... |
use std::env;
use std::io::prelude::*;
use std::net::TcpStream;
fn connect(host: &str) -> std::io::Result<()> {
let mut stream = TcpStream::connect(host.to_string() + ":80")?;
let request = format!(
"\
GET / HTTP/1.1\r\n\
Host: {0}:{1}\r\n\
Accept: */*\r\n\
Connecti... |
#![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 ErrorResponse {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
#[... |
#![feature(box_syntax)]
#![allow(unstable)]
extern crate regex_dfa;
extern crate dfagen;
extern crate syntax;
use regex_dfa::{Regex, Dfa};
use regex_dfa::dfa::Normalize;
use regex_dfa::derivatives::Differentiable;
fn main() {
while let Ok(line) = std::io::stdio::stdin().read_line() {
match Regex::new(lin... |
struct DidOpenTextDocumentParams {
textDocument: TextDocumentItem,
}
impl Notification for DidOpenTextDocumentParams {
method = "textDocument/didOpen";
}
|
use rustful::{Handler, Context, Response, StatusCode};
use methods::{CaptchaError, captcha_new, captcha_solution};
use rustful::header::ContentType;
use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
pub enum CaptchaMethod {
New,
Solution
}
pub struct RequestHandler {
method: CaptchaMethod
}
impl ... |
use crate::base::Part;
use std::io;
use std::ops::Add;
use std::str::FromStr;
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, ... |
extern crate lmdb;
extern crate tempdir;
use lmdb::{
Environment,
Error,
Transaction,
WriteFlags,
};
use tempdir::TempDir;
fn main() {
let dir = TempDir::new("example").unwrap();
let env = Environment::new().open(dir.path()).unwrap();
let db = env.open_db(None).unwrap();
let mut txn =... |
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn serialize_structure_cancel_rotate_secret_input(
object: &mut smithy_json::serialize::JsonObjectWriter,
input: &crate::input::CancelRotateSecretInput,
) {
if let Some(var_1) = &input.secret_id {
object.key("Secret... |
use specs::*;
use types::*;
use GameMode;
use GameModeWriter;
use OwnedMessage;
use SystemInfo;
use component::channel::*;
use protocol::server::{Login, LoginPlayer};
use protocol::{to_bytes, ServerPacket, Upgrades as ProtocolUpgrades};
pub struct SendLogin {
reader: Option<OnPlayerJoinReader>,
}
#[derive(SystemDa... |
#![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 rustc_serialize as serialize;
use serialize::base64::{self, ToBase64};
use serialize::hex::FromHex;
fn main() {
//set-1 challenge-1
let input = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d";
let result = utf8_to_base64(&string_to_hex(input)... |
enum Broken {
EInteger(i32),
EString(&'static str)
}
fn main() {
let mut hello = "hello";
let broken : Broken = Broken::EString(hello);
match &broken {
&Broken::EInteger(ref a) => (),
&Broken::EString(ref s) => {/*broken = Integer(3); println!("Broken was {}", s)*/}
}
le... |
//! This module defines four traits [`Source`], [`SourcePartition`], [`PartitionParser`], and [`Produce`] to define a source.
//! This module also contains source implementations for various databases.
#[cfg(feature = "src_bigquery")]
pub mod bigquery;
#[cfg(feature = "src_csv")]
pub mod csv;
#[cfg(feature = "src_dum... |
use std::io;
const PATTERN_LENGTH: usize = 80;
const GENERATION_COUNT: usize = 20;
fn main() {
println!("Rule 110");
println!("========");
println!("");
let mut pattern_ok: bool = false;
let mut pattern = String::new();
let mut generation = 1;
while !pattern_ok {
println!("Enter ... |
fn main() {
if let Err(error) = multithreaded_web_server::run() {
println!("Error: \"{}\"", error)
}
}
|
extern crate amethyst;
extern crate rand;
use amethyst::{
LoggerConfig,StdoutLog,
core::{
transform::TransformBundle,
frame_limiter::FrameRateLimitStrategy,
},
prelude::*,
renderer::{DisplayConfig,DrawSprite, Pipeline, RenderBundle, Stage,ColorMask,ALPHA},
input::InputBundle,
... |
mod libpnach_ffi;
use libpnach::*;
extern crate libc;
use libc::c_char;
use libc::size_t;
use std::ffi::CStr;
use std::slice;
#[no_mangle]
pub extern "C" fn sum_of_even(n: *const u32, len: size_t) -> u32 {
let numbers = unsafe {
assert!(!n.is_null());
slice::from_raw_parts(n, len as usize)
... |
pub mod error;
pub mod instruction;
pub mod processor;
pub mod state;
#[cfg(not(feature = "no-entrypoint"))]
pub mod entrypoint;
use solana_program::{
declare_id, entrypoint::ProgramResult, pubkey::Pubkey,
};
declare_id!("My11111111111111111111111111111111111111111");
/// Checks that the supplied authority ID i... |
#[doc = "Reader of register INTR_RX"]
pub type R = crate::R<u32, super::INTR_RX>;
#[doc = "Writer for register INTR_RX"]
pub type W = crate::W<u32, super::INTR_RX>;
#[doc = "Register INTR_RX `reset()`'s with value 0"]
impl crate::ResetValue for super::INTR_RX {
type Type = u32;
#[inline(always)]
fn reset_va... |
//! Repos is a module responsible for interacting with postgres db
#[macro_use]
pub mod acl;
pub mod identities;
pub mod repo_factory;
pub mod reset_token;
pub mod types;
pub mod user_roles;
pub mod users;
pub use self::acl::*;
pub use self::identities::*;
pub use self::repo_factory::*;
pub use self::reset_token::*;
... |
#![allow(
clippy::doc_markdown,
clippy::match_same_arms,
clippy::missing_panics_doc,
clippy::uninlined_format_args
)]
#![cfg_attr(all(test, exhaustive), feature(non_exhaustive_omitted_patterns_lint))]
use proc_macro::TokenStream;
use proc_macro2::{Span, TokenStream as TokenStream2};
use quote::quote;
u... |
use std::vec::Vec;
use std::io::{self, BufRead};
fn optimal_matrix_chain(input_dim: Vec<usize>) {
/*
Dynamic programming implementation to find
the optimal matrix chain product parenthesization.
*/
let nb_matrix: usize = input_dim.len();
if nb_matrix == 0 {
println!("()");
re... |
// 2019-07-12
// Cet exemple ne compile pas, c'est pour bien comprendre comment ça marche.
use std::sync::Mutex;
use std::thread;
fn main() {
// La variable counter contient un i32 dans un Mutex<T>
let counter = Mutex::new(0);
let mut handles = vec![];
// Créons 10 threads avec 10 fois la même closu... |
pub mod compute;
pub mod utils;
pub mod vkcmd;
pub mod vkdescriptor;
pub mod vkfence;
pub mod vkmem;
pub mod vkpipeline;
pub mod vkshader;
pub mod vkstate;
|
use super::*;
#[test]
fn test_external_ip_mapper_validate_ip_string() -> Result<(), Error> {
let ip = validate_ip_string("1.2.3.4")?;
assert!(ip.is_ipv4(), "should be true");
assert_eq!("1.2.3.4", ip.to_string(), "should be true");
let ip = validate_ip_string("2601:4567::5678")?;
assert!(!ip.is_ip... |
mod test_support;
use apllodb_immutable_schema_engine::ApllodbImmutableSchemaEngine;
use apllodb_immutable_schema_engine_infra::test_support::{session_with_tx, test_setup};
use apllodb_shared_components::{
ApllodbResult, NnSqlValue, Schema, SchemaIndex, SqlType, SqlValue,
};
use apllodb_storage_engine_interface::{... |
//! Sparse matrix
use super::matgen::{MatGen, FP, FP_MINPOS, MatView};
use std::collections::BTreeMap;
/// Matrix
pub type SpMat = MatGen<BTreeMap<usize, FP>>;
/// Matrix slice
pub type SpMatSlice<'a> = MatGen<&'a BTreeMap<usize, FP>>;
/// Matrix slice mutable
pub type SpMatSliMu<'a> = MatGen<&'a BTreeMap<usize, FP>... |
use crate::state::State;
use mumble_protocol::control::msgs;
use serde::{Deserialize, Serialize};
use tokio::sync::RwLock;
use std::collections::HashMap;
use std::convert::Into;
use std::rc::{Rc, Weak};
use std::sync::{Arc, Mutex};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Channel {
description: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.