text stringlengths 8 4.13M |
|---|
use nettu_scheduler_api::Application;
use nettu_scheduler_infra::{setup_context, Config, NettuContext};
use nettu_scheduler_sdk::NettuSDK;
pub struct TestApp {
pub config: Config,
pub ctx: NettuContext,
}
// Launch the application as a background task
pub async fn spawn_app() -> (TestApp, NettuSDK, String) {
... |
#[doc = "Register `DO5` reader"]
pub struct R(crate::R<DO5_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<DO5_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<DO5_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<DO5_SPEC>) ... |
extern crate neon;
fn common_prefix_length(word: &str, previous: &str) -> Option<usize> {
return word
.chars()
.zip(previous.chars())
.position(|(a, b)| a != b);
}
|
use ipnet::{Ipv4Net, Ipv6Net};
use itertools::Itertools;
use std::net::{Ipv4Addr, Ipv6Addr};
use crate::{GatewayMapping, Ipv4Route, Ipv6Route};
struct Node {
children: [Option<Box<Node>>; 2],
color: usize,
num_routes: Vec<usize>,
decision: Vec<Option<usize>>,
}
impl Node {
fn new(colors: usize) -... |
use env_logger;
use failure::Error;
use futures::future::Future;
use lapin_futures_native_tls::{AMQPConnectionNativeTlsExt, lapin};
use lapin::channel::ConfirmSelectOptions;
use tokio;
fn main() {
env_logger::init();
tokio::run(
"amqps://user:pass@host/vhost?heartbeat=10".connect_cancellable(|err| {
... |
use std::collections::{BTreeMap};
use crate::imp::rust_to_json::rust_value_to_json_value::rust_value_to_json_value;
use crate::imp::structs::rust_value::RustValue;
use crate::imp::structs::my_json::Value;
pub fn value_map_to_json(map : &BTreeMap<String, RustValue>) -> BTreeMap<String, Value>{
let mut result = BTre... |
#[aoc_generator(day16)]
fn parse_input(input: &str) -> (Vec<Field>, Vec<Vec<u32>>) {
let mut groups = input.split("\n\n");
if let Some(fields) = groups.next() {
let fields: Vec<Field> = fields.lines().map(|l| Field::new(l)).collect();
if let Some(tics) = groups.nth(1) {
let tickets: ... |
/**
* [19] Remove Nth Node From End of List
*
* Given a linked list, remove the n-th node from the end of list and return its head.
*
* Example:
*
*
* Given linked list: 1->2->3->4->5, and n = 2.
*
* After removing the second node from the end, the linked list becomes 1->2->3->5.
*
*
* Note:
*
* Given n ... |
// Post will handle its state internally. All the post stuff should be in lib.rs.
// But this is for note-taking purposes only. The state design pattern is useful
// for removing tons of `match`s but if we want to add a new state, then we'd have
// rewrite some state transitions. Also, there's a lot of duplicate code, ... |
#[doc = "Register `INTF` reader"]
pub struct R(crate::R<INTF_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<INTF_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<INTF_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R<INTF_SP... |
extern crate maple_core;
pub mod prelude {
pub use maple_core::prelude::*;
pub use maple_macro::view;
pub use maple_stdui::*;
pub use maple_stdweb::*;
}
|
// Copyright 2021 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// https://opensource.org/licenses/MIT> or the Modified BSD license <LICENSE-BSD
// https://opensource.org/licenses/BSD-3-Clause>, at your option. This file may not be copied,
// modified, or d... |
mod sync_utils;
use nimiq_primitives::policy::Policy;
use nimiq_test_log::test;
use crate::sync_utils::{sync_two_peers, SyncMode};
#[test(tokio::test)]
async fn two_peers_can_sync_empty_chain() {
sync_two_peers(0, 1, SyncMode::Full).await
}
#[test(tokio::test)]
async fn two_peers_can_sync_single_batch() {
s... |
// This file is part of Substrate.
// Copyright (C) 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 Softwa... |
// Copyright 2020 WHTCORPS INC. Licensed under Apache-2.0.
use engine_lmdb::raw::Cone;
use engine_lmdb::util::get_causet_handle;
use edb::{MiscExt, Causet_WRITE};
use tuplespaceInstanton::{data_key, DATA_MAX_KEY};
use std::sync::mpsc;
use std::sync::Mutex;
use std::time::Duration;
use test_violetabftstore::*;
use edb:... |
// #[macro_use]
extern crate log;
use simplelog::*;
use clap::load_yaml;
use clap::App;
mod push;
mod server;
mod shell;
fn main() {
CombinedLogger::init(vec![
TermLogger::new(LevelFilter::Debug, Config::default()).unwrap()
])
.unwrap();
let yaml = load_yaml!("cli.yml");
let matches = App::from_yaml(... |
use rustc_middle::mir;
use rustc_target::spec::abi::Abi;
use log::trace;
use crate::helpers::check_arg_count;
use crate::shims::windows::handle::{EvalContextExt as _, Handle, PseudoHandle};
use crate::shims::windows::sync::EvalContextExt as _;
use crate::*;
#[derive(Debug, Copy, Clone)]
pub enum Dlsym {
SetThrea... |
struct Solution;
impl Solution {
fn camel_match(queries: Vec<String>, pattern: String) -> Vec<bool> {
queries
.into_iter()
.map(|query| Self::query_match(query.chars().collect(), pattern.chars().collect()))
.collect()
}
fn query_match(query: Vec<char>, pattern: ... |
static SAMPLE: &[usize] = &[3, 8, 9, 1, 2, 5, 4, 6, 7];
static INPUT: &[usize] = &[2, 8, 4, 5, 7, 3, 9, 6, 1];
fn main() {
let mut cups: Vec<usize> = INPUT.into();
let part_1_solution = solve(cups.clone(), 100);
let part_1 = part_1_solution
.iter()
.cycle()
.skip_while(|n| **n != ... |
// This file contains code from external sources.
// Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md
//! Memory management for executable code.
use crate::unwind::UnwindRegistry;
use std::mem::ManuallyDrop;
use std::sync::Arc;
use std::{cmp, mem};
use wasmer_compiler::{CompiledFunctionUnwi... |
use std::cmp::Ordering;
use std::f32::consts::{FRAC_PI_2, PI};
use std::ops::Sub;
type Int = i16;
#[derive(Debug, Eq, Hash, Clone, Copy)]
pub struct Point {
pub x: Int,
pub y: Int,
}
fn gcd(a: Int, b: Int) -> Int {
return if b == 0 { a } else { gcd(b, a % b) };
}
impl Point {
pub fn normalize(&self)... |
use bellman::pairing::{
Engine,
};
use bellman::{
SynthesisError,
ConstraintSystem,
};
use bellman::pairing::ff::{
Field,
PrimeField,
};
use bellman::redshift::domains::*;
use common::num::*;
use common::boolean::*;
use common::log2_floor;
use std::iter;
pub struct FriUtilsGadget<E: Engine> {
... |
use erdos::dataflow::{stream::IngestStream, Message, Stream};
use pyo3::{exceptions, prelude::*};
use crate::{PyMessage, PyStream};
/// The internal Python abstraction over an `IngestStream`.
///
/// This class is exposed on the Python interface as `erdos.streams.IngestStream`.
#[pyclass(extends=PyStream)]
pub struct... |
pub trait ParseTree
{
fn children(& mut self) -> Option<&mut Vec<Box<dyn ParseTree>>>;
fn children_const(& self) -> Option<&Vec<Box<dyn ParseTree>>>;
fn text(&self) -> String;
}
pub struct TerminalNode
{
pub token: Token
}
impl ParseTree for TerminalNode
{
fn children(& mut self) -> Option<&mut Vec<Box<dyn Pars... |
use std::collections::HashSet;
use rug::Integer;
pub fn solve() -> usize {
let mut s: HashSet<Integer> = HashSet::new();
for a in 2..=100 {
for b in 2..=100 {
s.insert(Integer::from(Integer::u_pow_u(a, b)));
}
}
s.len()
}
|
// TODO: Consider to move MetaHandler to its own crate
// TODO: Make $HOME static
use anyhow::Error;
use hana_types::Metadata;
use regex::Regex;
use sha1::{Digest, Sha1};
use std::collections::HashMap;
use std::env;
use std::fs;
use std::io;
use std::io::prelude::*;
pub struct MetaHandler;
impl MetaHandler {
pub fn... |
//! This module handles accumulating / re-arranging comments for the Rust AST.
//!
//! The only way we have found to have comments inserted into the pretty-printed Rust output is via
//! a comment vector. The Rust pretty-printer accepts a vector of comments and, before printing
//! any AST node, it dumps out the prefix... |
#![feature(proc_macro, conservative_impl_trait, generators)]
extern crate futures_await as futures;
use futures::stream::Stream;
extern crate unbase;
use unbase::{Network,SubjectHandle};
use std::{thread,time};
/// This example is a rudimentary interaction between two remote nodes
/// As of the time of this writing,... |
pub mod product;
pub mod storage;
pub mod user;
|
use super::SignedUserTransaction;
use std::ops::Deref;
type BlockNumber = u64;
/// Transaction activation condition.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Condition {
/// Valid at this block number or later.
Number(BlockNumber),
/// Valid at this unix time or later.
Timestamp(u64),
}
/// Qu... |
use std::cell::*;
use std::rc::*;
use std::mem;
use piston_window::*;
use opengl_graphics::{ GlGraphics };
use cgmath::{ Vector2 };
use cgmath::InnerSpace;
use std::fmt::*;
use std::*;
pub struct MyRectangle {
pub position: Vector2<f64>,
pub width: f64,
pub height: f64
}
impl Display for MyRectangle {
... |
use std::path::PathBuf;
use crc32fast::Hasher;
use std::io::{Read, Write, BufWriter};
pub struct FileToZip {
last_mod_time: u16,
last_mod_date: u16,
crc32: Option<u32>,
size: Option<u64>,
file_name: String,
source: Option<Box<dyn Read>>,
offset_of_fh: u64,
}
use chrono::{Datelike, Timelike... |
mod iter;
mod util;
pub use iter::*;
pub use util::*;
#[cfg(test)]
mod tests {
use crate::IndexSplitter;
#[test]
fn it_works() {
let array = (0..20).map(|it| it + 1).collect::<Vec<_>>();
println!("Array: {:?}", array);
let indexes = [5, 10, 15];
println!("Indexes: {:?}", indexes);
let split... |
use std::env;
use std::fmt;
use std::io;
use std::process;
use std::fs;
use std::io::{Read, Write};
fn main() {
let (src, dst) = match get_src_dst(env::args()) {
Ok((src, dst)) => (src, dst),
Err(e) => {
println!("{}", e);
process::exit(0);
}
};
let mut i_f... |
#[doc = "Register `CHCTL2` reader"]
pub struct R(crate::R<CHCTL2_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<CHCTL2_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<CHCTL2_SPEC>> for R {
#[inline(always)]
fn from(reader: crate::R... |
use std::sync::Arc;
struct Sentence;
struct TextReader;
struct SentenceBatch {
size: usize,
batch_size: usize,
input_name: String,
reader: Arc<TextReader>,
sentences: Vec<Arc<Sentence>>,
}
impl SentenceBatch {
/*
SentenceBatch(int batch_size, string input_name)
: batch_size_(batc... |
pub struct Coordinate {
horizontal: i32,
depth: i32,
}
impl Coordinate {
pub fn new() -> Self {
Self { horizontal: 0, depth: 0 }
}
pub fn forwards(&mut self, steps: i32) {
self.horizontal += steps;
}
pub fn up(&mut self, steps: i32) {
self.depth -= steps;
}
p... |
//use std::cmp::*;
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::*;
// scanner from https://codeforces.com/contest/1396/submission/91365784
struct Scanner {
stdin: Stdin,
buffer: VecDeque<String>,
}
#[allow(dead_code)]
impl Scanner {
fn new() -> Self {
... |
use std::fmt::Debug;
use std::collections::{HashMap, HashSet, VecDeque};
use itertools::Itertools;
use std::array::IntoIter;
const RAW_INPUT_STR: &str = include_str!("../../inputs/day20.txt");
pub fn day20() -> impl Debug {
let maze = parse_input(RAW_INPUT_STR);
(part1(&maze), part2(&maze))
}
pub fn part1(m... |
#![deny(warnings)]
use core::{
cmp::Ordering,
fmt::{self, Write as _},
};
use std::collections::BTreeMap;
use binfmt::{Level, Tag};
/// Log message
pub struct Message<'f> {
pub level: Level,
pub timestamp: Timestamp,
pub footprint: &'f str,
pub args: Vec<Node<'f>>,
}
#[derive(Clone, Copy, Eq... |
//! Filters
use ndarray::prelude::*;
use ndarray::stack;
/// Dummy 'filter' that returns unmodified input as 'prediction'
pub struct FilterAutoEcho {}
/// Trait for autoregressive adaptive filters
pub trait FilterAuto {
fn predict_next(&mut self, x: &Array1<f64>) -> Array1<f64>;
}
impl FilterAuto for FilterAu... |
//!
//! Provides types for representing scenes, including:
//! * The [`Mesh`](trait.Mesh.html) trait for types that represent triangle meshes,
//! * The [`Material`](struct.Material.html) and [`MaterialBuilder`](struct.MaterialBuilder.html) types for OBJ-compatible materials,
//! * [`Entity`](struct.Entity.html) as a s... |
//@compile-flags: -Zmiri-disable-weak-memory-emulation -Zmiri-preemption-rate=0 -Zmiri-disable-stacked-borrows
#![feature(new_uninit)]
use std::ptr::null_mut;
use std::sync::atomic::{AtomicPtr, Ordering};
use std::thread::spawn;
#[derive(Copy, Clone)]
struct EvilSend<T>(pub T);
unsafe impl<T> Send for EvilSend<T> {}... |
use json5_parser::JVal;
use super::names::Names;
use super::json_name::{json_name, NameType, SystemNames};
use super::json_item_to_rust::json_item_to_rust;
use crate::error::Result;
use crate::imp::json_to_rust::tmp::tmp_obj::TmpObj;
use crate::imp::json_to_rust::get_old::get_old;
use crate::imp::json_to_rust::get_id:... |
use anyhow::{anyhow, bail, Result};
use image::DynamicImage;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
#[derive(Debug)]
pub struct NewImage {
pub path: PathBuf,
pub filename: String,
pub image: DynamicImage,
}
impl NewImage {
pub fn parse(f: PathBuf) -> Result<NewImage> {... |
pub use internal::vm::{Call, Arguments, Module, Throw, Result, JS};
|
use std::{path::Path, process::Command};
pub use anyhow::*;
pub use log::*;
#[cfg(feature = "logger")]
use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
/// Initialize a terminal logger with color support.
#[cfg(feature = "logger")]
pub fn init_logger() {
TermLogger::init(
... |
fn add(x:f32,y:f32)->(f32,f32,f32,f32){
(x+y,x-y,x*y,x/y)
}
fn main() {
let Add = add(2.0,6.0).0;//this is for addition
let sub = add(2.0,6.0).1;
let mult = add(2.0,6.0).2;
let div = add(2.0,6.0).3;
println!("addition is {:?}",Add);
println!("subtraction is {:?}",sub);... |
pub mod text {
//! # Scene Text Detection and Recognition
//!
//! The opencv_text module provides different algorithms for text detection and recognition in natural
//! scene images.
//! # Scene Text Detection
//!
//! Class-specific Extremal Regions for Scene Text Detection
//! ----------------------------... |
// Copyright (c) 2018 libeither developers
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copie... |
use std::fmt::Display;
pub mod str;
pub mod slice;
pub mod error;
#[derive(Clone)]
pub enum RuleResult<T> {
Matched(usize, T),
Failed,
}
pub trait Parse {
type PositionRepr: Display;
fn start<'input>(&'input self) -> usize;
fn position_repr<'input>(&'input self, p: usize) -> Self::PositionRepr;
}... |
mod arguments;
mod scan;
use std::env;
use std::process;
use std::sync::mpsc::channel;
use std::thread;
use arguments::Arguments;
use scan::scan;
const MAX_PORT: u16 = 65535;
fn main() {
let args: Vec<String> = env::args().collect();
let program = args[0].clone();
let arguments = Arguments::new(&args).u... |
use std::fmt;
use std::fmt::Write;
use protobuf_support::text_format::quote_bytes_to;
use crate::message_dyn::MessageDyn;
use crate::reflect::MessageRef;
use crate::reflect::ReflectFieldRef;
use crate::reflect::ReflectValueRef;
use crate::UnknownValueRef;
fn print_str_to(s: &str, buf: &mut String) {
// TODO: kee... |
pub mod breadboard_builder;
pub mod graphics;
pub mod modules;
pub mod shareable;
pub mod state;
use modules::*;
|
fn main() {
let buffer = std::fs::read_to_string("input/modules").unwrap();
let result: i64 = buffer
.lines()
.map(|l| l.parse::<i64>().unwrap())
.map(get_fuel_for_mass)
.sum();
println!("{}", result);
}
fn get_fuel_for_mass(mass: i64) -> i64 {
match mass {
x i... |
use std::{thread, time::Duration};
use erdos::{
dataflow::{
context::SinkContext,
operator::{Sink, Source},
operators::{Filter, Join, Map, Split},
state::TimeVersionedState,
stream::{WriteStream, WriteStreamT},
Message, OperatorConfig, Timestamp,
},
node::Nod... |
// This file is part of 50shades.
//
// Copyright 2019 Communicatio.Systems GmbH
//
// 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
//
//... |
#[allow(unused_imports)]
use tracing::{info, error, warn, debug};
use async_trait::async_trait;
use serde::{Serialize, de::DeserializeOwned};
use bytes::Bytes;
use std::future::Future;
use std::marker::PhantomData;
use std::sync::Arc;
use tokio::sync::Mutex;
use crate::spec::SerializationFormat;
use crate::error::*;
... |
// SPDX-License-Identifier: Apache-2.0
#[derive(Default)]
#[repr(C, align(16))]
pub struct Context([usize; 10]);
impl Context {
#[naked]
#[inline(never)]
pub extern "C" fn wipe() {
unsafe {
asm!(
"xor rax, rax",
"xor rcx, rcx",
"x... |
#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "alloc")]
extern crate alloc;
use core::future::Future;
use emit_core::extent::ToExtent;
use crate::local_frame::{LocalFrame, LocalFrameFuture};
#[doc(inline)]
pub use emit_macros::*;
#[doc(inline)]
pub use emit_core::{
clock, ctxt, emitter, empty, ev... |
use std::collections::HashSet;
fn main() {}
struct Solution;
impl Solution {
pub fn intersection(nums1: Vec<i32>, nums2: Vec<i32>) -> Vec<i32> {
let mut nums1 = nums1;
let mut nums2 = nums2;
let mut nums = Vec::new();
nums1.sort();
nums2.sort();
let mut i = 0;
... |
#![feature(asm)]
#![feature(global_asm)]
#![no_main]
#![no_std]
mod bsp;
mod cpu;
mod panicwait;
|
use crate::bot;
use async_std::{os::unix::net, prelude::*, task};
use kosmos::{
client,
utils::*,
xeno::client::{XenoClient, XenoHandler},
};
use telegram_types::bot::types;
use yukikaze::{Ask, Request};
/// kosmos to tg
#[derive(Copy, Clone)]
pub(crate) struct KosmosHandler {}
#[async_trait::async_trait]... |
//! Serial interface loopback test
//!
//! You have to short the TX and RX pins to make this program work
#![no_main]
#![no_std]
use panic_halt as _;
use cortex_m_rt::entry;
use stm32f1xx_hal::{
pac,
pac::interrupt,
pac::USART1,
prelude::*,
serial::{Rx, Serial, Tx},
};
static mut RX: Option<Rx<U... |
#[macro_use]
extern crate serde;
#[macro_use]
extern crate log;
#[macro_use]
extern crate thiserror;
extern crate simple_logger;
use hmac::{Hmac, NewMac};
use jwt::{SignWithKey, VerifyWithKey};
use lambda_runtime::{handler_fn, Context};
use rusoto_core::Region;
use rusoto_dynamodb::{AttributeValue, DynamoDb, DynamoDbC... |
use std::f32::consts::PI;
use crate::{
math::interpolate,
noise::{self, NoiseSource},
noise_gen::NoiseGenerator,
};
pub struct Glottis {
pub always_voice: bool,
pub auto_wobble: bool,
is_touched: bool,
pub target_tenseness: f32,
pub target_frequency: f32,
pub vibrato_amount: f32,
... |
// This file is part of Substrate.
// Copyright (C) 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 Softwa... |
//! Lower-level types and re-exports.
//!
//! Most users will not have to interact with the types in this module, but it is useful for those
//! writing extractors, middleware, libraries, or interacting with the service API directly.
pub use crate::config::{AppConfig, AppService};
#[doc(hidden)]
pub use crate::handler... |
use alt_serde::{Serializer, Deserializer, Deserialize};
use sp_std::str::{FromStr};
use sp_std::prelude::*;
use frame_support::{debug};
use alt_serde::de::{Error, Visitor, SeqAccess};
use hex::{encode, decode};
use ethabi::{Address, Hash};
use core::{fmt, fmt::Formatter};
// SERIALIZERS
pub fn ser_u32_to_hex<S>(valu... |
// This file is part of Substrate.
// Copyright (C) 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 Softwa... |
//! [Raft]アルゴリズムに基づく分散複製ログを提供するクレート.
//!
//! このクレート自体は、アルゴリズム実装のみに専念しており、
//! 実際に動作するシステムで利用するためには、`Io`トレイトの
//! 実装を別個用意する必要がある.
//!
//! [Raft]: https://raft.github.io/
#![warn(missing_docs)]
#[cfg(test)]
extern crate fibers;
#[macro_use]
extern crate trackable;
pub use crate::error::{Error, ErrorKind};
pub use crate:... |
// Copyright 2020 WHTCORPS INC
//
// 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, sof... |
/// Determine whether a sentence is a pangram.
pub fn is_pangram(sentence: &str) -> bool {
let lowercase = sentence.to_ascii_lowercase();
('a'..='z').all(|c| lowercase.contains(c))
}
|
// Claxon -- A FLAC decoding library in Rust
// Copyright 2017 Ruud van Asseldonk
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// A copy of the License has been included in the root of the repository.
// This file contains a m... |
use super::{DataFormat, DisplayError, WriteCommand, WriteOnlyDataCommand};
use packed_struct::{
derive::{PackedStruct, PrimitiveEnum_u8},
types::{bits::Bits11, Integer},
PackedStruct,
};
#[derive(PrimitiveEnum_u8, Clone, Copy, Debug, PartialEq)]
pub enum ZeroInLines {
NormalInBoth = 0b00,
ZeroInOdd... |
#[doc = "Reader of register WF63TO60"]
pub type R = crate::R<u32, super::WF63TO60>;
#[doc = "Writer for register WF63TO60"]
pub type W = crate::W<u32, super::WF63TO60>;
#[doc = "Register WF63TO60 `reset()`'s with value 0"]
impl crate::ResetValue for super::WF63TO60 {
type Type = u32;
#[inline(always)]
fn re... |
use sh::asm::{self, Instruction};
use crate::{
general, instructiontype::InstructionType, system, traits::Debugger, Display, Exception, Input,
Memory,
};
/// Emulates the CPU of the Calculator
pub struct CPU {
/// The Address of the Instruction that will be executed next (apart from the queud instruction)... |
use std::thread;
//Rust version of threads
fn main()
{
let _threadboi = thread::spawn(||
{
for i in 1..10
{
println!("{}",i)
}
}
);
let _threadboithesequel = thread::spawn(||
{
for i in 1..10
{
... |
use patricia_router::Router;
#[test]
fn single_node() {
let mut router = Router::<&str>::new();
router.add("/about", "about");
assert_eq!(router.find("/about").key(), "/about");
assert_eq!(router.find("/products").key(), "");
}
#[test]
fn key_and_path_matches() {
let mut router = Router::<&str>::n... |
/// This script prints an input/output prompt with the number of the
/// evaluation prefixed to it
/// Generated module that have accessible global variables
/// See its signature for more info
mod types;
use types::GlobalVariables;
use std::{ffi::CString, os::raw::c_char};
#[no_mangle]
// the signature must be this... |
use std::{cmp, fs};
fn main() {
let p1 = part1("./input", 2503);
let p2 = part2("./input", 2503);
println!("Part 1: {}", p1);
println!("Part 2: {}", p2);
}
fn part1(path: &str, duration: u32) -> u32 {
let input = fs::read_to_string(path).unwrap();
let mut reindeers = parse_input(&input);
... |
use anyhow::{
ensure,
Result,
};
use core::cell::Ref;
use super::*;
use iota_streams_core::sponge::prp::PRP;
use iota_streams_ddml::{
command::{
sizeof,
wrap,
},
link_store::LinkStore,
types::*,
};
/// Message context prepared for wrapping.
pub struct PreparedMessage<'a, F, Lin... |
use crate::core::size::Size;
use winit::window::Window;
use crate::graphics::transformation::Transformation;
use crate::graphics::Renderer;
pub struct Target {
surface: wgpu::Surface,
size: Size,
transformation: Transformation,
swap_chain: wgpu::SwapChain,
}
impl Target {
pub fn new(window: &Windo... |
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct MappingUsersRulesRuleOptionsExtended {
/// If true, and the rule was applied successfully, stop processing further.
#[serde(rename = "break")]
pub _break: Option<bool>,
///
#[serde(rename = "default_... |
pub mod callable;
pub mod lexicalvarstorage;
pub mod lispvalue;
|
use std::env;
use serde_json::{Value};
use serde::{Deserialize, Serialize};
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Root {
#[serde(rename = "Pagination")]
pub pagination: Pagination,
#[serde(rename = "Results")]
pub results: Vec<... |
use std::fmt;
enum Direction { Up, Down, Left, Right }
#[derive(Debug, Eq)]
struct State { board: [[u32; 4]; 4], score: u32 }
impl PartialEq for State {
fn eq(&self, other: &State) -> bool { self.board == other.board && self.score == other.score }
}
impl fmt::Display for State {
fn fmt(&self, f: &mut fmt::F... |
// Copyright 2006 The Android Open Source Project
// Copyright 2020 Yevhenii Reizner
//
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use alloc::vec::Vec;
use crate::path_builder::PathBuilder;
use crate::transform::Transform;
use crate::{Point, Rect};
/// A p... |
use cptool::workspace::Workspace;
use std::collections::HashMap;
use std::path::PathBuf;
fn main() {
let mut w = Workspace {
path: PathBuf::from("/home/peng/cplib/src/lib.rs"),
components: HashMap::new(),
};
w.components.insert("s".into(), vec![]);
let s = toml::to_string(&w).unwrap();... |
//! [Multicast DNS](https://en.wikipedia.org/wiki/Multicast_DNS) library with built-in networking.
//!
//! This crate can be used to discover mDNS devices that are listening
//! on a network.
//!
//! # Basic usage
//!
//! This example finds all [Chromecast](https://en.wikipedia.org/wiki/Chromecast) devices on the
//! s... |
use std::collections::{LinkedList, HashMap};
use std::io::Read;
use std::time::{Duration, SystemTime};
use std::thread::sleep;
use std::sync::mpsc::Sender;
use std::path::Path;
use std::fs::File;
use common::{AudioType, AudioPacket, AudioUpdate};
use hound::{Sample, WavReader};
pub mod mp3;
pub mod wav;
pub trait Son... |
// Copyright 2018 Grove Enterprises 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 ... |
use crate::namespace::{Namespace, Namespaces};
use crate::rust_core;
use crate::value::{ToValue, Value};
use crate::Symbol;
use crate::repl;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
// @TODO lookup naming convention
/// Inner value of our environment
/// See Environment for overall purp... |
#![feature(untagged_unions)]
use sanitizeable::{sanitizeable, Sanitizeable};
#[sanitizeable(
private_name = "Theft",
public_name = "Product",
container_name = "ProductContainer",
union_name = "_ProductUnion", // You probably only want to use this if the automatic name causes conflicts
)]
#[derive(Clon... |
#![feature(async_closure)]
mod commands;
mod config;
mod debug;
mod room_buffer;
mod server;
use std::cell::{Ref, RefCell, RefMut};
use std::collections::HashMap;
use std::rc::Rc;
use tracing_subscriber;
use weechat::{weechat_plugin, ArgsWeechat, Weechat, WeechatPlugin};
use crate::commands::Commands;
use crate::co... |
use bevy::prelude::*;
use bevy::app::AppExit;
use rand::Rng;
const G: f32 = 0.0000000000667430;
fn main() {
let matches = clap::App::new("bevy_balls")
.version("1.0")
.author("James Bell")
.about("N body simulation experiment for class")
.arg(clap::Arg::with_name("room_size")
... |
// node-bindings
#[macro_use] extern crate neon;
extern crate glutin;
extern crate gleam;
extern crate webrender;
extern crate app_units;
extern crate serde;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
#[macro_use] extern crate log;
extern crate env_logger;
mod window;
mod resources;
use neon::pr... |
use std::io;
use std::io::prelude::*;
fn toints(s: String) -> Vec<i32> {
s.chars().map(|d| d as i32 - '0' as i32).collect()
}
fn mkrecipes(xs: &Vec<i32>, elf1: usize, elf2: usize) -> Vec<i32> {
toints((xs[elf1] + xs[elf2]).to_string())
}
fn main() {
let stdin = io::stdin();
let input = stdin.lock()
... |
#![feature(clamp)]
mod force_directed_graph;
mod utils;
use crate::utils::{arena, document, get_arena_bounds, window, middle};
use cfg_if::cfg_if;
use js_sys::Array;
use lazy_static::lazy_static;
use std::sync::{
atomic::{AtomicU64, Ordering},
Mutex,
};
use specs::{World, WorldExt};
use wasm_bindgen::prelud... |
/// parser_validation.rs
///
/// Simple tests for the validation phase
use super::*;
#[test]
fn test_correct_struct_instance() {
Tester::new_single_source_expect_ok(
"single field",
"
struct Foo { s32 a }
func bar(s32 arg) -> Foo { return Foo{ a: arg }; }
"
);
Test... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.