text stringlengths 8 4.13M |
|---|
use super::super::{
program::MaskProgram,
webgl::{WebGlF32Vbo, WebGlI16Ibo, WebGlRenderingContext},
ModelMatrix,
};
use super::{Camera, TableBlock};
use crate::{
block::{self, BlockId},
Color,
};
use ndarray::Array2;
use std::collections::HashMap;
#[derive(PartialEq, PartialOrd)]
pub struct Total<T... |
use lambda_runtime::{error::HandlerError, lambda, Context};
use serde_derive::Deserialize;
use serde_json::{json, Value};
#[derive(Deserialize)]
struct AuthorizationEvent {
#[serde(rename = "methodArn")]
method_arn: String,
}
fn main() {
lambda!(handler)
}
fn handler(event: AuthorizationEvent, _: Context... |
use hey_listen::{
sync::{ParallelDispatcherRequest, ParallelDispatcher, ParallelListener},
RwLock,
};
use std::sync::Arc;
#[derive(Clone, Eq, Hash, PartialEq)]
enum Event {
VariantA,
VariantB,
}
#[test]
fn dispatch_parallel_to_dyn_traits() {
#[derive(Default)]
struct CountingEventListener {
... |
use std::io;
extern crate fancy_regex;
use fancy_regex::Regex as Regex;
fn check(i: u32, re1: &Regex, re2: &Regex) -> bool{
let as_string = i.to_string();
let matches = re1.is_match(&as_string).unwrap();
let rc = matches && re2.is_match(&as_string).unwrap();
return rc;
}
fn main() -> io::Result<()> ... |
mod maps;
mod strs;
mod vect;
fn main() {
vect::vectors();
println!("");
strs::strings();
println!("");
maps::maps();
}
|
use prelude::*;
use draw::prelude::*;
use widgets::text::StaticTextStyle;
pub struct ListItemSelected {
pub widget: Option<Widget>,
}
#[derive(Debug, Copy, Clone)]
pub struct ItemSelected;
#[derive(Default)]
pub struct ListHandler {
selected: Option<Widget>,
}
impl EventHandler<ListItemSelected> for ListHan... |
use std::fmt::Debug;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum MetadataError {
#[error("empty response")]
Empty,
#[error("audio item is non-playable when it should be")]
NonPlayable,
#[error("audio item duration can not be: {0}")]
InvalidDuration(i32),
#[error("track is marked ... |
struct Person {
name: &'static str,
age: u8,
}
impl Person {
fn print_details(&self) {
println!("\nName: {}\nAge: {}\nCan speak: {}", self.name, self.age, self.can_speak());
}
}
trait VoiceBox {
fn speak(&self);
fn can_speak(&self) -> bool;
}
impl VoiceBox for Person {
fn speak(&s... |
/*
* 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.
*/
//! Routines for tracing and decoding instructions to a particular architecture
use iced_x86::Decod... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
account_config::constants::CORE_CODE_ADDRESS,
identifier::Identifier,
language_storage::{ModuleId, StructTag, TypeTag},
};
use once_cell::sync::Lazy;
pub const STC_NAME: &str = "STC";
pub static STC_IDENTIF... |
use super::{shared::mask_32, shared::vector_256, *};
use crate::{
input::{error::InputError, Input, InputBlockIterator},
query::JsonString,
result::InputRecorder,
FallibleIterator,
};
const SIZE: usize = 32;
pub(crate) struct Avx2MemmemClassifier32<'i, 'b, 'r, I, R>
where
I: Input,
R: InputRec... |
//! This module defines the `Proc`, which represents a compiled function in memory.
//! The `Proc` struct contains enough informations for the `Builder` to inline calls to procedures,
//! and to call them efficiently.
use arch::Operand;
use assembler::AssemblyStyle;
use parser::Syntax;
use typesystem::{Fun, Ty, TyPara... |
error_chain! {
foreign_links {
//IO(std::io::Error);
PG(postgres::Error);
}
}
pub type ResT<T> = Result<T>;
|
pub mod ast;
pub mod parser;
#[cfg(test)]
mod tests;
|
pub mod bus;
pub mod decoder;
pub mod encoder;
pub mod messages;
pub mod types;
|
mod parser;
use parser::*;
fn main() -> Result<(), parser::ParsingError> {
let packet = "POST /cgi-bin/process.cgi HTTP/1.1\r
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)\r
Host: www.tutorialspoint.com\r
Content-Type: application/x-www-form-urlencoded\r
Content-Length: length\r
Accept-Language: en-us... |
use serenity::client::Context;
use serenity::model::channel::GuildChannel;
use serenity::model::guild::PartialMember;
use serenity::model::id::{GuildId, RoleId, UserId};
use serenity::model::prelude::{Channel, User};
use std::collections::HashMap;
use std::fmt::Display;
use std::sync::Mutex;
lazy_static! {
static ... |
//! Common transaction components.
mod fees;
mod intermediary;
pub mod permissions;
pub use currency::transactions::components::fees::{FeeStrategy, FeesCalculator, ThirdPartyFees};
pub use currency::transactions::components::intermediary::Intermediary;
// pub use currency::transactions::components::permissions::{mask... |
mod common;
#[test]
#[cfg(feature = "devkit-arm-tests")]
pub fn test_mov() {
let (cpu, _mem) = common::execute_arm("mov-imm", "mov r0, #5");
assert_eq!(cpu.registers.read(0), 5);
// If the shift amount is specified in the instruction, the PC will be 8 bytes ahead.
let (cpu, _mem) = common::execute_arm... |
use super::{common_invest_args, parse_common_invest_args};
use clap::{App, Arg, ArgMatches, SubCommand};
use investment::Investment;
use prettytable::row::Row;
pub const SUB_INVEST_TABLE: &str = "table";
const ARG_EVERY_PERIOD: &str = "every-period";
const ARG_TO: &str = "to";
/// Returns the loan info-at sub command... |
fn main() {
let v = vec![1, 2, 3, 4];
let third: &i32 = &v[2];
let fourth: Option<&i32> = v.get(3);
let row = vec![
SpreadsheetCell::Int(3),
SpreadsheetCell::Float(10.11),
SpreadsheetCell::Text(String::from("blue")),
];
} // <- vec & v go out of scope here
#[derive(Debug)]... |
// 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 tantivy::{
Index,
IndexWriter,
schema::*,
directory::MmapDirectory,
};
use env_logger;
use log::{info, debug};
use std::sync::Mutex;
use std::path::Path;
use rayon::prelude::*;
use storage::tantivy::{index_anchors, create_schema};
use wikitools::loaders::build_or_load_page_indices;
use wikitools::s... |
mod geo;
mod model;
mod obj;
mod render;
use std::vec::{Vec};
extern crate image;
fn main() {
let imgx = 800;
let imgy = 800;
let mut imgbuf = image::RgbImage::new(imgx, imgy);
let mut scene = render::Scene::new(Vec::<obj::Obj>::new(), &mut imgbuf);
scene.add_object(obj::Obj::from_file("obj/diabl... |
use iron::request::Request;
use iron::response::Response;
use iron::IronResult;
use iron::status;
use router::Router;
use ijr::JsonResponse;
use middleware::mysql::PoolProvider;
use model::rush::Rush;
use repository;
pub fn create(request: &mut Request) -> IronResult<Response> {
let mysql_pool = request.extensio... |
/*!
This crate creates a perfect hash function for an enum, providing a single method: `T::lookup(&str) -> Option<T>`
This method will return either the exact match of the variant, or None
`std::fmt::Display` is also implemented for convenient printing of the string representation of the variant
# Examples:
## deriv... |
use inkwell::types::FloatType;
use super::*;
impl<'ctx> Compiler<'ctx> {
pub fn void_ptr_type(&self) -> BasicTypeEnum<'ctx> {
self.llvm.i8_type().ptr_type(AddressSpace::Generic).into()
}
pub fn value_type(&self, vars: &mut Vars<'ctx>, ty: &Type) -> BasicTypeEnum<'ctx> {
match ty {
... |
// Copyright 2018-2021 Google LLC
//
// 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 t... |
use std::ops::{Index, IndexMut};
use std::fmt::{self, Debug};
use std::iter;
use smallvec::SmallVec;
#[derive(Clone, Eq, Ord, PartialOrd, PartialEq, Hash)]
pub struct Vec3<T> {
height: usize,
depth: usize,
width: usize,
data: SmallVec<[T; 2048]>, // 20 characters * 8 x 8 board
}
impl<T> Vec3<T> {
... |
#[doc = "Reader of register CTRL"]
pub type R = crate::R<u32, super::CTRL>;
#[doc = "Writer for register CTRL"]
pub type W = crate::W<u32, super::CTRL>;
#[doc = "Register CTRL `reset()`'s with value 0"]
impl crate::ResetValue for super::CTRL {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
pub mod process;
pub mod fork;
pub mod signal;
pub mod pipe;
pub mod redirect; |
pub mod prototypes;
mod util;
|
use std::fmt::Display;
use super::{AddressingMode, Status, CPU};
#[derive(Clone, Copy)]
pub struct Opcode<'a> {
pub code: u8,
pub mnemonic: &'a str,
pub length: u8,
pub cycles: u8,
pub mode: AddressingMode,
}
impl<'a> Opcode<'a> {
fn new(code: u8, mnemonic: &'a str, length: u8, cycles: u8, mo... |
pub mod create_database;
pub mod create_document;
pub mod delete_document;
pub mod execute_view;
pub mod read_document;
pub mod update_document;
pub use self::create_database::CreateDatabase;
pub use self::create_document::CreateDocument;
pub use self::delete_document::DeleteDocument;
pub use self::execute_view::Execu... |
//! Deployment Recipes
use ckb_tool::ckb_types::H256;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CellRecipe {
pub name: String,
pub tx_hash: H256,
pub index: u32,
pub occupied_capacity: u64,
pub data_hash: H256,
pub type_id: Option<H256>,
}
... |
#![doc = "generated by AutoRust 0.1.0"]
#[cfg(feature = "package-2019-12")]
mod package_2019_12;
#[cfg(feature = "package-2019-12")]
pub use package_2019_12::{models, operations, API_VERSION};
#[cfg(feature = "package-2018-10")]
mod package_2018_10;
#[cfg(feature = "package-2018-10")]
pub use package_2018_10::{models, ... |
use rust::solve;
fn main() {
solve();
}
|
use simple_error::bail;
use std::error;
use std::io;
use std::io::BufRead;
use crate::day;
pub type BoxResult<T> = Result<T, Box<dyn error::Error>>;
pub struct Day05 {}
impl day::Day for Day05 {
fn tag(&self) -> &str { "05" }
fn part1(&self, input: &dyn Fn() -> Box<dyn io::Read>) {
println!("{:?}", ... |
use std::ops::{Deref, DerefMut};
#[derive(Debug, Copy, Clone, Default)]
pub struct RV32Registers {
inner: [u32; 32],
pc: u32,
// x0: u32,
// x1: u32,
// x2: u32,
// x3: u32,
// x4: u32,
// x5: u32,
// x6: u32,
// x7: u32,
// x8: u32,
// x9: u32,
// x10: u32,
// x... |
#[doc = "Register `CR1` reader"]
pub type R = crate::R<CR1_SPEC>;
#[doc = "Register `CR1` writer"]
pub type W = crate::W<CR1_SPEC>;
#[doc = "Field `TAMP1E` reader - TAMP1E"]
pub type TAMP1E_R = crate::BitReader;
#[doc = "Field `TAMP1E` writer - TAMP1E"]
pub type TAMP1E_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG... |
use proconio::{fastout, input};
#[fastout]
fn main() {
input! {
s: String,
};
println!(
"{}",
match s.as_str() {
"RRR" => 3,
"RRS" | "SRR" => 2,
"SSS" => 0,
_ => 1,
}
);
}
|
#![recursion_limit = "128"]
#[macro_use]
extern crate combine;
extern crate clap;
mod error;
mod eval;
mod parser;
mod syntax;
mod tc;
use clap::{App, Arg};
use error::*;
use std::fs::File;
use std::io::prelude::*;
use std::process;
fn parse_and_eval(
code: &str,
mem_limit: usize,
reg_limit: usize,
) ->... |
use crate::impl_typesystem;
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum ArrowTypeSystem {
Int32(bool),
Int64(bool),
UInt32(bool),
UInt64(bool),
Float32(bool),
Float64(bool),
Boolean(bool),
... |
use crate::player::*;
use crate::human::*;
pub struct ComputerPlayer {
pub name: String,
hidden_card: u8,
visible_cards_sum: u8,
passed: bool,
}
impl ComputerPlayer {
pub fn new(n: &str) -> Self {
ComputerPlayer {
name: String::from(n),
hidden_card: 0,
v... |
use std::result::Result;
use bytes::{BufMut, BytesMut};
use futures::stream::SplitSink;
use futures::{Sink, SinkExt, StreamExt};
use rsocket_rust::{
error::RSocketError,
frame::Frame,
transport::{Connection, FrameSink, FrameStream},
utils::Writeable,
};
use tokio::net::TcpStream;
use tokio_tungstenite:... |
// This file is part of Substrate.
// Copyright (C) 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 Free S... |
extern crate iron;
extern crate time;
extern crate alpaca_client;
use iron::prelude::*;
use iron::{typemap, AfterMiddleware, BeforeMiddleware};
use time::{OffsetDateTime};
mod trading_strategy;
mod momentum;
mod index_funding_balancing;
struct ResponseTime;
struct Health {
status: String
}
impl typemap::Key fo... |
/// https://www.bilibili.com/video/BV1rK4y1p79j/?spm_id_from=333.788.b_7265636f5f6c697374.2
mod facts;
use datafrog::{Iteration, Relation, RelationLeaper};
use facts::{ Point, Variable_or_field};
fn main() {
let mut iteration = Iteration::new();
// line 1: b= new C();
// line 3: c= new C();
let new: ... |
use libc::{c_char, c_int, c_void};
use munge_sys::{munge_decode, munge_encode, munge_free, munge_strerror, MungeErr};
use std::{
borrow::{Cow, ToOwned},
convert::TryInto,
ffi::{CStr, CString},
ops::Not,
*,
};
#[derive(Debug, Default, Clone, PartialEq, Eq)]
pub struct Credential {
uid: u32,
... |
use crate::util;
use regex::Regex;
use std::collections::HashMap;
use std::collections::VecDeque;
pub fn solve() {
let input_file = "input-day-9.txt";
println!("Day 9 answers");
print!(" first puzzle: ");
let answer1 = solve_file(input_file, 1);
println!("{}", answer1);
print!(" second puzzle:... |
use syn::parse_quote_spanned;
use super::{
FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, WriteContextArgs,
RANGE_0, RANGE_1,
};
use crate::graph::OperatorInstance;
/// > 0 input streams, 1 output stream
///
/// > Arguments: None.
///
/// Emits a single unit `()` at the start of the f... |
fn run() -> std::io::Result<()> {
let cmd = std::env::var("OCAML").unwrap_or("ocaml".to_string());
let output = std::process::Command::new(cmd)
.arg("version.ml")
.arg(std::env::var("OUT_DIR").unwrap())
.output()?;
let output = String::from_utf8(output.stdout).unwrap();
let split... |
// q0070_runclimbing_stairs
struct Solution;
// impl Solution {
// pub fn climb_stairs(n: i32) -> i32 {
// if n == 1 {
// return 1;
// } else if n == 2 {
// return 2;
// } else {
// return Solution::climb_stairs(n - 1) + Solution::climb_stairs(n - 2);
//... |
mod q01dair1q;
fn main () {
q01dair1q::hello();
}
|
mod print; //mod to call the script
fn main() {
print::run(); //script::function
}
|
use ast::Ast;
use ast::lang_result::LangError;
use nom::IResult;
use parser::program;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::OpenOptions;
use std::error::Error;
pub fn read_file_into_ast(filename: String) -> Result<Ast, LangError> {
match OpenOptions::new().read(true).open(&filename) {
... |
// Copyright 2018-2020 argmin 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... |
#[macro_use] extern crate log;
extern crate env_logger;
#[macro_use]
extern crate serde_derive;
extern crate toml;
extern crate gpgme;
extern crate walkdir;
extern crate clipboard;
#[cfg(test)]
extern crate tempfile;
extern crate secstr;
extern crate sha1;
extern crate knock;
mod config;
mod password;
mod gpg;
mod pw... |
#![recursion_limit = "1024"]
// TODO change unsigned ints to signed
extern crate byteorder;
extern crate csv;
#[macro_use]
extern crate error_chain;
pub mod error;
pub mod executor;
pub mod storage;
// TODO this will be deprecated
// Each node only needs to know column types
#[derive(Debug, Clone)]
pub struct Schem... |
use aoc_runner_derive::{aoc, aoc_generator};
use fnv::FnvHashMap;
use itertools::Itertools;
#[aoc_generator(day4)]
fn parse_input_day4(input: &str) -> Result<Vec<FnvHashMap<String, String>>, String> {
Ok(input
.split("\n\n")
.map(|g| {
g.split_whitespace()
.flat_map(|kv|... |
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use super::VersionBinding;
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct PackageWithVersion {
pub name: String,
pub version: String,
pub binding: VersionBinding,
}
impl Packag... |
use holochain_json_api::error::JsonError;
use holochain_persistence_api::{
cas::content::AddressableContent,
eav::{Attribute, EaviQuery, EntityAttributeValueIndex, EntityAttributeValueStorage},
error::PersistenceResult,
reporting::{ReportStorage, StorageReport},
};
use pickledb::{PickleDb, PickleDbDump... |
#![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 ErrorDetails {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
#[s... |
pub mod allocator;
pub mod heap;
use crate::kernel::InitResult;
use x86_64::{VirtAddr, structures::paging::{OffsetPageTable, PageTable}};
use crate::input::{serial_print, serial_println};
pub unsafe fn init(physical_memory_offset: VirtAddr) -> InitResult<OffsetPageTable<'static>> {
let level_4_table = active_leve... |
fn main() {
println!("{} {} {} {} {}", true as u8, false as u8,
'A' as u32, 'à' as u32, '€' as u32);
}
|
//! This crate contains types that are used throughout the SVM project.
//! Whenever a type has a usage that exceeds a local crate then it should be considered a candidate for this crate.
#![deny(missing_docs)]
#![deny(unused)]
#![deny(dead_code)]
#![deny(unreachable_code)]
#![feature(const_type_id)]
#![feature(const_... |
//! Kafka Consumer
//!
//! A simple consumer based on KafkaClient. Accepts an instance of KafkaClient, a group and a
//! topic. Partitions can be specified using builder pattern (Assumes all partitions if not
//! specified).
//!
//! # Example
//!
//! ```no_run
//! let mut client = kafka::client::KafkaClient::new(vec!("... |
use super::*;
use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
#[derive(Clone, Debug, Default)]
pub struct InferenceTable {
pub(super) var_unification_table: InPlaceUnificationTable<TypeVarId>,
}
/// The ID of a type variable.
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct ... |
pub mod graph {
use graph_items::edge::Edge;
use graph_items::node::Node;
use std::collections::HashMap;
type Attrs = HashMap<String, String>;
pub trait Attributes {
fn get_attrs<'a>(&'a mut self) -> &'a mut Attrs;
fn with_attrs(mut self, attrs: &[(&str, &str)]) -> Self
whe... |
//! Slider style
#![allow(clippy::module_name_repetitions)]
use iced::widget::slider::Appearance;
use iced::widget::slider::{Handle, HandleShape, Rail};
use crate::gui::styles::style_constants::{BORDER_ROUNDED_RADIUS, BORDER_WIDTH};
use crate::gui::styles::types::palette::mix_colors;
use crate::{get_colors, StyleTyp... |
fn main() {
let s: String = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end().to_owned()
};
let n: u64 = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
line.trim_end().parse().unwra... |
use std::collections::*;
use std::{self, cmp::Ordering, io};
mod front_of_house;
pub use crate::front_of_house::hosting;
// pub use front_of_house::hosting;
mod back_of_house;
use crate::back_of_house::cooking::Breakfast as boh_breakfast;
use back_of_house::cooking;
mod util;
pub fn eat_at_restaurant() {
// /... |
use crate::network_dialog::{self, NetworkDialog};
use crate::utils::{format_number, format_number_full};
use gtk::glib;
use gtk::prelude::*;
use sysinfo::{NetworkExt, NetworksExt, System, SystemExt};
use std::cell::RefCell;
use std::collections::HashSet;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
fn append_column... |
use actix_web::http::header::HeaderMap;
use crate::error::HeaderError;
use std::str::FromStr;
pub(crate) fn get_header_as<T: FromStr>(
headers: &HeaderMap,
header: &str
) -> Result<T, HeaderError> {
headers.get(header)
.ok_or_else(|| HeaderError::Missing(header.to_owned()))
.and_then(|id| i... |
use super::matcher;
const EMAIL_REGEX: &'static str = r#"(?i)([A-Za-z0-9!#$%&'*+/=?^_{|.}~-]+@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)"#;
const URL_REGEX: &'static str = r#"(?:(?:https?://)?(?:[a-z0-9.\-]+|www|[a-z0-9.\-])[.](?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\))+(?:\((?:[^... |
use neuralnetwork::dataset::{read_csv_by_path};
use neuralnetwork::matrix::MatrixOps;
use neuralnetwork::nn::NeuralNetwork;
fn main() {
// read train data
println!("Reading train data ...");
let (train_label, train_data) = read_csv_by_path("data/mnist_train_100.csv").unwrap();
// read test data
pr... |
// 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 crate::{ProofOptions, TraceInfo};
use math::{log2, StarkField};
use utils::{
collections::Vec, string::ToString, ByteReader, ByteW... |
#[macro_export]
macro_rules! caml_ffi {
($code:tt) => {
let mut caml_frame = $crate::core::state::local_roots();
$code;
return;
};
($code:tt => $result:expr) => {
let mut caml_frame = $crate::core::state::local_roots();
$code;
return $crate::core::mlvalues::V... |
use EventType;
use RawXEvent;
pub struct Event {
pub typ: EventType,
pub event: RawXEvent
}
impl ::std::fmt::Debug for Event {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> {
write!(f, "{:?}{:?}",self.typ,self.event)
}
}
impl From<RawXEvent> for Event {
fn ... |
use crate::color_config::lookup_ansi_color_style;
use nu_ansi_term::{Color, Style};
use nu_protocol::Config;
pub fn get_shape_color(shape: String, conf: &Config) -> Style {
match conf.color_config.get(shape.as_str()) {
Some(int_color) => match int_color.as_string() {
Ok(int_color) => lookup_ans... |
extern crate bytes;
extern crate httparse;
#[macro_use]
extern crate may;
use std::io::{Read, Write};
use bytes::BufMut;
use httparse::Status;
use may::net::TcpListener;
fn req_done(buf: &[u8], path: &mut String) -> Option<usize> {
let mut headers = [httparse::EMPTY_HEADER; 16];
let mut req = httparse::Reque... |
extern crate advent_of_code;
use advent_of_code::day1;
use advent_of_code::input;
use std::str::FromStr;
fn main() {
let input = input::read_file_to_string("input/day1part1");
// Part 1
let mut fuel = 0;
for line in input.lines() {
let mass: usize = usize::from_str(line).unwrap();
fue... |
use specs::Join;
pub struct LifeSystem;
impl<'a> ::specs::System<'a> for LifeSystem {
type SystemData = (
::specs::WriteStorage<'a, ::component::PhysicBody>,
::specs::WriteStorage<'a, ::component::DynamicDraw>,
::specs::WriteStorage<'a, ::component::DynamicEraser>,
::specs::WriteSt... |
mod manager;
mod shim;
pub(crate) use manager::*;
pub(crate) use shim::*;
|
mod git_project;
mod id;
mod project;
mod column;
mod task;
pub use id::*;
pub use git_project::*;
pub use project::*;
pub use column::*;
pub use task::*;
|
#[doc = "Reader of register TICK"]
pub type R = crate::R<u32, super::TICK>;
#[doc = "Writer for register TICK"]
pub type W = crate::W<u32, super::TICK>;
#[doc = "Register TICK `reset()`'s with value 0x0200"]
impl crate::ResetValue for super::TICK {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self... |
#![cfg(feature = "std")]
use tabled::settings::{
locator::ByColumnName,
object::{Columns, Rows, Segment},
Alignment, Modify, Padding, Style,
};
use crate::matrix::Matrix;
use testing_table::test_table;
test_table!(
full_alignment,
Matrix::new(3, 3).with(Style::psql()).with(Modify::new(Segment::al... |
use crate::vector::Vector;
use crate::point::Point;
use crate::game::ColourIndex;
/// A model representing a particle
///
/// Particles are visible objects that have a time to live and move around
/// in a given direction until their time is up. They are spawned when the
/// player or an enemy is killed
pub struct Par... |
// This file is part of Substrate.
// Copyright (C) 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
//
// http://... |
pub const T_EMPTY: u8 = 0;
pub const T_FOOD: u8 = 1;
pub const T_BODY: u8 = 2;
pub const T_HEAD: u8 = 3;
pub const T_CORNER: u8 = 4;
pub const T_TAIL: u8 = 5;
|
fn find_digit(num: i32, nth: i32) -> i32 {
if nth <= 0 {return -1;} let mut num = num.abs(); let mut nth = nth;
loop { if nth == 1 {return num % 10; } num /= 10; nth -= 1; }
}
#[test]
fn test0() {
assert_eq!(find_digit(0, 0), -1);
}
#[test]
fn test1() {
assert_eq!(find_digit(0, 1), 0);
}
#[test]
fn test... |
#![no_main]
#![no_std]
#[allow(unused_extern_crates)]
#[allow(unused_imports)]
use panic_halt;
extern crate embedded_hal;
extern crate stm32f4xx_hal;
use stm32f4xx_hal::block;
use stm32f4xx_hal::serial::{config::Config, Serial};
use cortex_m_rt as rt;
use stm32f4xx_hal as hal;
use hal::prelude::*; // need for the Gp... |
use bytes::{Buf, BufMut, Bytes, BytesMut};
use crate::error::RSocketError;
use crate::utils::Writeable;
const MAX_ROUTING_TAG_LEN: usize = 0xFF;
#[derive(Debug, Clone)]
pub struct RoutingMetadata {
tags: Vec<String>,
}
pub struct RoutingMetadataBuilder {
inner: RoutingMetadata,
}
impl RoutingMetadataBuilde... |
use chrono::naive::NaiveDateTime;
use lazy_static::lazy_static;
use regex::Regex;
use std::str::FromStr;
use super::error;
#[derive(Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Record {
pub timestamp: NaiveDateTime,
pub event: Event,
}
impl FromStr for Record {
type Err = error::ParseRecordError;
... |
mod comment_reader;
mod identifiers_reader;
mod operators_reader;
mod strings_reader;
mod unambiguous_single_chars_reader;
mod whitespace_reader;
pub use self::comment_reader::CommentReader;
pub use self::identifiers_reader::IdentifiersReader;
pub use self::operators_reader::OperatorsReader;
pub use self::strings_rea... |
use mongodb::sync::Client;
use std::env;
use crate::persistence::{Error, Result};
pub fn get_mongo_client() -> Result<Client> {
let mongo_url = match env::var("DATABASE_URL") {
Ok(url) => url,
Err(_) => {
return Err(Error::DatabaseURLNotSet);
}
};
Ok(Client::with_uri_s... |
// Problem 12 - Highly divisible triangular number
//
// The sequence of triangle numbers is generated by adding the natural numbers. So
// the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten
// terms would be:
//
// 1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
//
// Let us list the factors o... |
use crate::utils;
use chrono::{Duration, Utc};
use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation};
use lazy_static::lazy_static;
use scrypt::{errors::CheckError, ScryptParams};
use serde::{Deserialize, Serialize};
use std::{
collections::HashMap,
env,
sync::{Arc, Mutex},
};
use thiserror::Err... |
use amethyst::ecs::{Component, NullStorage};
#[derive(Debug, Default)]
pub struct Mob;
impl Component for Mob {
type Storage = NullStorage<Self>;
}
|
use std::path::PathBuf;
use serde::{Deserialize, Serialize};
use crate::util::random_string;
pub static CONFIG_ENV_PREFIX: &str = "PT_";
/// Available configuration values.
/// These are mapped to SCREAMING_UPPER_CASE environment variables.
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(default)]
pub struc... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.