text stringlengths 8 4.13M |
|---|
use amethyst::{
assets::Handle,
core::{nalgebra::Vector3, Transform},
input::{is_close_requested, is_key_down},
prelude::*,
renderer::{Camera, DisplayConfig, Projection, VirtualKeyCode},
ui::{Anchor, FontAsset, UiText, UiTransform},
};
use crate::component::{Ball, Block, Cube, Direction, Paddle... |
//! Responses for Network service Commands
use super::types::*;
use atat::atat_derive::AtatResp;
use heapless::{consts, String};
/// 7.3 Signal quality +CSQ
#[derive(Clone, AtatResp, defmt::Format)]
pub struct SignalQuality {
#[at_arg(position = 0)]
pub signal_power: u8,
#[at_arg(position = 1)]
pub qua... |
use siro::html::{
attr::{placeholder, value},
button, div,
event::{on_click, on_input},
input,
};
use siro::prelude::*;
use futures::prelude::*;
use futures::{select, stream::FuturesUnordered};
use serde::Deserialize;
use wasm_bindgen::prelude::*;
use wee_alloc::WeeAlloc;
#[global_allocator]
static AL... |
use std::fs::{self, File};
use std::time::{Instant, Duration};
use serde_json::value::Value as JValue;
use serde_json;
use csv::Writer as CSVWriter;
use csv::Result as CSVResult;
use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
#[derive(Serialize, Deserialize)]
struct Field {
path : String,
type... |
pub trait HasArea {
fn name(&self) -> String;
fn area(&self) -> f64;
}
pub struct Circle {
pub x: f64,
pub y: f64,
pub radius: f64,
pub name: String
}
impl HasArea for Circle {
fn name(&self) -> String {
self.name.clone()
}
fn area(&self) -> f64 {
std::f64::consts::... |
use super::pool::*;
use super::config::*;
pub struct Client{
pub pool: Pool,
}
impl Client {
pub fn new<C: ToPqConfig>(conf: C, pool_size: usize) -> Result<Client, ConfParseError> {
Ok(Client{
pool: Pool::new(conf, pool_size)?,
})
}
pub async fn get_conn(&self) -> Result<P... |
//https://ptrace.fefe.de/wp/wpopt.rs
// gcc -o lines lines.c
// tar xzf llvm-8.0.0.src.tar.xz
// find llvm-8.0.0.src -type f | xargs cat | tr -sc 'a-zA-Z0-9_' '\n' | perl -ne 'print unless length($_) > 1000;' | ./lines > words.txt
//#![feature(impl_trait_in_bindings)]
use std::fmt::Write;
use std::io;
use std::iter::... |
pub trait GraphTraversal {
fn bwd_edges(&self, v: usize) -> &Vec<usize>;
fn fwd_edges(&self, v: usize) -> &Vec<usize>;
fn all_bwd_edges(&self) -> &Vec<Vec<usize>>;
fn all_fwd_edges(&self) -> &Vec<Vec<usize>>;
fn sources(&self) -> Vec<usize>;
}
pub struct Graph {
e_fwd: Vec<Vec<usize>>,
e_bw... |
pub mod binding;
mod environment;
pub mod global_user;
pub mod metadata;
pub mod target;
pub use environment::{Environment, QueryEnvironment};
|
use crate::headers::from_headers::*;
use crate::prelude::*;
use crate::resources::collection::{IndexingPolicy, PartitionKey};
use azure_core::headers::{etag_from_headers, session_token_from_headers};
use azure_core::{collect_pinned_stream, Request as HttpRequest, Response as HttpResponse};
use chrono::{DateTime, Utc};
... |
use std::future::Future;
use std::io::Error as IOError;
use std::marker::Unpin;
use std::pin::Pin;
use std::result::Result as StdResult;
use std::sync::Arc;
use async_trait::async_trait;
use futures::channel::{mpsc, oneshot};
use futures::{Sink, Stream};
use tokio::sync::Notify;
use crate::payload::SetupPayload;
use ... |
/// Namespace for operations that cannot be added to any other modules.
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct Miscellaneous {}
impl Miscellaneous {
#[inline]
pub fn admin_unadopted_list() -> MiscellaneousGetBuilder {
MiscellaneousGetBuilder {
param_page: None,... |
use crate::prelude::*;
use azure_core::prelude::*;
use http::StatusCode;
use std::convert::TryInto;
#[derive(Debug, Clone)]
pub struct GetAttachmentBuilder<'a, 'b> {
attachment_client: &'a AttachmentClient,
if_match_condition: Option<IfMatchCondition<'b>>,
user_agent: Option<azure_core::UserAgent<'b>>,
... |
#[doc = "Register `EMR2` reader"]
pub type R = crate::R<EMR2_SPEC>;
#[doc = "Register `EMR2` writer"]
pub type W = crate::W<EMR2_SPEC>;
#[doc = "Field `EM32` reader - CPU wakeup with interrupt mask on event input"]
pub type EM32_R = crate::BitReader;
#[doc = "Field `EM32` writer - CPU wakeup with interrupt mask on even... |
use crate::{
ec_cycle_pcd::data_structures::{ECCyclePCDPK, ECCyclePCDVK, HelpCircuit, MainCircuit},
variable_length_crh::{constraints::VariableLengthCRHGadget, VariableLengthCRH},
CircuitSpecificSetupPCD, Error, PCDPredicate, UniversalSetupPCD, PCD,
};
use ark_crypto_primitives::snark::{
constraints::{S... |
use serde::Deserialize;
#[derive(Deserialize, Clone)]
#[serde(default)]
pub struct BlockProperties {
pub name: String,
pub solid: bool,
pub opaque: bool,
pub flora: bool,
pub texture: BlockTextureProperties,
}
impl Default for BlockProperties {
fn default() -> Self {
Self {
... |
pub mod agenda;
pub mod partition;
pub mod push_down;
pub mod integerisable;
pub mod parsing;
pub mod reverse;
pub mod search;
pub mod tree;
pub mod factorizable;
use fnv::{FnvHashMap, FnvHashSet};
/// A `HashMap` with `usize` `Key`s.
/// It uses the `Fnv` hasher to provide fast access and insert
/// functionality wi... |
use std::convert::Infallible;
#[cfg(unix)]
use std::path::Path;
use std::sync::Arc;
use std::thread;
use std::time::{Duration, SystemTime};
use tokio::sync::Mutex;
use tokio::time::delay_for;
use clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, SubCommand};
use eyre::Result;
use hyper::service::{make_service_fn, ... |
// Stringy Strings
fn main() {
println!("{}", stringy(6) == "101010");
println!("{}", stringy(9) == "101010101");
println!("{}", stringy(4) == "1010");
println!("{}", stringy(7) == "1010101");
}
fn stringy(l: i32) -> String {
let mut result = "".to_string();
for n in 0..l {
if n % 2 ==... |
extern crate libc;
use std::ffi::CString;
use std::fs::File;
use std::io::{Error, ErrorKind, Result};
use std::mem;
use std::os::unix::ffi::OsStrExt;
use std::os::unix::fs::MetadataExt;
use std::os::unix::io::{AsRawFd, FromRawFd};
use std::path::Path;
use FsStats;
pub fn duplicate(file: &File) -> Result<File> {
... |
use std::convert::TryFrom;
use nia_protocol_rust::GetDefinedModifiersRequest;
use crate::error::NiaServerError;
use crate::error::NiaServerResult;
use crate::protocol::Serializable;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NiaGetDefinedModifiersRequest {}
impl NiaGetDefinedModifiersRequest {
pub fn ne... |
/// Generate artifact information from unit dependencies for configuring the compiler environment.
use crate::core::compiler::unit_graph::UnitDep;
use crate::core::compiler::{Context, CrateType, FileFlavor, Unit};
use crate::core::TargetKind;
use crate::CargoResult;
use std::collections::HashMap;
use std::ffi::OsString... |
extern crate hyper;
extern crate futures;
use hyper::header::ContentLength;
pub fn not_allowed_error(text: &str) -> hyper::Response{
hyper::Response::new()
.with_status(hyper::StatusCode::MethodNotAllowed)
.with_header(ContentLength(text.len() as u64))
.with_body(String::from(text))
}
pub... |
use super::SnapshotBuilder;
use super::{FileMetadata, Snapshot};
use crate::hash::Hash;
use blake2::{self, Digest};
use std::path;
use std::string::String;
// TODO: SnapshotBuilder should return self
impl SnapshotBuilder {
pub fn new() -> SnapshotBuilder {
SnapshotBuilder {
message: None,
... |
// This file is part of Substrate.
// Copyright (C) 2017-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... |
fn main() {
// This is a vector similiar to a C++ vector.
// The vector information is on the stack,
// but the elements are stored on the heap.
let v = vec![1, 2, 3];
// Copy the stack-part of the vector to a mutable
// variable, but clone *NOT* the values (heap).
// This is also called "m... |
use super::prelude::*;
#[derive(Debug, Clone, PartialEq)]
pub struct Hash {
pub pairs: Vec<Pair>,
}
impl Display for Hash {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
let out = self
.pairs
.iter()
.map(|pair| format!("{}:{}", pair.key, pair.value))
... |
mod set1;
mod set2;
mod utils;
fn main() {}
|
fn main() {
// 行コメント
let x = 5; // this is also a line comment.
println!("add_one(5) is {}",add_one(x));
}
/// 与えられた数値に1を加える
///
/// # Examples
///
/// ```
/// let five = 5;
///
/// assert_eq!(6, add_one(5));
/// # fn add_one(x: i32) -> i32 {
/// # x + 1
/// # }
/// ```
fn add_one(x: i32) -> i32 {
... |
use std::str;
use std::fs::File;
use std::io::prelude::*;
fn encrypt_repeating(buf: &[u8], keys: &[u8]) -> Vec<u8> {
let mut out = vec![0; buf.len()];
let keys_len = keys.len();
for x in 0..buf.len() {
let keys_pos = x % keys_len;
let key = keys[keys_pos];
out[x] = buf[x] ^ key;
... |
use rdisk::vhd::VhdImage;
use std::path::PathBuf;
pub fn get_testdata_path() -> Option<PathBuf> {
std::env::var("CARGO_MANIFEST_DIR").ok().and_then(|dir| {
let dir = PathBuf::from(dir).join("testdata");
if dir.exists() {
Some(dir)
} else {
None
}
})
}
pu... |
//! Sx127x FSK mode definitions
//!
//! Copyright 2019 Ryan Kurte
pub use super::common::*;
/// FSK and OOK mode configuration
#[derive(Clone, PartialEq, Debug)]
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct FskConfig {
/// ... |
extern crate llvm_sys;
use std::borrow::Cow;
use std::collections::HashMap;
use std::ffi::{CStr, CString};
use std::str::Chars;
use std::io::{self, Read, Write};
use std::iter::Peekable;
use llvm_sys::prelude::*;
fn cstr(s: &str) -> Box<CStr> {
CString::new(s).unwrap().into_boxed_c_str()
}
type ParseResult<T> =... |
pub mod healthcare_parameters;
pub use healthcare_parameters::HealthcareParameters;
|
// traits.rs ---
//
// Filename: traits.rs
// Author: Jules <archjules>
// Created: Thu Mar 30 22:53:26 2017 (+0200)
// Last-Updated: Fri Mar 31 15:43:13 2017 (+0200)
// By: Jules <archjules>
//
pub trait ReadMemory {
fn read_byte(&self, address: usize) -> u8;
fn read_word(&self, address: usize) -... |
use crate::headers::*;
use crate::AddAsHeader;
use http::request::Builder;
use std::str::FromStr;
use uuid::Uuid;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LeaseId(Uuid);
impl std::fmt::Display for LeaseId {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
self.0... |
/*
chapter 4
primitive types
arrays
*/
fn main() {
let a = [1, 2, 3]; // a: [i32; 3]
println!("{:?}", a);
let mut b = [1, 3, 2]; // b: [i32; 3]
println!("{:?}", b);
b = [3, 2, 1];
println!("{:?}", b);
}
// output should be:
/*
[1, 2, 3]
[1, 3, 2]
[3, 2, 1]
*/
|
pub use self::r_layout::RLayout;
pub use self::constraints_layout::RConstraintsLayout;
mod r_layout;
mod constraints_layout;
pub fn hbox() {
}
pub fn align() {
} |
//! Commonly used Base58 alphabets.
/// Bitcoin's alphabet as defined in their Base58Check encoding.
///
/// See https://en.bitcoin.it/wiki/Base58Check_encoding#Base58_symbol_chart.
pub const BITCOIN: &[u8; 58] = b"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
/// Monero's alphabet as defined in this f... |
pub struct FindIndices<'a> {
haystack: &'a str,
needle: String,
offset: usize,
}
impl<'a> FindIndices<'a> {
pub fn new(haystack: &'a str, needle: &str) -> Self {
FindIndices {
haystack,
needle: String::from(needle),
offset: 0,
}
}
}
impl<'a> Iter... |
pub fn f1(a: u8, b: u8) -> u8 {
(a + b) / 2 * 4
}
|
use stq_router::RouteParser;
use stq_types::*;
/// List of all routes with params for the app
#[derive(Clone, Debug, PartialEq)]
pub enum Route {
Roles,
RoleById {
id: RoleId,
},
RolesByUserId {
user_id: UserId,
},
Countries,
CountriesFlatten,
CountryByAlpha2 {
a... |
use twang::{gen::White, mono::Mono64, Audio};
mod wav;
fn main() {
let mut out = Audio::<Mono64>::with_silence(48_000, 48_000 * 5);
let mut pink = White::new();
out.generate(&mut pink);
wav::write(out, "white.wav").expect("Failed to write WAV file");
}
|
use crate::*;
pub fn init_math(globals: &mut Globals) -> Value {
let id = globals.get_ident_id("Math");
let class = ClassRef::from(id, globals.builtins.object);
let obj = Value::class(globals, class);
globals.add_builtin_class_method(obj, "sqrt", sqrt);
globals.add_builtin_class_method(obj, "cos", ... |
#![cfg_attr(not(test), no_std)]
extern crate embedded_graphics;
use embedded_graphics::{
geometry::Size,
image::ImageRaw,
mono_font::{DecorationDimensions, MonoFont},
};
mod char_offset;
use char_offset::{char_offset_impl, CHARS_PER_ROW};
/// The 8x8 regular
///
/// [![8x8 regular font spritemap screens... |
use std::collections::HashSet;
use std::borrow::BorrowMut;
use std::rc::Rc;
use std::cell::RefCell;
use core::iter::FromIterator;
use rand::prelude::{Rng, RngCore};
use rand::IsaacRng;
use xcg::utils::Trim;
use xcg::model::Point;
use xcg::model::*;
use xcg::bot::TestBot;
#[test]
fn test_border() {
// test on the ... |
// SPDX-FileCopyrightText: 2020-2021 HH Partners
//
// SPDX-License-Identifier: MIT
use serde::{Deserialize, Serialize};
/// https://spdx.github.io/spdx-spec/3-package-information/#39-package-verification-code
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct PackageVerificationCode {
/// Value of th... |
extern crate adder;
fn main() {
let a = 10;
let b = 15;
let sum = adder::add(a, b);
println!("{} + {} = {}", a, b, sum);
}
|
//!
//! [`RawDevice`](RawDevice) and [`RawSurface`](RawSurface)
//! implementations using the legacy mode-setting infrastructure.
//!
//! Usually this implementation will be wrapped into a [`GbmDevice`](::backend::drm::gbm::GbmDevice).
//! Take a look at `anvil`s source code for an example of this.
//!
//! For an examp... |
mod apis;
mod backtest;
mod clock;
mod config;
mod simulation;
mod strategies;
mod studies;
mod trading;
use std::env;
fn main() {
let args: Vec<String> = env::args().map(|a| a.to_uppercase()).collect();
if args.len() < 2 {
eprintln!("Must provide at least one symbol to use");
return;
}
... |
#[doc = "Register `CIDR2` reader"]
pub type R = crate::R<CIDR2_SPEC>;
#[doc = "Field `PREAMBLE` reader - component identification bits \\[23:16\\]"]
pub type PREAMBLE_R = crate::FieldReader;
impl R {
#[doc = "Bits 0:7 - component identification bits \\[23:16\\]"]
#[inline(always)]
pub fn preamble(&self) -> ... |
pub fn number_to_words(mut num: i32) -> String {
fn helper(num: usize) -> String {
let ones = ["", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"];
let tens = ["", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"];
let special = ["Ten",... |
pub fn slugify(s: &String) -> String {
let filtered = s
.chars()
.filter(|c| c.is_alphanumeric() || c.is_whitespace())
.collect::<String>();
let mut slug = slug::slugify(filtered)
.chars()
.filter(|c| c.is_ascii_alphanumeric() || *c == '-')
.collect::<String>();
slug.truncate(50);
slug
}... |
/*
Copyright 2018 Intel Corporation
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 in writing, ... |
use std::io::Write;
fn add(a: i32, b: i32) -> i32 {
a + b
}
fn abs(number: i32) -> i32 {
if number < 0 {
return -number;
}
number
}
struct Person {
name: String,
age: u32,
}
impl Person {
fn new(name: &str, age: u32) -> Person {
Person {
name: String::from(name... |
//! CORS support for Tsukuyomi.
#![doc(html_root_url = "https://docs.rs/tsukuyomi-cors/0.3.0-dev")]
#![deny(
missing_docs,
missing_debug_implementations,
nonstandard_style,
rust_2018_idioms,
rust_2018_compatibility,
unused
)]
#![forbid(clippy::unimplemented)]
use {
failure::Fail,
http:... |
use simple_db::blockid::BlockId;
#[test]
fn test_display() {
let filename = String::from("test");
let blknum = 10;
let bi = BlockId::new(&filename, blknum);
assert_eq!(filename, bi.filename());
assert_eq!(blknum, bi.number());
assert_eq!(
format!("[file {}, block {}]", filename, blknu... |
use super::{Pages, Pagination};
use crate::{custom_client::OsekaiRarityEntry, embeds::MedalRarityEmbed, BotResult};
use twilight_model::channel::Message;
pub struct MedalRarityPagination {
msg: Message,
pages: Pages,
ranking: Vec<OsekaiRarityEntry>,
}
impl MedalRarityPagination {
pub fn new(msg: Mess... |
use inflector::cases::camelcase::is_camel_case;
pub fn abbreviate(phrase: &str) -> String {
// Filter out any special character requirements like - to be treated as space to consider abbrevation.
let phrase_filtered = phrase.replace("-", " ");
// Split word by space.
let word_iter = phrase_filtered.sp... |
use std::collections::BTreeMap;
pub fn transform(h: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> {
h.iter().fold(BTreeMap::new(), |mut acc, (score, letters)| {
for c in letters {
acc.insert(c.to_lowercase().collect::<Vec<_>>()[0], *score);
}
acc
})
}
|
use anyhow::Result;
use itertools::Itertools;
use nom::{
branch::alt,
bytes::complete::tag,
combinator::{iterator, value},
IResult,
};
use std::{
collections::{HashMap, HashSet},
fs,
};
fn parse_direction(input: &str) -> IResult<&str, (isize, isize)> {
alt((
value((2, 0), tag("e")),... |
#[cfg(all(test, feature = "secp256k1"))]
mod test {
use cryptographer::rand::Rand;
use cryptographer::{x::secp256k1, Signer};
#[test]
fn sign_verify() {
let mut reader = Rand::new();
let priv_key = secp256k1::generate_key(&mut reader).unwrap();
let msg = [123u8; 32];
... |
// Crates
extern crate indicatif;
// Use
use indicatif::ProgressBar;
use std::env;
use std::fs;
use std::io;
use std::path::Path;
use std::path::PathBuf;
use std::process;
// Main
fn main() {
// Collect args
let args: Vec<String> = env::args().collect();
// Check index
if args.len() > 1 {
let path_arg = a... |
use serde::Deserialize;
use serde::Serialize;
#[derive(Default, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Album {
pub catalog: String,
pub category: String,
pub link: String,
#[serde(rename = "media_format")]
pub media_format: String,
#[... |
use kagura::prelude::*;
use std::{cell::RefCell, rc::Rc};
pub fn div<Msg: 'static>(
z_index: u64,
on_close: impl FnMut() -> Msg + 'static,
position: &[f64; 2],
attributes: Attributes,
events: Events,
children: Vec<Html>,
) -> Html {
let on_close = Rc::new(RefCell::new(Box::new(on_close)));
... |
use super::{common_home_args, parse_common_home_args};
use clap::{App, Arg, ArgMatches, SubCommand};
use comparators;
pub const SUB_HOME_COMPARE_AT: &str = "compare-at";
const ARG_PERIOD: &str = "n-periods";
/// Returns the home compare-at sub command
pub fn home_compare_at_subcommand<'a, 'b>() -> App<'a, 'b> {
S... |
use std::process::Command;
use crate::{
revision_shortcut::RevisionShortcut,
select::{Entry, State},
version_control_actions::{handle_command, VersionControlActions},
};
fn str_to_state(s: &str) -> State {
match s {
"?" => State::Untracked,
"M" => State::Modified,
"A" => State:... |
extern crate geom;
use geom::*;
#[test]
fn rect_split_row_mut() {
let mut r = Rect::new(0, 0, 10, 10);
let s = r.split_row_mut(5);
assert_eq!(r.top(), 0);
assert_eq!(r.left(), 0);
assert_eq!(r.bottom(), 4);
assert_eq!(r.right(), 9);
assert_eq!(s.top(), 5);
assert_eq!(s.l... |
use crate::io::load_input;
use std::collections::HashSet;
pub fn day1_1() {
let input = load_input("day1");
let mut sum = 0;
for line in input {
let n: i32 = line.parse().unwrap();
sum += n;
}
info!("Result of day1_1: {}", sum);
}
pub fn day1_2() {
let input = load_input("day... |
/// PBKDF2 implementation from *ring*
pub use self::ring_pbkdf2::Pbkdf2;
mod ring_pbkdf2 {
use primitives::{Primitive, PrimitiveImpl};
use sod::Sod;
use ring::pbkdf2;
use serde_mcf::Hashes;
use std::fmt;
use std::num::NonZeroU32;
/// Struct holding `PBKDF2` parameters.
///
/// Th... |
use std::{
cmp::Ordering,
collections::{HashMap, HashSet},
fs::File,
path::PathBuf,
};
use assembly_fdb::{
common::Latin1Str,
mem::{Database, Row, RowHeaderIter, Table, Tables},
};
use color_eyre::eyre::{eyre, WrapErr};
use mapr::Mmap;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
stru... |
use std::cmp;
use regex::Regex;
fn main() {
let list: Vec<Instruction> = include_str!("input.txt")
.lines()
.map(parse_line_to_instruction)
.collect();
// We could use the Part 2 code for part 1 but I'd already written it...
let mut g = Grid3d::new();
for ins in &list {
... |
use crate::contract::{handle, init, query};
use cosmwasm_std::testing::{mock_env, MockApi, MockStorage, MOCK_CONTRACT_ADDR, mock_dependencies, MockQuerier};
use cosmwasm_std::{Binary, CosmosMsg, Decimal, Extern, HumanAddr, Uint128, WasmMsg, from_binary, to_vec};
use cw20::{Cw20HandleMsg};
use spectrum_protocol::common:... |
use testutil::*;
use seven_client::voice::{Voice, VoiceParams};
mod testutil;
fn client() -> Voice {
Voice::new(get_client())
}
fn params() -> VoiceParams {
VoiceParams {
from: Option::from("seven.io".to_string()),
text: "HI2U!".to_string(),
to: "+49179876543210".to_string(),
... |
use clap::{App, Arg, ArgMatches, SubCommand};
use futures::{StreamExt, TryStreamExt};
use k8s_openapi::api::core::v1::{Event, Secret};
use kube::api::{ListParams, WatchEvent};
use kube::client::APIClient;
use kube::runtime::Informer;
use kube::{Api, Resource};
use oauth2::prelude::*;
use oauth2::{RefreshToken, TokenRes... |
use alloc::vec::Vec;
use core::{cmp::Ordering, mem};
use util::{impl_md_flow, uint_from_bytes, Hash};
use crate::{
consts::{
{f1, f2, f3, f4}, {H256, K128_LEFT, K128_RIGHT, R_LEFT, R_RIGHT, S_LEFT, S_RIGHT},
},
{round_left_128, round_right_128},
};
pub struct Ripemd256 {
status: [u32; 8],
}
... |
pub fn parse(data: &str) -> usize {
data.lines().map(|line| {
let row: Vec<usize> = line.split_whitespace().map(|chr| {
chr.parse::<usize>().unwrap()
}).collect();
for i in 0..row.len() {
for j in 0..row.len() {
if i == j {
continu... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - DMA mode register"]
pub eth_dmamr: ETH_DMAMR,
#[doc = "0x04 - System bus mode register"]
pub eth_dmasbmr: ETH_DMASBMR,
#[doc = "0x08 - Interrupt status register"]
pub eth_dmaisr: ETH_DMAISR,
#[doc = "0x0c - Debu... |
use super::churn::Matcher;
use super::event::Event;
use time;
use regex::Regex;
static TimeStamp: Regex = regex!(r"\d{2}:\d{2}");
static Mode: Regex = regex!(r"@&%+!\s");
static Nick: Regex = regex!(r"A-Za-z\[\]\\`_\^\{\|\}");
pub struct Irssi;
impl Matcher for Irssi {
fn regular(&self, input: &str) -> Option<E... |
#[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::SRAMMODE {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... |
fn main() {
// mutable borrow
let mut s1 = String::from("Hello!");
let s2 = &mut s1; // mutable borrow occurs here
s2.push('!');
println!("s2 = {}", s2);
println!("s1 = {}", s1);
} |
extern crate wiringpi;
use wiringpi::pin::Value::{High, Low};
use wiringpi::time::delay;
fn main() {
// Example code for a HC-SR04 Ultrasonic Ranging Module
//
// http://www.micropik.com/PDF/HCSR04.pdf
//
// Assumes 'trigger' is connected to pin 0 and 'echo' to pin 1.
//
let pi = wiringpi:... |
use cpx2::interface::gen_whitespace;
use std::collections::HashMap;
#[test]
fn txt() {
let regex = regex::Regex::new(r#".*?"#).unwrap();
let mut haystack = "apple \"fuckk\" apple bryg apple bruh ".to_string();
let matched = haystack.match_indices("apple").collect::<Vec<_>>();
let index_vec = matched.int... |
// Copyright 2020 The VectorDB Authors.
//
// Code is licensed under Apache License, Version 2.0.
#[derive(Debug)]
pub struct VariablePlanner {
pub val: String,
}
impl VariablePlanner {
pub fn new(v: impl AsRef<str>) -> Self {
VariablePlanner {
val: v.as_ref().to_string(),
}
}
... |
use ndarray::{Array1, Array2, Axis, Slice};
use serde::Deserialize;
use std::error::Error;
use std::fs::File;
use std::time::SystemTime;
use learn_rs::Tree;
#[derive(Debug, Deserialize)]
struct BostonRecord {
crim: f64,
zn: f64,
indus: f64,
chas: f64,
nox: f64,
rm: f64,
age: f64,
dis: ... |
use crate::{
ast_types::{
boxed_val::BoxedValue,
break_ast::{
Break,
BreakBase,
},
convert_tokens_into_arguments,
convert_tokens_into_res_expressions,
expression::{
Expression,
ExpressionBase,
},
fn_call:... |
//! Compare the speed of rand implementations
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use libafl::bolts::rands::{
Lehmer64Rand, Rand, RomuDuoJrRand, RomuTrioRand, XorShift64Rand, Xoshiro256StarRand,
};
fn criterion_benchmark(c: &mut Criterion) {
let mut xorshift = XorShift64Ran... |
use generics:: {
Summary,
Test,
Tweet,
};
#[derive(Debug)]
struct Point<T, U> {
x: T,
y: U,
}
impl<T, U> Point<T, U> {
fn x(&self) -> &T {
&self.x
}
fn mixup<V, W>(self, other: Point<V, W>) -> Point<T, W> {
Point {
x: self.x,
y: other.y,
... |
//! Manages a group of threads that all have the same return type and can be [join()]ed as a unit.
//!
//! The implementation uses a [mpsc channel] internaly so that children (spawned threads) can notify
//! the parent (owner of a [`ThreadGroup`]) that they are finished without the parent having to use
//! a blocking [... |
extern crate good_bye;
fn main() {
println!("Hello, world!");
good_bye::say();
}
|
use std::collections::BTreeMap;
use std::rc::Rc;
use std::cell::RefCell;
use std::fmt::Debug;
#[derive(Clone, Debug)]
struct LoudVec<T>(Vec<T>, String);
impl<T: Debug> LoudVec<T> {
fn new(name: impl Into<String>) -> Self {
Self(vec![], name.into())
}
fn push(&mut self, value: T) {
print!("{}: Push {:?};... |
extern crate anthologion;
use anthologion::psalter;
fn main() {
println!("Hello");
let psalm = psalter::get_psalm(1);
println!("{}", psalm.to_string());
}
|
#[macro_use]
extern crate trackable;
#[macro_use]
extern crate lazy_static;
use clap::{App, Arg};
use dialoguer::{theme::ColorfulTheme, Select};
use indicatif::ProgressBar;
use m3u8_rs::{playlist::MasterPlaylist, playlist::MediaPlaylist, playlist::Playlist};
use mpeg2ts::ts::{ReadTsPacket, TsPacketReader, TsPacketWri... |
use serde_derive::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct MinerConfig {
pub rpc_url: String,
pub poll_interval: u64,
pub block_on_submit: bool,
pub threads: usize,
} |
use bindgen::builder;
use std::env;
use std::path::PathBuf;
fn main() {
let root_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
let library_dir: PathBuf = root_dir.join("cxop");
println!(
"cargo:rustc-link-search=native=... |
use framework::{App, Canvas};
mod framework;
struct Counter {
count: isize,
}
impl App for Counter {
type State = isize;
fn init() -> Self {
Self {
count: 0,
}
}
fn draw(&mut self) {
let canvas = Canvas::new();
canvas.draw_rect(0.0, 0.0, 300 as f32, 10... |
pub mod glulx;
|
//! Contains the error type used by `Server`
use crate::BoxError;
use std::net::AddrParseError;
use thiserror::Error;
/// Error returned by the [`Server.listen`](crate::Server::listen()) method
#[derive(Error, Debug)]
#[error("server error: {msg}")]
pub struct ServerError {
msg: String,
#[source]
source:... |
use super::{Token, TokenFilter, TokenStream};
use rust_stemmers::{self, Algorithm};
use std::sync::Arc;
/// `Stemmer` token filter. Currently only English is supported.
/// Tokens are expected to be lowercased beforehands.
#[derive(Clone)]
pub struct Stemmer {
stemmer_algorithm: Arc<Algorithm>,
}
impl Stemmer {
... |
/*
* 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
*/
/// SyntheticsApiTestConfig : Configuration object for a Synthetic API test.
#[derive(Clone, Debug, P... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.