text stringlengths 8 4.13M |
|---|
use super::common;
use serde_json::Value;
use veloci::*;
// #[macro_use]
// mod common;
pub fn get_test_data() -> Value {
json!([
{
"title": "die erbin"
},
{
"title": "erbin"
},
{
"title": "der die erbin"
},
{
... |
use std::fs::File;
use std::io::{BufRead, BufReader};
use itertools::Itertools;
fn get_parameter(commands: &Vec<i32>, ip : usize, mode : i32) -> i32 {
match mode {
0 => return commands[commands[ip] as usize],
1 => return commands[ip],
_ => println!("Invalid mode: {}, ip: {}, command: {}, co... |
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
mod _QuestionMark;
//mod _c;
mod _d_upper;
mod _g;
mod _g_upper;
mod _h_upper;
//mod _k;
mod _m;
mo... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub mod protection_intent {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub ... |
mod robot {
pub fn say_hello() {
println!("Saying hello!!!");
}
pub fn say_hi() {
println!("Saying hi!!!");
}
}
fn main() {
robot::say_hi();
use robot::say_hello;
say_hello();
} |
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... |
use crossbeam_channel as channel;
pub trait MessageReceiver<T> {
fn queue(&self, data: impl Into<T>);
}
pub struct MessageQueue<T> {
queue: channel::Sender<T>,
reader: channel::Receiver<T>,
}
impl<T> Default for MessageQueue<T> {
fn default() -> Self {
let (queue, reader) = channel::unbounded... |
use std::collections::HashMap;
impl Solution {
pub fn min_distance(word1: String, word2: String) -> i32 {
let xs = word1.as_bytes();
let ys = word2.as_bytes();
let mut rc = HashMap::new();
fn min_dis<'a, 'b>(
xs: &'a [u8], ys: &'b [u8],
rc: &mut HashMap<(&'a ... |
use chrono::{Local, Utc, DateTime};
use mustache::{MapBuilder, VecBuilder, Data};
use postgres::rows::Row;
pub trait DBTable {
fn from_row(row: Row) -> Self;
fn drop_query() -> &'static str;
fn init_query() -> &'static str;
fn test_init_query() -> &'static str;
}
pub trait TemplateData {
fn name(... |
use specs::prelude::*;
use specs::storage::BTreeStorage;
use criterion::*;
use criterion::measurement::WallTime;
use super::super::utils::{Cold, Warm, CustomBencher};
use std::time::Instant;
use crate::suits::{A, B, C, D, E, F, G, H, I, J, K};
use rand::prelude::SliceRandom;
use crate::utils::bencher_max_size;
#[deriv... |
extern crate pretty_env_logger;
use chrono::prelude::*;
use hmac::{Hmac, Mac, NewMac};
use log::debug;
use reqwest::StatusCode;
use serde_json::Value;
use sha2::Sha256;
use std::collections::BTreeMap;
use std::error::Error;
type HmacSha256 = Hmac<Sha256>;
pub struct KylinNetworkAPI {
api_key: String,
api_sec... |
use shorthand::ShortHand;
#[derive(ShortHand)]
pub struct Command {
#[shorthand(enable(copy))]
value: String,
}
fn main() {}
|
#[doc = "Register `STR` reader"]
pub type R = crate::R<STR_SPEC>;
#[doc = "Register `STR` writer"]
pub type W = crate::W<STR_SPEC>;
#[doc = "Field `NBLW` reader - Number of valid bits in the last word When the last word of the message bit string is written to HASH_DIN register, the hash processor takes only the valid b... |
pub struct TabBar; // TODO
|
use std::convert::TryFrom;
use crate::generated::pahkat as pahkat_fbs;
use types::DependencyKey;
pub(crate) trait DescriptorExt {
fn name(&self) -> Option<Map<'_, &'_ str, &'_ str>>;
fn description(&self) -> Option<Map<'_, &'_ str, &'_ str>>;
}
pub(crate) trait TargetExt {
fn dependencies(&self) -> Optio... |
// Copyright 2015-2016 Joe Neeman.
//
// 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 accordin... |
mod utils;
use js_sys::{Array, Number, Reflect};
use wasm_bindgen::prelude::*;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
// macro_rules! console_log {
// ... |
use actix_web::http::Method;
use maplit::hashmap;
use maplit::hashset;
use once_cell::sync::Lazy;
use std::collections::HashMap;
use std::collections::HashSet;
pub static SECURITY_MATRIX: Lazy<HashMap<(&str, Method), HashSet<&str>>> = Lazy::new(|| {
hashmap! {
{{~#each paths as | _ path |}}
{{~#with ge... |
#[cfg(feature = "rustls-tls")]
pub mod rustls_tls {
use hyper_rustls::ConfigBuilderExt;
use rustls::{
self,
client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier},
Certificate, ClientConfig, DigitallySignedStruct, PrivateKey,
};
use thiserror::Error;
/// E... |
use core::fmt::Display;
use x86_64::instructions::port::*;
use crate::time;
const UPDATE_IN_PROGRESS_BIT : usize = 1 << 7;
const BCD_MODE : usize = 1 << 1;
const HOUR_24 : usize = 1 << 2;
pub struct Cmos {
index_reg : Port<u8>, // 0x70
data_reg : Port<u8>, // 0x71
}
#[allow(unused)]
pub struct Rtc {
... |
use super::config;
use crate::errors::{Error, ErrorKind, Result};
use crate::protos;
use crate::{session, wallet};
use std::prelude::v1::*;
extern crate sgx_types;
use crate::protos::xchain;
use sgx_types::*;
use std::collections::HashMap;
//use std::path::PathBuf;
use std::slice;
/// account在chain上面给to转账amount,小费是fee... |
use crate::lib::core::{Star, StarSecret};
pub struct StaticStarSecret {}
impl StarSecret for StaticStarSecret {}
impl Star for StaticStarSecret {
fn star_display_code(&self) -> &str { "star-display-code" }
} |
use tcod::input::{self, Event, };
use super::rendering;
use super::data::{ Object, Game, Tcod, };
use crate::{PLAYER, MAP_HEIGHT, MAP_WIDTH};
pub fn target_tile(
max_range: Option<f32>,
objects: &[Object] ,
game: &mut Game,
tcod: &mut Tcod,
) -> Option<(i32, i32)> {
use tcod::input::KeyCode::Escap... |
mod reverse;
mod max_of_2;
mod small_to_high;
fn main() {
// ALGORISM IN reverse.rs
// Take a string and return a new string but with the character reversed
// example: hello rust -> tsur olleh
// TESTS:
// reverseString("hello") // => "olleh"
// reverseString("123i s8") // => "8s i321"
// reverseString("") ... |
//! Generate high level room layout
//!
mod params;
pub use params::*;
use crate::components::{RoomComponent, RoomConnection, RoomConnections};
use crate::geometry::{Axial, Hexagon};
use crate::prelude::hex_round;
use crate::storage::views::UnsafeView;
use crate::tables::morton_table::{ExtendFailure, MortonTable};
use... |
#[cfg(test)]
mod tests {
use crate::xor::encrypt_decrypt_repeating_key_xor;
// Fifth cryptopals challenge - https://cryptopals.com/sets/1/challenges/5
#[test]
fn challenge5() {
let plaintext =
"Burning 'em, if you ain't quick and nimble\nI go crazy when I hear a cymbal";
let... |
//
// Copyright 2021 The Project Oak 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 o... |
use hacspec_lib::*;
use hacspec_ristretto::*;
// === Positive Tests === //
#[test]
fn test_unit_add_zero() {
let point = BASE_POINT();
let zero = IDENTITY_POINT();
let res = add(point, zero);
assert!(equals(point, res));
}
#[test]
fn test_unit_inverse_sub() {
let point = BASE_POINT();
let res... |
extern crate ffmpeg_dev;
extern crate libc;
use ffmpeg_dev::sys;
use ffmpeg_dev::sys::av_register_all;
use ffmpeg_dev::sys::avformat_open_input;
use ffmpeg_dev::sys::AVCodecParameters;
use ffmpeg_dev::sys::AVFormatContext;
use ffmpeg_dev::sys::AVMediaType_AVMEDIA_TYPE_VIDEO;
use ffmpeg_dev::sys::AV_TIME_BASE;
use std:... |
// Natural integers type
use std::ops::*;
use num_bigint::{BigInt};
use num_traits::{Pow, One, identities::Zero};
#[derive(Clone, PartialEq, PartialOrd, Eq, Ord)]
pub struct Int(BigInt);
impl Add for Int {
type Output = Int;
fn add(self, rhs:Int) -> Int {
Int(self.0 + rhs.0)
}
}
impl Sub for I... |
pub mod job;
pub mod util;
pub mod signal;
pub mod queue;
pub mod fs;
use async_process::{Command, Stdio};
use futures_lite::{io::BufReader, prelude::*};
pub async fn cmd() -> std::io::Result<()> {
let mut child = Command::new("ls")
.arg("/home/chrisp/dvsa/dito/")
.stdout(Stdio::piped())
.... |
#![allow(non_snake_case)]
use gl;
use gl::types::*;
use std::ffi::{CStr, CString};
use std::fs::File;
use std::io::Read;
use std::{ptr, str};
use cgmath::prelude::*;
use crate::types::*;
pub struct Shader {
pub ID: u32
}
#[allow(dead_code)]
impl Shader {
pub fn new(vertexPath: &str, fragmentPath: &str) -> Shad... |
#[cfg(test)]
mod test_jump_to {
use diar::{
command::CommandError,
commands::jump::{jump_to, JumpTo},
domain::model::Favorite,
};
use crate::infrastructure::inmemory::repository::Repository;
#[test]
fn with_key() {
let fav = Favorite::new("name1", "/");
let... |
use core::f64;
use std::{fs::File, str::FromStr};
/// Parse the string `s` as a coordinate pair, like `"400x600"` or `"1.0,0.5"`
fn parse_pair<T: FromStr>(s: &str, separator:char) -> Option<(T, T)> {
match s.find(separator) {
None => None,
Some(index) => {
match (T::from_str(&s[..index... |
#[doc = "Register `CFGR1` reader"]
pub type R = crate::R<CFGR1_SPEC>;
#[doc = "Register `CFGR1` writer"]
pub type W = crate::W<CFGR1_SPEC>;
#[doc = "Field `FWDIS` reader - Firewall disable"]
pub type FWDIS_R = crate::BitReader<FWDIS_A>;
#[doc = "Firewall disable\n\nValue on reset: 1"]
#[derive(Clone, Copy, Debug, Parti... |
use crate::Span;
use serde::{Deserialize, Serialize};
use std::fmt::Display;
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub enum Operator {
Equal,
NotEqual,
LessThan,
GreaterThan,
LessThanOrEqual,
GreaterThanOrEqual,
RegexMatch,
NotRegexMatch,
Plus,
Minus,
... |
use std::cmp;
use super::data::{ Transition, Object, Game, MessageLog, PlayerAction };
use crate::PLAYER;
pub fn mut_two<T>(first_index: usize, second_index: usize, items: &mut [T]) -> (&mut T, &mut T) {
assert_ne!(first_index, second_index);
let split_at_index = cmp::max(first_index, second_index);
let(fi... |
use clap::{App, Arg, ArgMatches};
use std::{sync::{mpsc::{Sender, Receiver}}, thread, time};
use my_tcp::{core::manager::{self, TaskMsg, TaskRet}, core::socket::Socket};
fn main() {
println!("Starting a Transport Node!");
// Parse command line arguments
let arg_matches = App::new("My Node Program")
... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use std::collections::HashMap;
use std::fmt;
use std::fmt::Debug;
use std::ops::Index;
use crate::Allocator;
use crate::Value;
/// Blo... |
use crate::libs::color::color_system;
use isaribi::{
style,
styled::{Style, Styled},
};
use nusa::prelude::*;
pub struct Props {
pub variant: Variant,
}
#[derive(Clone)]
pub enum Variant {
Primary,
PrimaryLikeMenu,
Secondary,
SecondaryLikeMenu,
Danger,
Disable,
Dark,
DarkLi... |
use super::*;
#[cfg(test)]
use crate::rusty_hook::rusty_hook_tests::utils::{build_simple_command_runner, GIT_REV_PARSE_CMD};
#[cfg(test)]
mod get_root_directory_path_tests {
use super::*;
#[test]
fn uses_git_rev_parse_top_level_command() {
let exp = "/usr/me/foo";
let target_dir = "";
... |
// 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 air::{proof::Queries, EvaluationFrame};
use crypto::{ElementHasher, Hasher, MerkleTree};
use math::StarkField;
use utils::{batch_iter_... |
mod selection_sort;
mod insertion_sort;
mod bubble_sort;
mod merge_sort;
fn main() {
let v = vec![1, 5, 2, 6, 3, 6, 0];
let mut v1 = v.clone();
let mut v2 = v.clone();
let mut v3 = v.clone();
let mut v4 = v.clone();
println!("Before: \t\t {:?}",v);
selection_sort::sort(&mut v1, |x,y| x < ... |
use std::ascii::AsciiExt;
use std::fmt;
use std::ops::{Add, Index, Range};
/// Represents a single nucleotide and acts as a building block
/// for the `DNA_Sequence` type.
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
pub enum Nucleotide {
A,
C,
G,
T,
}
impl Nucleot... |
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::sync::{mpsc, Arc};
use std::{thread, time};
#[derive(PartialEq, Debug)]
enum OpResult<'a> {
// The result of a line operation: nothing, a sound played, or a jump
Void,
Sound(isize),
Recover(&'a str),
... |
#[doc = "Reader of register CH3_DBG_CTDREQ"]
pub type R = crate::R<u32, super::CH3_DBG_CTDREQ>;
#[doc = "Reader of field `CH3_DBG_CTDREQ`"]
pub type CH3_DBG_CTDREQ_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:5"]
#[inline(always)]
pub fn ch3_dbg_ctdreq(&self) -> CH3_DBG_CTDREQ_R {
CH3_DBG_CTDREQ_R... |
const TRIPLET_SUM: u64 = 1000;
pub fn find() -> Option<u64> {
for a in 1..TRIPLET_SUM {
for b in a..(TRIPLET_SUM-a) {
let c = TRIPLET_SUM - a - b;
if a.pow(2) + b.pow(2) == c.pow(2) {
return Some(a * b * c);
}
}
}
None
}
|
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... |
use super::*;
use rust_htslib::bam;
macro_rules! btreemap {
( $b:expr; $($x:expr => $y:expr),* ) => ({
let mut temp_map = BTreeMap::with_b($b);
$(
temp_map.insert($x, $y);
)*
temp_map
});
( $($x:expr => $y:expr),* ) => ({
let mut temp_map = BTreeMap::new(... |
#![no_std]
#![no_main]
#![feature(abi_x86_interrupt)]
#![feature(custom_test_frameworks)]
#![test_runner(xagima::testing::runner)]
#![reexport_test_harness_main = "test_main"]
#![feature(default_alloc_error_handler)]
use bootloader::BootInfo;
use core::panic::PanicInfo;
#[panic_handler]
fn panic(_: &PanicInfo) -> ! {... |
use std::fs;
use structopt::clap::Shell;
include!("src/cli.rs");
const BIN_NAME: &str = "zellij";
fn main() {
// Generate Shell Completions
let mut clap_app = CliArgs::clap();
println!("cargo:rerun-if-changed=src/cli.rs");
let mut out_dir = std::env::var_os("CARGO_MANIFEST_DIR").unwrap();
out_dir... |
use anyhow::Result;
use std::io::SeekFrom;
/// Base trait for all readers and writers that support seeking to a specific point in their
/// underlying stream. This trait is similar to [std::io::Seek](std::io::Seek) but instead
/// of seeking to a specific byte offset, it allows seeking to a specific point.
pub trait S... |
use crate::println;
use x86_64::instructions::port::Port;
use alloc::vec::Vec;
use alloc::fmt;
use core::fmt::Formatter;
pub struct PCIDevice {
bus: u8,
device: u8,
vendor_id: u16,
device_id: u16,
function: u8,
class_code: u8,
subclass_code: u8,
rev_id: u8
}
impl fmt::Display for PCIDe... |
use instruction::instruction::ExecuteResult;
use rtda::frame::Frame;
use util::code_reader::CodeReader;
#[allow(non_snake_case)]
fn _icmpPop(frame: Frame) -> (i32, i32, Frame) {
let Frame {
operand_stack,
local_vars,
} = frame;
let (val2, operand_stack) = operand_stack.pop_int();
let (... |
use shorthand::ShortHand;
#[derive(ShortHand)]
struct UnitStruct;
fn main() {}
|
use ckb_chain_spec::consensus::{build_genesis_epoch_ext, ConsensusBuilder};
use ckb_dao_utils::genesis_dao_data;
use ckb_types::{
core::{
capacity_bytes, BlockBuilder, BlockView, Capacity, HeaderBuilder, HeaderView,
TransactionBuilder,
},
packed::{Byte32, CellInput, Script},
prelude::*,
... |
// This file is part of rdma-core. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ... |
use std::collections::HashMap;
use std::env;
use std::fmt;
use std::fs::File;
use std::hash::{Hash, Hasher};
use std::io::{BufRead, BufReader, BufWriter, Write};
use std::path::Path;
static DATA_FILE: &str = "data/glyphlist-extended.txt";
fn main() {
let mut map = HashMap::new();
let lines = BufReader::new(F... |
pub mod builder;
pub mod deserializer;
pub mod serializer;
pub mod transaction;
pub use self::deserializer::deserialize;
pub use self::serializer::serialize;
pub use self::transaction::Transaction;
|
extern crate chrono;
extern crate mysql;
use self::chrono::UTC;
use self::chrono::offset::TimeZone;
use self::mysql::conn::MyOpts;
use self::mysql::conn::pool::MyPool;
use self::mysql::error::MyResult;
use self::mysql::value::from_row;
use self::mysql::value::Value;
use std::clone::Clone;
use std::default::Default;
us... |
use directory_client::metrics::MixMetric;
use directory_client::requests::metrics_mixes_post::MetricsMixPoster;
use directory_client::DirectoryClient;
use futures::channel::mpsc;
use futures::lock::Mutex;
use futures::StreamExt;
use log::{debug, error};
use std::collections::HashMap;
use std::sync::Arc;
use std::time::... |
use std::collections::HashMap;
use kite::{Document, Term, TermRef};
use kite::schema::FieldRef;
use byteorder::{BigEndian, WriteBytesExt};
use key_builder::KeyBuilder;
#[derive(Debug)]
pub struct SegmentBuilder {
current_doc: u16,
pub term_dictionary: HashMap<Term, TermRef>,
current_term_ref: u32,
p... |
use std::cmp;
use card::Card;
use types;
use calculator::utility;
pub fn test(cards: Vec<Card>) -> Option<types::Combination> {
if cards.len() < 4 {
return None;
}
let hash_map = utility::get_count_hash_map(&cards[..]);
let mut three_cards: Option<types::Rank> = None;
let mut two_cards: ... |
use crate::heapfile::HeapFile;
use crate::heapfileiter::HeapFileIterator;
use crate::page::Page;
use common::ids::{ContainerId, PageId, Permissions, TransactionId, ValueId};
use common::storage_trait::StorageTrait;
use common::testutil::gen_random_dir;
use common::{CrustyError, PAGE_SIZE};
use std::collections::HashMap... |
/*
* Rustパターン(記法)。
* CreatedAt: 2019-07-07
*/
fn main() {
let numbers = (2, 4, 8, 16, 32);
match numbers {
// (first, ..) => println!("{}", first), // 2
// (.., last) => println!("{}", last), // 32
// (.., second, ..) => println!("{}", second), // error: `..` can only be used once per tu... |
mod vm;
mod worktype;
pub use vm::*;
pub use worktype::*; |
use std::env;
use std::fs;
use std::io;
use std::os::unix::fs::PermissionsExt;
use std::process;
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("{:?}: no mode given", &args[0]);
process::exit(1);
}
let mode: u32 = u32::from_s... |
use async_trait::async_trait;
use uuid::Uuid;
use common::cache::Cache;
use common::error::Error;
use common::infrastructure::cache::InMemCache;
use common::result::Result;
use crate::domain::user::{Email, User, UserId, UserRepository, Username};
use crate::mocks;
pub struct InMemUserRepository {
cache: InMemCac... |
use termion::event::Key;
use termion::input::TermRead;
use std::sync::mpsc;
use std::time::Duration;
use std::{io, thread};
pub enum Event<T> {
Input(T),
Continue,
}
pub struct Config {
exit_key: Key,
}
impl Default for Config {
fn default() -> Config {
Config {
exit_key: Key::Ch... |
#![no_std]
#![crate_type="lib"]
#![feature(const_fn)]
#![feature(const_mut_refs)]
#![feature(clamp)]
#![feature(test)]
#![feature(const_fn_floating_point_arithmetic)]
pub mod util;
pub mod trig;
pub mod vector;
pub mod matrices;
pub mod prng;
pub mod hasher; |
use crate::WorldGenerator;
use feather_core::anvil::level::SuperflatGeneratorOptions;
use feather_core::biomes::Biome;
use feather_core::blocks::BlockId;
use feather_core::chunk::Chunk;
use feather_core::util::ChunkPosition;
pub struct SuperflatWorldGenerator {
pub options: SuperflatGeneratorOptions,
}
impl World... |
pub mod http;
pub mod utils;
pub mod renderer;
fn main() {
println!("Hello, world!");
}
|
use std::collections::VecDeque;
use rust_intcode::intcode;
#[test]
fn test_intcode() {
{ // mem[7] = mem[1] + mem[2]; write(mem[7]);
let mut memory = vec![ 1, 1, 2, 7, 4, 7, 99, 0];
let mut itape = VecDeque::new();
let otape = intcode(&mut memory, &mut itape);
assert_eq!(memory[7... |
/*
* 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
*/
/// SyntheticsPrivateLocationCreationResponse : Object that contains the new private location, the publi... |
use std::io::{BufWriter, stdin, stdout, Write};
#[derive(Default)]
struct Scanner {
buffer: Vec<String>
}
impl Scanner {
fn next<T: std::str::FromStr>(&mut self) -> T {
loop {
if let Some(token) = self.buffer.pop() {
return token.parse().ok().expect("Failed parse");
... |
use std::error::Error;
use std::io;
use std::collections::HashMap;
use std::process::Command;
use std::str::from_utf8;
use serde::Deserialize;
use serde_json::Value;
use super::Authenticator;
#[derive(Debug, Deserialize)]
struct Item {
name: Option<String>,
login: Option<LoginItem>,
#[serde(flatten)]
... |
// This stub file contains items which aren't used yet; feel free to remove this module attribute
// to enable stricter warnings.
#![allow(unused)]
const CARS_PRODUCED_PER_HOUR: u32 = 221;
fn success_rate(speed: u8) -> f64 {
match speed {
0 ..= 4 => 1.00,
5 ..= 8 => 0.90,
9 ..= 10 => 0.77,... |
use crate::field::FieldCsv;
use crate::register::{Register, RegisterCsv};
use crate::utils;
use serde::{Deserialize, Serialize};
use std::path;
use svd_parser::svd::peripheral::{Peripheral as SvdPeripheral, PeripheralBuilder};
use svd_parser::svd::AddressBlock as SvdAddressBlock;
#[derive(Serialize, Deserialize, Clone... |
use super::{parse_redis_value, Value};
pub(crate) const SLOT_SIZE: usize = 16384;
#[derive(Debug, Clone, Copy, PartialEq)]
pub(crate) enum RoutingInfo {
AllNodes,
AllMasters,
Random,
Slot(u16),
}
fn get_arg(values: &[Value], idx: usize) -> Option<&[u8]> {
match values.get(idx) {
Some(Valu... |
use std::path::{Path,PathBuf};
use std::fmt;
use std::thread;
use store::{Store, Values};
use std::sync::{Arc,Mutex, Condvar};
use std::error::Error;
use std::io::{self, Write};
use yak_client::Datum;
use rusqlite;
extern crate r2d2;
extern crate r2d2_sqlite;
type DatabaseConnection = r2d2::PooledConnection<r2d2_sqlit... |
use proconio::input;
fn main() {
input! {
a:i32,
b:i32,
c:i32,
d:i32,
};
let ans = a * d - b * c;
println!("{}", ans);
}
|
use std::io::Read;
fn main() {
let mut stdin = std::io::stdin();
let mut buf = String::new();
stdin.read_to_string(&mut buf).unwrap();
let out = solve(&buf);
println!("{out}");
}
fn solve(input: &str) -> String {
let mut lines = input
.lines()
.map(|l| {
l.split_whitespace()
.map(|x| x.parse::<i64>()... |
use crate::registry::{MetaType, Registry};
use crate::{
do_resolve, CacheControl, Context, ContextSelectionSet, Error, ObjectType, OutputValueType,
Positioned, QueryEnv, QueryError, Result, SchemaEnv, SubscriptionType, Type,
};
use async_graphql_parser::query::Field;
use futures::Stream;
use indexmap::IndexMap;... |
#![allow(proc_macro_derive_resolution_fallback)]
use crate::auth::Auth;
use crate::schema::users;
use chrono::{Duration, Utc};
use serde::Serialize;
use serde_derive::Deserialize;
#[derive(Debug, Queryable, Serialize, Deserialize, Identifiable, PartialEq, AsChangeset)]
#[table_name = "users"]
pub struct User {
pub... |
fn main() {
let mut words = vec![String::from("Hello"),String::from("Yellow"),
String::from("Tree"),String::from("Rust"),String::from("Compiler!")];
println!("{:?}", words);
//Borrowing não ia funcionar pois só se pode emprestar uma vez da estrutura toda
let t = words[1].clone();
words[1] = wo... |
pub fn factors(n: u64) -> Vec<u64> {
let mut results = vec![];
if n <= 1 {
return results;
}
for number in 2..n + 1 {
if is_prime(number) && n % number == 0 {
results.push(number);
let remainder = n / number;
let mut factors: Vec<u64> = factors(remai... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
_reserved_0_cr1: [u8; 0x04],
#[doc = "0x04 - USART control register 2"]
pub cr2: CR2,
#[doc = "0x08 - USART control register 3"]
pub cr3: CR3,
#[doc = "0x0c - USART baud rate register"]
pub brr: BRR,
#[doc = "0x10 - USART g... |
// // match分支和模式匹配
// // 一个枚举和一个以枚举成员作为模式的match表达式
// enum Coin{
// Penny,
// Nickel,
// Dime,
// Quarter,
// }
// fn value_in_cents(coin: Coin) -> u32{
// match coin {
// // 一个分支有两个部分:一个模式和一些代码
// // 第一个分支的模式是Coin::Penny , =>将模式和代码分开 , 这里的代码仅仅是1
// // 每一个分支之间用逗号分隔
// ... |
use super::libs::id_table::{IdColor, IdTable, IdTableBuilder, ObjectId, Surface};
use super::libs::matrix::camera::CameraMatrix;
use super::libs::matrix::model::ModelMatrix;
use super::libs::tex_table::TexTable;
use super::libs::webgl::{program, ProgramType, WebGlF32Vbo, WebGlI16Ibo, WebGlRenderingContext};
use crate::... |
use crate::mmtk::MMTK;
use crate::plan::global::BasePlan;
use crate::plan::global::CommonPlan;
use crate::plan::global::GcStatus;
use crate::plan::global::NoCopy;
use crate::plan::marksweep::gc_work::MSProcessEdges;
use crate::plan::marksweep::mutator::ALLOCATOR_MAPPING;
use crate::plan::AllocationSemantics;
use crate:... |
//! DNS resolver configuration
use std::io;
use std::net::SocketAddr;
use std::time::Duration;
/// Configures the behavior of DNS requests
#[derive(Clone, Debug)]
pub struct DnsConfig {
/// List of name servers; must not be empty
pub name_servers: Vec<SocketAddr>,
/// List of search domains
pub search... |
#![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 error: Option<error_response... |
#[doc = "Register `CR` reader"]
pub type R = crate::R<CR_SPEC>;
#[doc = "Register `CR` writer"]
pub type W = crate::W<CR_SPEC>;
#[doc = "Field `TSCE` reader - Touch sensing controller enable"]
pub type TSCE_R = crate::BitReader;
#[doc = "Field `TSCE` writer - Touch sensing controller enable"]
pub type TSCE_W<'a, REG, c... |
use crypto::blake2s;
use hash::H256;
#[derive(Debug, Default)]
struct TransactionList;
/// The Block struct represents the compact data representing one unit of the chain.
struct Block {
block_header: BlockHeader,
transactions: TransactionList,
// TODO omners (?)
}
/// The BlockHeader contains all of the... |
/*
* 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
*/
/// SyntheticsSslCertificateSubject : Object describing the SSL certificate used for the test.
#[deri... |
use std::io::{self, BufRead};
fn is_sum_of_two_numbers_in_previous_n(nums: &Vec<u64>, start : usize, end : usize) -> bool {
for i in start..end {
for j in i+1..end {
if nums[i] + nums[j] == nums[end] {
return true;
}
}
}
return false;
}
fn find_not_s... |
//! Relay implementation for consensus blocks.
use crate::protocol::compact_block::{CompactBlockClient, CompactBlockServer};
use crate::utils::{NetworkPeerHandle, NetworkWrapper, RequestResponseErr};
use crate::{
DownloadResult, ProtocolBackend, ProtocolClient, ProtocolServer, RelayError, LOG_TARGET,
};
use async_... |
use crate::libs::color::color_system;
use isaribi::{
style,
styled::{Style, Styled},
};
use kagura::prelude::*;
use nusa::prelude::*;
pub struct Props {}
pub enum Msg {}
pub enum On {}
pub struct Header {}
impl Component for Header {
type Props = Props;
type Msg = Msg;
type Event = On;
}
impl ... |
use std::ops::{ Add, Sub };
use std::ops::Not;
use std::cmp::PartialEq;
use std::convert::From;
#[derive(Debug)]
struct ComplexNumber {
re: i32,
im: i32
}
impl Sub<Self> for ComplexNumber {
type Output = Self;
fn sub(self, rhs: Self) -> Self {
Self {
re: self.re - rhs.re,
... |
use std::env;
use friday_error;
use friday_error::frierr;
use friday_error::FridayError;
pub fn get_environment<S: AsRef<str>>(name: S) -> Result<String, FridayError> {
return env::var(name.as_ref()).or_else(
|err| frierr!("Unable to get environment variable {} - Reason {}\
\n\nThings to try\n1. Tr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.