text stringlengths 8 4.13M |
|---|
use std::borrow::Cow;
use std::error::Error;
use std::fmt;
#[derive(Debug, PartialEq)]
pub struct JustTextError<'a> {
message: Cow<'a, str>,
}
impl<'a> JustTextError<'a> {
pub fn new<S>(message: S) -> Self
where
S: Into<Cow<'a, str>>,
{
JustTextError {
message: message.into... |
// error-pattern:explicit failure
use std;
import std::option::*;
fn foo(s: str) { }
fn main() {
let i = alt some[int](3) { none[int]. { fail } some[int](_) { fail } };
foo(i);
} |
///
/// The general trait to process opcodes.
///
/// ## A NOTE ABOUT CERTAIN OPCODES
/// There are actually 2 different Chip8 specifications which behave differently
/// for certain opcodes. These specifications go by many different names, but
/// here the more popular and well-known will be called the "CowGod" speci... |
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
pub enum FilterMode {
Nearest,
Linear,
}
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
pub struct Filter {
pub min: FilterMode,
pub mag: FilterMode,
pub mipmap: Option<FilterMode>,
}
impl Filter {
pub fn new(min: FilterMode, mag: Filter... |
use rodio::{Decoder, OutputStream, source::Source};
use std::fs::File;
use std::io::BufReader;
// Play specified file on the Primary sound device
pub fn play_ogg(ogg_file:&str){
//Get default sound device
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
//Open .ogg files in th... |
use rocket_include_static_resources::StaticResponse;
pub fn favicon_dir() -> std::string::String {
"src/static_content/favicon.ico".to_string()
}
pub fn index_dir() -> std::string::String {
"src/static_content/index.html".to_string()
}
#[get("/")]
pub fn index() -> StaticResponse {
static_response!("inde... |
//!
//! methods to directly interact with the bdev layer
use clap::{App, AppSettings, Arg, ArgMatches, SubCommand};
use colored_json::prelude::*;
use tonic::Status;
use rpc::mayastor::{BdevShareRequest, BdevUri, CreateReply, Null};
use crate::context::Context;
pub async fn handler(
ctx: Context,
matches: &A... |
use std::str::Chars;
use std::collections::HashMap;
mod file_reader;
#[derive(Debug, PartialEq)]
enum Token {
PLUS(String),
MINUS(String),
NUMBER(String),
IDENTIFIER(String),
MOD(String),
MULTIPLY(String),
LESSTHAN(String),
GREATERTHAN(String),
DOT(String),
COMMA(String),
OP... |
extern crate wast_spec;
use std::path::Path;
use wast_spec::WastContext;
macro_rules! run_wast {
($file:expr, $func_name:ident) => {
#[test]
fn $func_name() {
run_spectest($file)
}
};
}
fn run_spectest(filename: &str) {
let testsuite_dir = Path::new(file!()).parent().un... |
#[derive(Debug)]
pub struct MDatabase{
filename: String,
magic_number: u32,
file_format_id: String,
jet_version: u32,
db_info: Option<DBInfo>,
}
use std::io::Seek;
use std::fs::File;
use std::io::{Read, SeekFrom, Error};
use std::mem::transmute;
impl MDatabase {
pub fn open_database(filename: ... |
use thiserror::Error;
#[derive(Error, Debug)]
pub enum NSError {
#[error("error from the http client")]
HTTPClient(#[from] reqwest::Error),
#[error("error from the deserializer")]
Deserializer(#[from] quick_xml::de::DeError),
}
|
#![allow(non_snake_case)]
use glutin::dpi::PhysicalSize;
use glutin::event::{Event, KeyboardInput, VirtualKeyCode, WindowEvent};
use glutin::event_loop::ControlFlow;
use glutin::event_loop::EventLoop;
use glutin::window::Window;
use glutin::window::WindowBuilder;
use glutin::Api;
use glutin::ContextBuilder;
use glutin:... |
use crate::abst::{Controller, Input, Presenter};
use crate::exp::SyntaxError;
pub struct Console;
fn string_to_tokens(string: &[char]) -> Vec<Input> {
use Input::*;
let mut tokens = vec![];
let mut num_buf = String::new();
for raw_token in string {
if raw_token.is_digit(10) || raw_token == &'.' {
n... |
// Copyright (c) 2018 tomlenv developers
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
/... |
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate clap;
extern crate serde;
extern crate serde_json;
extern crate time;
#[macro_use]
extern crate serde_derive;
pub mod manifest;
pub mod options;
pub mod profiler;
pub mod processor;
pub mod types;
|
use super::Interrupts;
#[derive(Debug)]
pub enum ButtonState {
Up,
Down,
}
#[derive(Debug,Copy,Clone)]
pub enum Button {
Up,
Down,
Left,
Right,
A,
B,
Start,
Select,
}
impl Button {
fn flag(self) -> u8 {
use self::Button::*;
match self {
Right | ... |
// Copyright 2021 Datafuse Labs.
//
// 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 ... |
use amethyst::core::{Transform};
use amethyst::derive::SystemDesc;
use amethyst::ecs::{ReadStorage, System, SystemData, WriteStorage, WriteExpect};
use crate::ball::component::Ball;
use crate::taunt::Taunt;
use amethyst::core::ecs::{Join, Read};
use amethyst::renderer::SpriteRender;
use crate::persistence::Settings;
... |
/// Any password hasher should implement this trait.
///
/// Note that password hashers are the only ones that
/// are able to read a clear text password, so try not
/// to leak any kind of information about it.
///
/// If your hasher can be configured to have different
/// time or memory costs, then make sure to stor... |
use crate::HdbResult;
#[cfg(feature = "sync")]
use byteorder::{LittleEndian, WriteBytesExt};
#[derive(Debug)]
pub struct WriteLobRequest<'a> {
locator_id: u64,
offset: i64,
buf: &'a [u8],
last_data: bool,
}
impl<'a> WriteLobRequest<'a> {
pub fn new(locator_id: u64, offset: i64, buf: &[u8], last_dat... |
wit_bindgen::generate!("sample");
struct SampleHost;
impl Sample for SampleHost {
fn run() {
log(LogLevel::Info, "test log");
}
}
export_sample!(SampleHost);
|
use pyo3::exceptions::PyValueError;
use pyo3::ffi::Py_uintptr_t;
use pyo3::prelude::*;
use polars_core::utils::accumulate_dataframes_vertical;
use polars_core::POOL;
use ukis_h3cellstore::export::polars::export::arrow::datatypes::DataType as ArrowDataType;
use ukis_h3cellstore::export::polars::export::arrow::ffi;
use ... |
use crate::utils::*;
pub(crate) const NAME: &[&str] = &["AsMut"];
pub(crate) fn derive(data: &Data, items: &mut Vec<ItemImpl>) -> Result<()> {
derive_trait!(
data,
parse_quote!(::core::convert::AsMut)?,
parse_quote! {
trait AsMut<__T: ?Sized> {
#[inline]
... |
fn main() {
yew::start_app::<froovie_front::Model>();
}
|
use ggez::graphics;
use ggez::graphics::*;
use specs;
use std::path;
use std::sync::{Arc, RwLock};
use components::*;
use map::*;
use resources::*;
use sprite::*;
use state::*;
use storyboard::*;
use systems::UpdateCharacters;
pub fn create_scene(tilemap_src: &'static str) -> Story {
let tilemap_src = tilemap_sr... |
use lazy_static::lazy_static;
use nalgebra::{Point3, Vector3};
use std::collections::HashMap;
type Face = [Point3<f32>; 3];
#[derive(Clone, Copy, Debug)]
pub struct Triangle {
pub normal: Vector3<f32>,
pub vertices: Face,
}
pub fn to_stl(s: &str) -> Vec<Triangle> {
let mut output = vec![];
for (i, c)... |
use std::cell::Ref;
/// Entry point of Bot
fn main() -> lux_ai::LuxAiResult<()> {
// Initialize Lux AI I/O environment
let mut environment = lux_ai::Environment::new();
// Create agent [lux_ai_api::Agent]
let mut agent = lux_ai::Agent::new(&mut environment)?;
// For every turn
loop {
/... |
use std::env;
use std::process;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use tokio::prelude::*;
use tokio::runtime::Runtime;
use tokio::timer::Interval;
use modio::error::Error;
use modio::filter::prelude::*;
use modio::QueryString;
use modio::{auth::Credentials, Modio};
fn current_timestamp() -> u64 {
... |
// Copyright 2021 Datafuse Labs.
//
// 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 ... |
pub mod rv64i;
|
use serde::{
Serialize,
Serializer
};
use super::helpers::serialize_currency;
////////////////////////////////////////////////////////////////////////////////////////////////////
#[derive(Debug, Serialize)]
pub struct VirtualItem{
pub amount: i32,
pub available_groups: Vec<String>,
pub sku: String... |
use itertools::{IntoChunks, Itertools};
use crate::raw;
use crate::FlannError;
use crate::Indexable;
use crate::Neighbor;
use crate::Parameters;
pub struct SliceIndex<'a, T: Indexable> {
index: raw::flann_index_t,
parameters: raw::FLANNParameters,
rebuild_threshold: f32,
pub(crate) point_len: usize,
... |
//! IOx Compactor Layout tests
//!
//! These tests do almost everything the compactor would do in a
//! production system *except* for reading/writing parquet data.
//!
//! The input to each test is the parquet file layout of a partition.
//!
//! The output is a representation of the steps the compactor chose to
//! ta... |
mod stack;
pub use crate::stack::Stack;
|
use byteorder::{ByteOrder, NetworkEndian};
use std::future::Future;
use thiserror::Error;
use crate::io::*;
use crate::v5::{
SocksV5AddressType, SocksV5Command, SocksV5Host, SocksV5RequestError, SocksV5RequestStatus,
};
use crate::SocksVersion;
/// Writes a SOCKSv5 request with the specified command, host and por... |
use std::collections::HashMap;
use std::convert::TryFrom;
use amethyst::ui::{UiText, UiTransform};
use super::system_prelude::*;
const DIFFICULTY_DESCRIPTION_TRANSFORM_ID: &str =
"label_difficulty_description";
const PREFIX_SELECTION_TRANSFORM_ID: &str = "selection_";
#[derive(Default)]
pub struct MenuSelection... |
//! EVM module types.
use oasis_runtime_sdk::types::{address::Address, token};
/// Transaction body for creating an EVM contract.
#[derive(Clone, Debug, cbor::Encode, cbor::Decode)]
pub struct Create {
pub value: U256,
pub init_code: Vec<u8>,
}
/// Transaction body for calling an EVM contract.
#[derive(Clone,... |
use std::collections::HashMap;
use ahash::RandomState;
use crossfont::{
Error as RasterizerError, FontDesc, FontKey, GlyphKey, Metrics, Rasterize, RasterizedGlyph,
Rasterizer, Size, Slant, Style, Weight,
};
use log::{error, info};
use unicode_width::UnicodeWidthChar;
use crate::config::font::{Font, FontDescri... |
use std::env;
use std::path::PathBuf;
use std::process::Command;
fn main() {
let manifest_dir: PathBuf = env::var("CARGO_MANIFEST_DIR").unwrap().into();
let k12_dir = manifest_dir.join("K12");
let build_dir = k12_dir.join("bin/Haswell");
Command::new("make")
.arg("Haswell/libk12.a")
.cu... |
use std::prelude::v1::*;
use ring::digest;
pub fn double_sha256(data: &[u8]) -> Vec<u8> {
let res = digest::digest(&digest::SHA256, data);
digest::digest(&digest::SHA256, res.as_ref())
.as_ref()
.to_vec()
}
pub fn sha256(data: &[u8]) -> Vec<u8> {
let res = digest::digest(&digest::SHA256, d... |
use crate::device::Context;
use crate::explorer::candidate::Candidate;
use crate::explorer::choice::ActionEx;
use rpds::List;
use serde::Serialize;
/// A Trait defining a structure containing the candidates, meant to explore the
/// search space
pub trait Store: Sync {
/// Transmits the information needed to updat... |
const MEMORY_SIZE: usize = 4096;
type Byte = u8;
type Word = u16;
pub struct Memory {
pub data: [Byte; MEMORY_SIZE],
}
pub fn new_memory() -> Memory {
let font = [
0xF0, 0x90, 0x90, 0x90, 0xF0, // 0
0x20, 0x60, 0x20, 0x20, 0x70, // 1
0xF0, 0x10, 0xF0, 0x80, 0xF0, // 2
0xF0, 0x... |
/// Reset terminal formatting
#[derive(Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Reset;
impl Reset {
/// Render the ANSI code
#[inline]
pub fn render(self) -> impl core::fmt::Display {
ResetDisplay
}
}
struct ResetDisplay;
impl core::fmt::Display for Reset... |
#[doc = "Reader of register IMC"]
pub type R = crate::R<u32, super::IMC>;
#[doc = "Writer for register IMC"]
pub type W = crate::W<u32, super::IMC>;
#[doc = "Register IMC `reset()`'s with value 0"]
impl crate::ResetValue for super::IMC {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
//! # Naia Client
//! A cross-platform client that can send/receive events to/from a server, and
//! has a pool of in-scope actors that are synced with the server.
#![deny(
missing_docs,
missing_debug_implementations,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features,
unu... |
use semver::{Identifier, Version};
use crate::error::FatalError;
static VERSION_ALPHA: &'static str = "alpha";
static VERSION_BETA: &'static str = "beta";
static VERSION_RC: &'static str = "rc";
arg_enum! {
#[derive(Debug, Clone, Copy)]
pub enum BumpLevel {
Major,
Minor,
Patch,
... |
use crate::{
aabb::AABB,
hittable::{HitRecord, HitTable},
ray::Ray,
vec3::Point3,
};
use std::{sync::Arc, vec};
pub struct HitTableList {
pub objects: vec::Vec<Arc<dyn HitTable>>,
}
impl HitTableList {
pub fn new() -> Self {
Self {
objects: vec::Vec::new(),
}
}
... |
/* use std::env;
use std::fs;
fn main() {
let args: Vec<String> = env::args().collect();
let config = Config::new(&args);
println!("Searching for {}", config.query);
println!("In file {}", config.filename);
//use BufReader instead: https://doc.rust-lang.org/1.39.0/std/io/struct.BufReader.htm... |
//! A simple library for *fast* inspection of binary buffers to guess the type of content.
//!
//! This is mainly intended to quickly determine whether a given buffer contains "binary"
//! or "text" data. Programs like `grep` or `git diff` use similar mechanisms to decide whether
//! to treat some files as "binary data... |
use async_std::{io, task};
use futures::{future, prelude::*};
use libp2p::{
Multiaddr,
PeerId,
Swarm,
NetworkBehaviour,
identity,
floodsub::{self, Floodsub, FloodsubEvent},
mdns::{Mdns, MdnsEvent},
swarm::NetworkBehaviourEventProcess
};
use std::{error::Error, task::{Context, Poll}};
fn... |
use crate::intcode::{IntCodeEmulator, YieldReason};
use itertools::Itertools;
use std::collections::VecDeque;
const INPUT: &str = include_str!("../input/2019/day7.txt");
pub fn part1() -> i64 {
let program = IntCodeEmulator::parse_input(INPUT);
let permutations = (0..5).permutations(5);
permutations
... |
use super::{Client, Structure};
use crate::field::{ForeignKey, LineItem};
use chrono::{DateTime, Utc};
use retriever::traits::record::Record;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
#[derive(Debug, Deserialize, Serialize, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct ExpenseReport {
p... |
use std::{
collections::HashMap,
iter::FromIterator,
};
use serde::{
Deserialize,
Serialize,
};
use rnc_core::{
urs::Urs,
urs_taxid::UrsTaxid,
};
use crate::normalize::utils;
use crate::normalize::ds::{
basic::Basic,
cross_reference::{
AccessionVec,
CrossReference,
... |
pub mod bezier;
pub mod ds;
pub mod mesh;
pub mod plane;
pub mod sphere;
pub use bezier::BezierRotate;
pub use mesh::Mesh;
pub use plane::Plane;
pub use sphere::Sphere;
|
pub mod base_project_dependency;
pub mod flatten_project_dependency;
|
pub struct SimpleRnd {
values: [i32; 10],
next: usize,
}
impl SimpleRnd {
pub fn new() -> Self {
SimpleRnd {
values: [1 ,3, 5, 7, 2, 4, 6, 8, 9, 0],
next: 0,
}
}
pub fn next_rnd(&mut self) -> i32 {
self.next = self.next + 1;
if self.next > 9 ... |
use druid::kurbo::{BezPath, Circle, Insets, Point, Rect, Vec2};
use druid::piet::{RenderContext, StrokeStyle};
use druid::{Data, Env, EventCtx, HotKey, KbKey, KeyEvent, MouseEvent, PaintCtx, RawMods};
use crate::edit_session::EditSession;
use crate::mouse::{Drag, Mouse, MouseDelegate, TaggedEvent};
use crate::path::Se... |
use std::{
collections::HashSet,
marker::PhantomData,
};
use crate::{
pack::*,
class::*,
shape::*,
};
#[derive(Clone, Debug, Default)]
pub struct TestShape<T: 'static> {
phantom: PhantomData<T>,
}
impl<T> TestShape<T> {
pub fn new() -> Self {
Self { phantom: PhantomData }
}
}
... |
#[doc = "Reader of register PSSI"]
pub type R = crate::R<u32, super::PSSI>;
#[doc = "Writer for register PSSI"]
pub type W = crate::W<u32, super::PSSI>;
#[doc = "Register PSSI `reset()`'s with value 0"]
impl crate::ResetValue for super::PSSI {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
mod batch_id;
mod block_height;
mod block_time_height;
mod block_timestamp;
mod config;
mod contract_balances;
pub mod contract_state;
mod epoch_height;
mod gas;
mod lock;
mod redeem_stake_batch;
mod redeem_stake_batch_receipt;
mod stake_account;
mod stake_batch;
mod stake_batch_receipt;
mod stake_token_value;
mod stor... |
use blisp::embedded;
use num_bigint::{BigInt, ToBigInt};
#[embedded]
fn test_fun(
_z: BigInt,
_a: Vec<BigInt>,
_b: (BigInt, BigInt),
_c: Option<BigInt>,
_d: Result<BigInt, String>,
) -> Option<BigInt> {
let temp = 5.to_bigint();
temp
}
#[embedded]
fn add_four_ints(a: BigInt, b: (BigInt, Bi... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor 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 ... |
extern crate rand;
use super::{data, Color, RngExt};
/// A description of a treatment for a shield.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(tag = "type")]
pub enum ShieldIconTreatment {
/// A single, solid shield color, aka no treatment.
SingleColor,
/// A treatment that result... |
use nom::combinator::map_opt;
use nom::number::complete::be_u8;
use nom::IResult;
use num_traits::FromPrimitive;
#[derive(Debug, Clone, Eq, PartialEq, Primitive)]
#[repr(u8)]
pub enum DHCPv6MessageType {
Solicit = 1,
Advertise = 2,
Request = 3,
Confirm = 4,
Renew = 5,
Rebind = 6,
Reply = 7,... |
use yew::prelude::*;
use yew_functional::function_component;
#[function_component(User)]
pub fn user() -> Html {
html! {
<>
<div class="clearfix card-user">
<div class="card-avatar-container">
<img class="card-avatar" width="260" height="260" src="https://yuchanns.... |
use crate::graphics::Format;
use crate::graphics::SampleCount;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum LoadOp {
Load,
Clear,
DontCare
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum StoreOp {
Store,
DontCare
}
#[derive(Clone, Copy, PartialEq)]
pub enum ImageLayout {
Unde... |
#[macro_use]
extern crate log;
mod config;
mod connection_handler;
mod request_handler;
mod server;
pub use self::config::Config;
pub use self::request_handler::RequestHandler;
pub use self::server::Server;
|
use super::*;
pub struct Jugada {
pub carta: mazo::Carta,
pub numero_jugador: usize,
pub cartas_restantes: usize,
}
pub struct ResumenRonda {
pub jugadores_puntos: Vec<(usize, f64)>,
pub jugador_suspendido: usize,
pub ultima_ronda: bool
}
// Estado inicial, se crean los jugadores y se repar... |
use super::math::*;
use super::vec3;
use super::collide::*;
#[derive(Default)]
pub struct World {
pub sphere_x: Vec<f32>,
pub sphere_y: Vec<f32>,
pub sphere_z: Vec<f32>,
pub sphere_r: Vec<f32>,
pub sphere_c: Vec<Vec3>,
pub material_ids: Vec<u32>,
}
impl World {
pub fn construct(objects: &[... |
extern crate sdl2;
use sdl2::event::{Event, WindowEvent};
use sdl2::keyboard::{Keycode, Mod};
use sdl2::mouse::MouseButton;
use sdl2::pixels::Color;
use sdl2::pixels::PixelFormatEnum;
use sdl2::rect::{Point, Rect};
use sdl2::render::{Texture, WindowCanvas};
use sdl2::surface::Surface;
extern crate rusttype;
use rustty... |
use proconio::input;
fn main() {
input! {
n: usize,
a: [usize; n],
};
let mut b = vec![false; 4];
let mut p = 0;
for a in a {
assert_eq!(b[0], false);
b[0] = true;
let mut c = vec![false; 4];
for j in 0..=3 {
if b[j] {
if ... |
use rltk::{Algorithm2D, field_of_view, Point};
use specs::prelude::*;
use crate::{IsVisible, Map, Player, Position, Viewshed};
pub struct VisibilitySystem;
impl<'a> System<'a> for VisibilitySystem {
type SystemData = (
WriteExpect<'a, Map>,
Entities<'a>,
WriteStorage<'a, Viewshed>,
... |
fn main(){
// let _s = "Hello World!";
// let _num = 10000;
// println!("{}", 1<4);
// let mut v = Vec::new();
// v.push(1);
// v.push(2);
// v.push(3);
// for i in &v{
// println!("{}", i)
// }
// struct Point {
// x: i32,
// y: i32
// }
// let ... |
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;
fn... |
//! # fn-search-backend-cache
//!
//! Caching the functions found on [packages.elm-lang.org](https://packages.elm-lang.org)
//! is performed with the following algorithm
//!
//! * Download the list of packages on [packages.elm-lang.org](https://packages.elm-lang.org)
//! * Iterate over each repository in parallel
//! ... |
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
/*
Computer the number of times a pattern appears in a text
http://rosalind.info/problems/ba1a/
NOTE: Take care of overlapping. i.e. pattern_count("ATATA", "ATA") == 2
Input file should contain two lines; the first is a text, and the second is a pattern to look for.
*/
extern crate rosalind_rust;
use rosalind_rust::... |
//! EV3 specific features
use std::fs;
use std::path::Path;
use crate::driver::DRIVER_PATH;
use crate::utils::OrErr;
use crate::{Attribute, Ev3Result};
/// Color type.
pub type Color = u8;
/// The led's on top of the EV3 brick.
#[derive(Debug, Clone)]
pub struct Led {
led: Attribute,
}
impl Led {
/// Led o... |
use crate::spec::{Target, TargetOptions};
// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
// for target ABI requirements.
pub fn target() -> Target {
Target {
llvm_target: "aarch64-linux-android".into(),
pointer_width: 64,
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i1... |
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//! Serialization and deserialization of wire formats.
//!
//! This module provides efficient serialization and deserialization of the
//! various wire for... |
#[cfg(any(feature = "embedded-server", feature = "no-server"))]
pub fn main() {
shared();
match std::env::var_os("TAURI_DIST_DIR") {
Some(dist_path) => {
let dist_path_string = dist_path.into_string().unwrap();
println!("cargo:rerun-if-changed={}", dist_path_string);
let inlined_assets = mat... |
//! Hostcall endpoints exposed to guests.
use super::context::EventBuffer;
use crate::wasm::context::RaisedError;
use crate::wasm::WasmModuleConfig;
use crate::Event;
use lucet_runtime::vmctx::Vmctx;
use std::convert::TryInto;
use vector_wasm::Registration;
pub use wrapped_for_ffi::ensure_linked;
// Also add any new f... |
use std::{
fs,
io::{Read, Write},
net::{TcpListener, TcpStream},
thread::{self, sleep},
time::Duration,
};
use hello::ThreadPool;
fn main() {
let listener = TcpListener::bind("127.0.0.1:7878").unwrap();
let pool = ThreadPool::new(3);
for stream in listener.incoming().take(7) {
... |
// This sub-crate exists to make sure that everything works well with the `no_alloc` flag enabled
use core::fmt::Write;
use humansize::{SizeFormatter, DECIMAL};
struct Buffer<const N: usize>([u8; N], usize);
impl<const N: usize> Write for Buffer<N> {
fn write_str(&mut self, s: &str) -> core::fmt::Result {
... |
use piston_window::*;
pub type Point = [f64; 2];
pub type Color = [f32; 4];
#[derive(Copy, Clone, Debug)]
pub struct Rect {
pub origin: Point,
pub size: Point
}
pub trait Widget {
fn layout(&mut self, bounds: Rect);
fn get_bounds(&self) -> Rect;
fn add_child(&mut self, child: Box<Widget>);... |
use na::{DVector, DMatrix};
use rand::distributions::{Normal, IndependentSample};
use rand::thread_rng;
use kalmanfilter::systems::continuous_to_discrete;
use kalmanfilter::nt;
use super::types::*;
pub struct ContinuousLinearModelBuilder {
pub vec_x_init : SystemState,
pub mat_a : ContinuousSystemMatrix,
... |
use lex::Lex;
use lex::Token;
use std::iter::Peekable;
use std::result;
type Result<T> = result::Result<T, String>;
#[derive(Debug)]
pub struct Invocation {
command: Invocable,
expression: Vec<Token>,
}
#[derive(Debug)]
pub struct Invocable {
token: Token,
}
pub struct Parse<'a> {
token_stream: Peek... |
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000000007;
fn main() {
let (n, m): (usize, usize) = parse_line().unwrap();
let mut aa: Vec<isize> = parse_line().unwrap();
let mut bb: Vec<isize> = parse_line().un... |
mod test_env;
use rustcommon::redisaccessor_async;
use tokio;
use log::kv::Source;
fn get_redis_client_test<'a>() -> redisaccessor_async::RedisAccessorAsync<'a> {
let get_default = || redisaccessor_async::RedisAccessorAsync::new()
.host("localhost")
.port(6379)
.passwd("")
.db(0);... |
extern crate chrono;
use chrono::{DateTime, TimeZone, Duration};
const GIGASECOND: i64 = 1_000_000_000;
pub fn after<T: TimeZone>(datetime: DateTime<T>) -> DateTime<T> {
datetime + Duration::seconds(GIGASECOND)
}
|
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - RNG control register"]
pub rng_cr: RNG_CR,
#[doc = "0x04 - RNG status register"]
pub rng_sr: RNG_SR,
#[doc = "0x08 - The RNG_DR register is a read-only register that delivers a 32-bit random value when read. The content... |
use std::error;
use std::fmt;
use std::fmt::Debug;
#[derive(Clone)]
#[repr(C)]
pub struct RootEntry {
pub filename: [u8; 8],
pub extension: [u8; 3],
attrs: u8,
reserved: u16,
pub creation_time: u16,
pub creation_date: u16,
pub last_access_date: u16,
pub hi_first_lcluster: u16,
pub ... |
use serde_json;
pub use serde_json::Value;
pub use self::grammar::{expression, ParseError};
//# format_string := <text> [ format <text> ] *
// format := '{' [ argument ] [ ':' format_spec ] '}'
// argument := integer | identifier
//
// format_spec := [[fill]align][sign]['#'][0][width]['.' precision][type]
// fill := ... |
pub mod cloud;
pub mod device;
pub mod emeter;
pub mod sys;
pub mod sysinfo;
pub mod time;
pub mod wlan;
|
// render_system.rs
//
// Copyright (c) 2019, Univerisity of Minnesota
//
// Author: Bridger Herman (herma582@umn.edu)
//! Renders with WebGL, using wasm-bindgen and web-sys
use std::usize;
use wasm_bindgen::prelude::JsValue;
use wasm_bindgen::JsCast;
use web_sys::WebGl2RenderingContext;
use crate::frame_buffer::Fr... |
use rand::rngs::SmallRng;
use rand::{Rng, SeedableRng};
fn roll2die<T: Rng>(mut rng: T) -> (i32, i32) {
let first_roll = rng.gen_range(1, 7);
let second_roll = rng.gen_range(1, 7);
(first_roll, second_roll)
}
fn main() {
let mut thread_rng = SmallRng::seed_from_u64(1);
let mut string = String::with_... |
pub mod base_types;
pub mod core_state;
pub mod core_types;
pub mod crypto;
pub mod driver;
pub mod mempool;
pub mod messages;
pub mod net;
#[macro_use]
extern crate serde_big_array;
big_array! { BigArray; }
#[macro_use]
extern crate failure;
fn main() {
println!("Hello, world!");
}
|
use std::borrow::Cow;
use anyhow::Context;
use pathfinder_common::StarknetVersion;
pub const COMPILER_VERSION: &str = env!("SIERRA_CASM_COMPILER_VERSION");
/// Compile a Sierra class definition into CASM.
///
/// The class representation expected by the compiler doesn't match the representation used
/// by the feede... |
use std::io;
fn main() {
println!("Enter 1st Number = ");
let mut a = String::new();
io::stdin().read_line(&mut a);
let a:f32 = a.trim().parse().unwrap();
println!("Enter 2nd Number = " );
let mut b = String::new();
io::stdin().read_line(&mut b);
let b:f32 = b.trim().parse().unwrap... |
#[cfg(test)]
#[macro_use]
extern crate approx; // For the macro relative_eq!
extern crate nalgebra as na;
extern crate float_cmp as flcmp;
extern crate num;
extern crate num_traits as numt;
extern crate uuid;
extern crate rand;
pub mod defs;
pub mod tools;
pub mod core;
pub mod basic;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.