text stringlengths 8 4.13M |
|---|
use geometry::primitive::Point;
use geometry::shape::SupportMapping;
use linalg::{Dot, Mat, Scalar, Vect, VectorNorm};
use num::traits::Float;
use typehack::prelude::*;
struct DistanceCache<T: Scalar, D: Dim> {
dims: D,
simplex: DataVec<Vect<T, D>, D::Succ>,
dots: Mat<T, D::Succ, D::Succ>,
deltas: Mat... |
pub fn connect(){
println!("connected to server");
} |
//! Utilities for working with test accounts.
use codec::Encode;
use ed25519_dalek::{Keypair, PublicKey, SecretKey, Signature};
use finality_grandpa::voter_set::VoterSet;
use sp_consensus_grandpa::{AuthorityId, AuthorityList, AuthorityWeight};
use sp_std::prelude::*;
/// Set of test accounts with friendly names.
pub(... |
use std::io::prelude::*;
use std::{io, fs, thread};
use std::sync::Arc;
use std::sync::mpsc::{sync_channel, SyncSender, Receiver};
enum OutputMode {
Print,
Count,
}
struct Options {
files: Vec<String>,
pattern: String,
output_mode: OutputMode,
}
impl Options {
fn new(files: Vec<String>, patte... |
use libsdp::*;
#[test]
fn sanitizer_simple_single() {
let in_data = "v=0\r
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
s=SDP Seminar\r
i=A Seminar on the session description protocol\r
u=http://www.example.com/seminars/sdp.pdf\r
e=j.doe@example.com (Jane Doe)\r
c=IN IP4 224.2.17.12/127\r
t=2873397496 28734046... |
use itertools::Itertools;
use std::cmp;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
enum Direction {
Up,
Down,
Right,
Left,
}
#[derive(Debug)]
pub struct WirePath(Vec<(Direction, i32)>);
#[aoc_generator(day03)]
pub fn day03_gen(input: &str) -> (WirePath, WirePath) {
input
... |
//! Traits for defining generic RPC handlers.
use bytes;
use failure;
use futures;
use descriptor;
/// An implementation of a specific RPC handler.
///
/// This can be an actual implementation of a service, or something that will send a request over
/// a network to fulfill a request.
pub trait Handler: Clone + Send ... |
use std::io;
use serde::Deserialize;
use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::ChildStdout;
use crate::agda::ReplState;
use crate::debug::debug_response;
use crate::resp::Resp;
/// Deserialize from Agda's command line output.
pub fn deserialize_agda<'a, T: Deserialize<'a>>(buf: &'a str) -> ser... |
// This file is part of Substrate.
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the F... |
/*!
Plugins are WebAssembly modules that can be attached to an [`Environment`][0]. They have 2 tasks:
- Modify other modules that are added to the [`Environment`][0]
- Spawn environment bound processes (TODO)
Each module that is being added to an [`Environment`][0] is going to get parsed into a
`ModuleContext` and Plu... |
#[macro_use]
extern crate cluLog;
use std::io::Write;
fn main() {
inf!("Test");
{//Lock out thread
let mut lock = lock_out!();
for _a in 0..10 {
let _e = lock.write(b"Test");
}
let _e = lock.write(b"\n");
}
let mut lock = lock_out!();
... |
use std::env;
fn main() {
let target = env::var("TARGET").expect("Env variable TARGET not found");
// dmb is only available in armv7 and aarch64
if target.starts_with("armv7") || target.starts_with("aarch64") {
let mut build = cc::Build::new();
build.file("dmb.c");
build.compile("d... |
#![allow(dead_code)]
mod list;
mod heap;
mod set;
mod tree;
mod util;
|
fn boolean_to_string(b: bool) -> String {
return if b == true {
String::from("true")
} else {
String::from("false")
}
}
|
use crate::parser::{Line, Lines};
use crate::symbol_table::SymbolTable;
pub struct Assembler {
lines: Lines,
symbol_table: SymbolTable,
}
impl Assembler {
pub fn new(path: &str) -> Self {
let lines = Lines::new(path);
let mut symbol_table = SymbolTable::new();
let mut row = 0;
... |
use crate::remote_code_ptr::RemoteCodePtr;
use std::{
cmp::Ordering,
convert::TryInto,
fmt::{Display, Formatter, Result},
marker::PhantomData,
ops::{Add, AddAssign, Sub, SubAssign},
};
/// Useful alias.
pub type Void = u8;
#[derive(Copy, Clone, Hash, Debug)]
pub struct RemotePtr<T> {
ptr: usiz... |
/// Module for decoding specification from serde Value into plates structures.
use ::indextree::NodeId;
use ::serde_yaml::Value;
use ::std::collections::HashMap;
use ::std::ops::Deref;
use ::std::str::FromStr;
use super::super::prelude::*;
use super::super::Program;
use super::super::variable::{VariableType, Variable, ... |
// Copyright 2020 <盏一 w@hidva.com>
// 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::{self, Write};
use std::error::Error;
use std::ops::Range;
use std::env;
use std::fmt::{self, Display, Formatter};
use settings::PromptSetting;
use editor::{Editor, Point};
use fugu_env::{CommandType, FuguEnv};
use selector::Selector;
use termion::clear;
use termion::cursor;
use termion::style;
#[derive(D... |
#![feature(collections)]
fn main() {
let sentences = vec![ "This challenge doesn't seem so hard.",
"There are more things between heaven and earth, Horatio, than are dreamt of in your philosophy.",
"Eye of Newt, and Toe of Frog, Wool of Bat, and Tongue of Dog.",
... |
mod farming;
pub mod piece_cache;
pub mod piece_reader;
mod plotting;
use crate::identity::{Identity, IdentityError};
use crate::node_client::NodeClient;
use crate::reward_signing::reward_signing;
use crate::single_disk_farm::farming::farming;
pub use crate::single_disk_farm::farming::FarmingError;
use crate::single_d... |
#[doc = "Reader of register IC_CLR_RESTART_DET"]
pub type R = crate::R<u32, super::IC_CLR_RESTART_DET>;
#[doc = "Reader of field `CLR_RESTART_DET`"]
pub type CLR_RESTART_DET_R = crate::R<bool, bool>;
impl R {
#[doc = "Bit 0 - Read this register to clear the RESTART_DET interrupt (bit 12) of IC_RAW_INTR_STAT registe... |
pub mod image {
use std::fs::File;
use std::io::Write;
pub type Color = u8;
pub type Pixel = [Color; 3];
pub struct Image {
pub width: usize,
pub height: usize,
pub total_pixels: usize,
pub maximum_color_value: Color,
pub pixels: Vec<Pixel>,
}
impl<'a> Image {
pub fn new(width: usize, height: usiz... |
extern crate carrier_core;
#[macro_use]
pub extern crate failure;
extern crate bs58;
extern crate byteorder;
extern crate crc8;
extern crate ed25519_dalek;
extern crate rand;
extern crate sha2;
extern crate subtle;
extern crate x25519_dalek;
#[macro_use]
extern crate prost_derive;
pub extern crate bytes;
extern crate p... |
use crate::cli::Args;
use crate::errors::Errcode;
use crate::config::ContainerOpts;
use crate::child::generate_child_process;
use crate::mounts::clean_mounts;
use nix::sys::utsname::uname;
use nix::sys::wait::waitpid;
use nix::unistd::{close, Pid};
use std::os::unix::io::RawFd;
pub struct Container {
config: Cont... |
#[macro_use]
extern crate cpp;
#[macro_use]
extern crate failure;
extern crate libc;
mod bindings;
pub mod context;
pub mod interpreter;
pub mod model;
pub mod op_resolver;
pub mod ops;
pub use interpreter::Interpreter;
pub use model::{FlatBufferModel, InterpreterBuilder};
|
use std::io;
use std::net::{SocketAddr, ToSocketAddrs};
use std::os::windows::io::AsRawSocket;
#[cfg(feature = "io_timeout")]
use std::time::Duration;
use super::super::{co_io_result, EventData};
use crate::coroutine_impl::{is_coroutine, CoroutineImpl, EventSource};
use crate::net::UdpSocket;
use crate::scheduler::get... |
use middle::*;
use name::*;
pub trait Walker<'a, 'ast>: StatementWalker<'a, 'ast> {
fn walk_universe(&mut self, universe: &Universe<'a, 'ast>) { default_walk_universe(self, universe); }
fn walk_package(&mut self, package: PackageRef<'a, 'ast>) { default_walk_package(self, package); }
fn walk_type_definitio... |
use Error;
use super::Device;
// We use our own RNG to stay compatible with #![no_std].
// The use of the RNG below has a slight bias, but it doesn't matter.
fn xorshift32(state: &mut u32) -> u32 {
let mut x = *state;
x ^= x << 13;
x ^= x >> 17;
x ^= x << 5;
*state = x;
x
}
fn check_rng(state:... |
use crate::cache::StoreCache;
use crate::store::ChainStore;
use ckb_db::{
iter::{DBIter, DBIterator, IteratorMode},
Col, DBPinnableSlice, RocksDBSnapshot,
};
use std::sync::Arc;
pub struct StoreSnapshot {
pub(crate) inner: RocksDBSnapshot,
pub(crate) cache: Arc<StoreCache>,
}
impl<'a> ChainStore<'a> f... |
#[doc = "Register `GUSBCFG` reader"]
pub type R = crate::R<GUSBCFG_SPEC>;
#[doc = "Register `GUSBCFG` writer"]
pub type W = crate::W<GUSBCFG_SPEC>;
#[doc = "Field `TOCAL` reader - FS timeout calibration"]
pub type TOCAL_R = crate::FieldReader;
#[doc = "Field `TOCAL` writer - FS timeout calibration"]
pub type TOCAL_W<'a... |
use thiserror::Error;
#[derive(Error, Debug)]
pub enum ServiceError {
#[error("Not Found")]
NotFound,
#[error("{0}")]
DbQueryFailed(#[from] diesel::result::Error),
}
|
#![doc = "generated by AutoRust 0.1.0"]
#[cfg(feature = "package-2020-09-18")]
mod package_2020_09_18;
#[cfg(feature = "package-2020-09-18")]
pub use package_2020_09_18::{models, operations, API_VERSION};
#[cfg(feature = "package-2020-06-14")]
mod package_2020_06_14;
#[cfg(feature = "package-2020-06-14")]
pub use packa... |
use core::mem;
use crate::common::segment_iterator::SegmentIterator;
use crate::Segment;
/// It's an implementation of `SegmentIterator` that does not heap-allocate. Alternatives are
/// `BinBuilder` and `StrBuilder`; `SegmentsSlice` is less flexible but cheaper
/// (smaller stack; faster).
///
/// ```rust
/// use ab... |
// Copyright 2017 pdb 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 to tho... |
#[doc = "Register `CFGR` reader"]
pub type R = crate::R<CFGR_SPEC>;
#[doc = "Register `CFGR` writer"]
pub type W = crate::W<CFGR_SPEC>;
#[doc = "Field `SEL` reader - SEL"]
pub type SEL_R = crate::FieldReader;
#[doc = "Field `SEL` writer - SEL"]
pub type SEL_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 4, O>;
#... |
use qt_widgets::{QSystemTrayIcon, QApplication, QMenu, QActionGroup, SlotOfActivationReason};
use qt_widgets::qt_core::{QTimer, QString, Slot};
use qt_gui::QIcon;
use std::thread;
mod utils;
enum ActivationReason {
LeftClick = 3,
MiddleClick = 4
}
// Returns an index for an icon depending on the status of the ... |
#[doc = "Register `MACVR` reader"]
pub type R = crate::R<MACVR_SPEC>;
#[doc = "Field `SNPSVER` reader - IP version"]
pub type SNPSVER_R = crate::FieldReader;
#[doc = "Field `USERVER` reader - ST-defined version"]
pub type USERVER_R = crate::FieldReader;
impl R {
#[doc = "Bits 0:7 - IP version"]
#[inline(always)... |
#[doc = "Register `CR2` reader"]
pub type R = crate::R<CR2_SPEC>;
#[doc = "Register `CR2` writer"]
pub type W = crate::W<CR2_SPEC>;
#[doc = "Field `RXDMAEN` reader - Rx buffer DMA enable When this bit is set, a DMA request is generated whenever the RXNE flag is set."]
pub type RXDMAEN_R = crate::BitReader;
#[doc = "Fie... |
// cspell:ignore HINSTANCE HWND libloaderapi lpfn lpsz minwindef OVERLAPPEDWINDOW winapi winuser WNDCLASSW
use std::ffi::OsStr;
use std::iter::once;
use std::os::windows::prelude::OsStrExt;
use std::path::Path;
use std::ptr;
use std::sync::{Arc, Mutex};
use vst::host::{Host, PluginLoader};
use vst::plugin::Plugin;
us... |
use std::fmt::Debug;
use logos::Logos;
#[derive(Logos, Debug, PartialEq, Clone, Eq)]
pub enum JavaTokenType {
#[end]
End,
#[error]
Error,
#[regex = "[\r|\n|\t| ]" ]
Whitespace,
// TODO
#[regex = "([_|$|a-z|A-Z]([_|$|a-z|A-Z|_|$0-9])*)" ]
Identifier,
#[token = "abstract" ]
... |
use std::str::*;
#[derive(Debug, PartialEq)]
pub enum Token<'a> {
Text(&'a str),
Int(i64),
Float(f64),
LeftCurly,
RightCurly,
LeftParen,
RightParen,
SemiColon,
Tick,
}
pub struct Lexer<'a> {
input: Chars<'a>,
curr: Option<char>,
mark: &'a str,
}
impl<'a> Lexer<'a> {
... |
extern crate ggez;
mod base;
mod pathfinder;
mod path_example;
mod move_example;
use ggez::*;
use base::*;
use pathfinder::*;
use std::env;
use std::path;
use std::process;
use ggez::conf::FullscreenType;
pub fn main() -> GameResult<()> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 || ar... |
use chrono::prelude::*;
use std::collections::HashMap;
const BASEURL: &str = "https://www.boardgamegeek.com/xmlapi2/";
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum ThingType {
Boardgame,
BoardgameAccessory,
BoardgameExpansion,
Videogame,
RPGItem,
RPGIssue
}
impl ThingType {
p... |
use std::{
fs::File,
io::{stderr, Read, Write},
path::Path,
process::exit,
};
pub fn open_file(path: &Path) -> String {
match File::open(path) {
Ok(mut file) => {
let mut file_content = String::new();
let _ = file
.read_to_string(&mut file_content)
... |
use crate::settings::CanonicalizeOption;
use std::ffi::OsString;
use std::io;
#[cfg(unix)]
use std::os::unix::ffi::OsStringExt;
#[cfg(windows)]
use std::os::windows::ffi::OsStringExt;
use std::path::{Component, Path, PathBuf};
pub fn read_link<P: AsRef<Path>>(
path: P,
canonicalize: &CanonicalizeOption,
) -> i... |
use crate::asset::*;
use crate::reader::*;
use crate::util::*;
use anyhow::*;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
use std::io::prelude::*;
use std::io::Cursor;
#[derive(Debug)]
pub struct Export {
pub class: u32, // just storing u32 because idc what this is
pub super_index: i32, // no... |
//! Tests auto-converted from "sass-spec/spec/non_conformant/sass_4_0/color_arithmetic/division"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/non_conformant/sass_4_0/color_arithmetic/division/color_color.hrx"
// Ignoring "color_color", error tests are not supported yet.
// From "sass-spec/spec/non_conf... |
mod interface;
mod tcp;
use self::interface::*;
use futures::future::{join_all, select, Either};
use futures_locks::{Mutex, RwLock};
use smol::Timer;
use std::{
collections::{HashMap, HashSet},
hash, io,
sync::Arc,
time::Duration,
};
use yggy_core::{
dev::*,
interfaces::{
link::{self, m... |
use super::break_xor_cipher;
use super::english;
use std::convert::From;
use crypto::xor_cipher::SingleCharXorCipher;
use crypto::xor_cipher::BlockCipher;
use num_rational::Ratio;
use super::frequency_analysis::Histogram;
use std::collections::HashMap;
fn make_table(array: &[(u8, usize)]) -> (usize, HashMap<u8,usize>... |
use cc;
pub fn build_linux() {
cc::Build::new()
.include("bullet3/src")
.define("BT_USE_DOUBLE_PRECISION", None)
.define("LinearMath_EXPORTS", None)
.define("NDEBUG", None)
.define("USE_GRAPHICAL_BENCHMARK", None)
.opt_level(3) // ignoring OPT_LEVEL from the crate
... |
//! module sha3 implements the SHA-3 fixed-output-length hash functions and the SHAKE
//! variable-output-length hash functions defined by FIPS-202.
//!
//! Both types of hash function use the "sponge" construction and the Keccak permutation. For a
//! detailed specification see [http://keccak.noekeon.org/][1].
//!
//!... |
fn main() {
println!("{:?}", calculate_recipes(793031));
println!("{:?}", find_recipes(vec![7,9,3,0,3,1]));
}
fn score(scoreboard:&mut Vec<usize>, first_elve_index: usize, second_elve_index: usize) {
let new_score;
{ // this block of code is used to be able to get values from mutable vec ==> https://s... |
// --- paritytech ---
use pallet_randomness_collective_flip::Config;
// --- darwinia-network ---
use crate::*;
impl Config for Runtime {}
|
// Copyright (C) 2021 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use super::*;
use std::collections::BTreeMap;
/// `RTP-Info` header ([RFC 7826 section 18.45](https://tools.ietf.org/html/rfc7826#section-18.45)).
#[der... |
use serde_derive::Deserialize;
#[derive(Debug, Deserialize)]
pub struct Config {
pub basic: BasicCfg,
}
#[derive(Debug, Deserialize)]
pub struct BasicCfg {
pub database_url: String,
}
|
use std::borrow::Cow;
use std::convert::TryFrom;
use std::ffi::OsString;
use std::fmt;
use std::sync::Arc;
use grep::printer::{ColorSpecs, StandardBuilder};
use grep::regex::RegexMatcherBuilder;
use grep::searcher::SearcherBuilder;
use poppler::PopplerDocument;
use rayon::iter::{IntoParallelIterator, ParallelIterator}... |
#[doc = "Reader of register EMR1"]
pub type R = crate::R<u32, super::EMR1>;
#[doc = "Writer for register EMR1"]
pub type W = crate::W<u32, super::EMR1>;
#[doc = "Register EMR1 `reset()`'s with value 0"]
impl crate::ResetValue for super::EMR1 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
use std::collections::VecDeque;
use crate::swapping::{Swapper, SWAPPER_DEFAULT_CAPACITY};
pub struct FifoSwapper<T> {
deque: VecDeque<T>,
capacity: usize,
}
impl<T> Default for FifoSwapper<T> {
fn default() -> Self {
Self {
deque: VecDeque::with_capacity(SWAPPER_DEFAULT_CAPACITY),
... |
use std::io;
fn main()
{
let mut letter = String::new();
let mut operator = String::new();
let mut number1 = String::new();
let mut number2 = String::new();
let result:i32;
let mut percentage = String::new();
let gradeuate;
println!("Question 1: Proof if Alphabet is vowel or not");
println!("Please enter... |
extern crate env_logger;
extern crate hyper;
extern crate iron;
extern crate mount;
extern crate params;
#[macro_use]
extern crate log;
#[macro_use]
extern crate lazy_static;
extern crate crypto;
extern crate dotenv;
extern crate structopt;
#[macro_use]
extern crate serde_derive;
extern crate rust_sodium;
extern crate ... |
use diesel::{Queryable, Insertable};
use serde_derive::*;
use rocket::*;
use crate::schema::*;
#[derive(Queryable, Serialize)]
pub struct UserEntity {
pub id: i32,
pub name: String,
pub email: String,
pub dob: String,
pub kyc_level: i32
}
#[derive(Insertable, Deserialize, Serialize, FromForm)]
pub struct U... |
mod paragraph;
mod rule;
mod header;
mod blockquote;
mod codeblock;
mod list;
mod footnote_definition;
mod table;
mod inline;
mod link;
mod image;
pub use self::paragraph::Paragraph;
pub use self::rule::Rule;
pub use self::header::Header;
pub use self::blockquote::BlockQuote;
pub use self::codeblock::CodeBlock;
pub us... |
extern crate rand;
use std::io;
use rand::Rng;
fn main() {
// let secret_number =12u32;
// let secret_number =rand::random::<u32>();;
let mut secret_number =generateSecrte();
println!("secret_number is :{}",secret_number);
loop{
let guess =inputAnNum();
if secret_number != guess {
println!("You guessed: ... |
#[doc = "Reader of register OA0_OFFSET_TRIM"]
pub type R = crate::R<u32, super::OA0_OFFSET_TRIM>;
#[doc = "Writer for register OA0_OFFSET_TRIM"]
pub type W = crate::W<u32, super::OA0_OFFSET_TRIM>;
#[doc = "Register OA0_OFFSET_TRIM `reset()`'s with value 0"]
impl crate::ResetValue for super::OA0_OFFSET_TRIM {
type T... |
/*!
```rudra-poc
[target]
crate = "array_iterator"
version = "1.2.0"
indexed_version = "0.2.4"
[report]
issue_url = "https://gitlab.com/kevincox/array_iterator.rs/-/issues/1"
issue_date = 2020-12-31
[[bugs]]
analyzer = "Manual"
guide = "UnsafeDataflow"
bug_class = "Other"
rudra_report_locations = []
```
!*/
#![forbid... |
//! Tests auto-converted from "sass-spec/spec/libsass-closed-issues/issue_1654"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/libsass-closed-issues/issue_1654/basic.hrx"
#[test]
#[ignore] // wrong result
fn basic() {
assert_eq!(
rsass(
"%foo {\
\n &bar {\
\... |
use crate::helpers::configuration::*;
use crate::helpers::virustotal::*;
use crate::helpers::whoxml::*;
|
pub mod error;
pub mod operators;
pub mod source;
pub mod util;
pub use operators::Operator;
|
use serde::{Serialize, Deserialize};
// base info
#[derive(Serialize, Deserialize)]
pub struct BaseResult {
pub code: String,
pub data: String,
pub success: bool,
} |
use std::process::Command;
use std::env::current_exe;
fn main() {
let path = current_exe()
.expect("could not find current executable");
let path = path.with_file_name("process_b");
let mut children = Vec::new();
for _ in 0..3 {
children.push(
Command::new(path.as_os_str())
... |
#![cfg(target_arch = "wasm32")]
use day01::*;
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
static INPUT: &str = include_str!("../input.txt");
#[wasm_bindgen_test]
fn day01_part1() {
assert_eq!(part1(INPUT), Ok(3_266_516));
}
#[wasm_bindgen_test]
fn day01_part2() {
assert_eq!(part... |
//! The `tpu` module implements the Transaction Processing Unit, a
//! 5-stage transaction processing pipeline in software.
//!
//! ```text
//! .---------------------------------------------------------------.
//! | TPU .-----. |
//! ... |
#[doc = "Register `SDTR1` reader"]
pub type R = crate::R<SDTR1_SPEC>;
#[doc = "Register `SDTR1` writer"]
pub type W = crate::W<SDTR1_SPEC>;
#[doc = "Field `TMRD` reader - Load Mode Register to Active"]
pub type TMRD_R = crate::FieldReader;
#[doc = "Field `TMRD` writer - Load Mode Register to Active"]
pub type TMRD_W<'a... |
/*
Copyright 2019-2023 Didier Plaindoux
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... |
use apllodb_shared_components::{
ApllodbResult, ApllodbSessionError, ApllodbSessionResult, Session, SessionId, SessionWithDb,
SessionWithTx,
};
use futures::FutureExt;
use super::BoxFut;
#[cfg_attr(feature = "test-support", mockall::automock)]
pub trait WithDbMethods: Sized + 'static {
fn begin_transactio... |
use crate::api::*;
use crate::auth::{Claims};
use crate::database::*;
use crate::error::Error;
use std::collections::HashMap;
/// Get all RPG systems from database
pub fn get_rpgsystems(db: &Database) -> Result<GetRpgSystems, Error> {
match db.get_all::<RpgSystem>() {
Ok(rpgsystems) => Ok(GetRpgSystems { r... |
use std::collections::{HashSet, HashMap};
pub struct Pak { }
impl Pak {
/// Calculates the P@K value for each of the queries provided.
/// Returns a list of (query_id, P@K) tuples
pub fn calc(k: usize, results: &HashMap<usize, Vec<usize>>, relevance_info: &HashMap<usize, HashSet<usize>>) -> Vec<(usize, f6... |
fn main() {
let _: bool = 4 / 3;
}
|
pub struct True;
pub struct False;
impl True {
pub const fn value(self) -> bool {
true
}
}
impl False {
pub const fn value(self) -> bool {
false
}
}
|
use babylon::prelude::*;
struct Game {
scene: Scene,
_camera: Camera,
_light_1: HemisphericLight,
_light_2: PointLight,
ball: Sphere,
paddle_1: Cube,
paddle_2: Cube,
paddle_dir: f64,
ball_dir: Vector,
}
impl Default for Game {
fn default() -> Self {
let mut scene = Scen... |
use super::{selector, Comp, InstanceKey, Popup, Tracker};
use crate::{world, Game};
use glam::Vec2;
pub fn overview_ui(ui: &mut egui::Ui, game: &mut Game) -> Option<()> {
reset_ui(ui, game);
let cursor_pos = {
let Game {
phys,
player,
config: world::Config { draw, .... |
mod elliptic_curve;
mod alphabet;
extern crate regex;
use regex::Regex;
use elliptic_curve::Curve;
use elliptic_curve::Point;
use getopts::Options;
use yaml_rust::YamlLoader;
use std::fs;
use std::env;
fn find_in_alphabet(p: Point) -> Option<char> {
for point in alphabet::ALPHABET.entries() {
let c_p = Point {... |
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use super::*;
/// `Scale` header ([RFC 7826 section 18.46](https://tools.ietf.org/html/rfc7826#section-18.46)).
#[derive(Debug, Clone, Copy, PartialEq, P... |
#![cfg(target_arch = "wasm32")]
use day11::*;
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
static INPUT: &str = include_str!("../input.txt");
#[wasm_bindgen_test]
fn day11_part1() {
assert_eq!(part1(INPUT), Ok(2373));
}
#[wasm_bindgen_test]
fn day11_part2() {
assert_eq!(part2(INP... |
use crate::{client::Client};
use ureq::{Error, Request};
use serde::{Deserialize};
#[derive(Deserialize)]
pub struct Contact {
#[serde(rename = "ID")]
pub id: String,
#[serde(rename = "Name")]
pub name: String,
#[serde(rename = "Number")]
pub number: String,
}
#[derive(Default)]
pub struct Con... |
use super::{RMBA, Bx, Bxm, rc};
use std::{ptr, mem, fmt, hash, cmp, borrow};
use std::ops::Deref;
use std::rc::Rc;
use stable_deref_trait::StableDeref;
use std::sync::{Arc, Mutex, MutexGuard, RwLock, RwLockReadGuard, RwLockWriteGuard};
use std::cell::{Ref, RefMut, RefCell};
use std::marker::PhantomData;
type ARefSto... |
//#![feature(trace_macros)]
#![feature(test)]
extern crate test;
#[macro_use]
extern crate nom;
use nom::{digit, alphanumeric};
use test::Bencher;
use std::str::{self,FromStr};
use std::collections::HashMap;
#[derive(Debug,PartialEq)]
pub enum JsonValue {
Str(String),
Num(f32),
Array(Vec<JsonValue>),
Objec... |
use multiarray::{Dim3, MultiArray};
use grid::GridUnity;
use modules::physical_modules::hd;
pub fn calculations(
initial_grid: MultiArray<GridUnity,Dim3>,
size: &Vec<usize>,
time_step: f64,
) -> MultiArray<GridUnity, Dim3> {
return hd::calculations(initial_grid, &size, time_step,1.0);
}
|
/// First line is a short summary describing function.
///
/// The next lines present detailed documentation. Code blocks start with
/// triple backquotes and have implicit `fn main()` inside
/// and `extern crate <cratename>`.
///
/// ```
/// let result = doc::add(2,3);
/// assert_eq!(result, 5);
/// ```
pub fn add... |
// Usual update functions
fn linear_update(alpha: f64, beta: f64, q: f64, delta_t: f64) -> f64 {
let x: f64 = -1.0 * alpha * delta_t;
delta_t * q * (1.0 - beta + beta * x.exp()) / (1.0 - x.exp())
}
fn quadratic_update(alpha: f64, beta: f64, q: f64, delta_t: f64) -> f64 {
let x: f64 = 1.0 + 4.0 * alpha /(q * delta_t... |
struct S { len: i32 }
fn main() {
let s = S { len: 42 };
let x = s.len;
}
|
#![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 blueprints {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub async f... |
#![deny(warnings)]
extern crate futures;
extern crate hyper;
extern crate pretty_env_logger;
use futures::future::FutureResult;
use hyper::{Get, Post, StatusCode};
use hyper::header::ContentLength;
use hyper::server::{Http, Service, Request, Response};
static INDEX: &'static [u8] = b"Try POST /echo";
struct Echo;
... |
use std::io;
pub fn question5() {
let mut number = String::new();
io::stdin().read_line(&mut number)
.expect("Failed to read line");
let number: i32 = number.trim().parse()
.expect("Please type a number!");
println!("You Entered: {}", number);
if number < 0
{... |
use crate::{
cmd::*,
result::{anyhow, Result},
traits::{TxnEnvelope, TxnSign, B64},
};
use helium_api::blocks;
use rust_decimal::{prelude::*, Decimal};
use serde::Serialize;
use serde_json::json;
use std::str::FromStr;
/// Report an oracle price to the blockchain
#[derive(Debug, StructOpt)]
pub enum Cmd {
... |
// q0053_maximum_subarray
struct Solution;
impl Solution {
pub fn max_sub_array(nums: Vec<i32>) -> i32 {
Solution::max_sum(&nums)
}
pub fn max_sum(nums: &[i32]) -> i32 {
// println!("{:?}", nums);
let nlen = nums.len();
if nlen == 0 {
return 0;
} else i... |
use futures::prelude::*;
use futures::task::{Context, Poll, Spawn, SpawnError, SpawnExt};
use std::io;
use std::pin::Pin;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
pub struct Compat<T>(pub T);
impl<T> Compat<T> {
pub fn new(inner: T) -> Self {
Self(inner)
}
pub ... |
use rocket::{
Route,
response::{status::Custom},
http,
};
use rocket_contrib::json::Json;
use crate::{
models::{ResponseErr, Header, PostedReview},
services,
};
#[post("/", data = "<review>")]
fn eval(review: Json<PostedReview>, head: Header) -> Result<http::Status, Custom<Json<ResponseErr>>> {
... |
use bytes::BytesMut;
use std::io;
pub(crate) struct Writer<'a>(pub &'a mut BytesMut);
impl<'a> io::Write for Writer<'a> {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.0.extend_from_slice(buf);
Ok(buf.len())
}
fn flush(&mut self) -> io::Result<()> {
Ok(())
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.