text stringlengths 8 4.13M |
|---|
use hyper::{service::service_fn, Error, Response, Body, Client, Request, Server, Uri, service::make_service_fn};
use std::net::SocketAddr;
async fn serve_req(req: Request<Body>) -> Result<Response<Body>, hyper::Error> {
println!("Got request at {:?}", req.uri());
//Ok(Response::new(Body::from("hello, world!"))... |
//! A scrapper module intended to work together with the `ThreadPool`'s workers.
//!
//! Scrapes the page for needed data and returns it back to the main thread.
use crate::{ScrapeData, ScrapeParam};
use reqwest::Url;
use select::document::Document;
use select::predicate::{Element, Name, Predicate};
use snailquote::une... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use ocaml::{caml, Str, Value};
// Unix.file_descr -> sharedmem_base_address -> string -> int = "get_gconst"
// Send an RPC request over... |
// 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... |
pub mod cpu;
pub mod instructions;
pub mod memory;
pub mod utils;
pub type CpuResult<T> = Result<T, CpuPanic>;
pub use cpu::*;
pub use instructions::*;
pub use memory::*;
pub use utils::*;
|
use proc_macro2::*;
use quote::*;
use syn::*;
pub fn derive(input: &DeriveInput) -> TokenStream {
let DeriveInput {
ident,
data,
generics,
..
} = input;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
let fields = match get_fields(data) {
... |
//! This module contains things that aren't really part of the gba
//! but are part of the emulator. e.g. the debug module should actually be in
//! here but it's temporary until I can start using a better UI library so
//! it gets to stay where it is for now.
pub mod settings;
use ::util::sync_unsafe_cell::SyncUnsaf... |
mod vec_operation;
use vec_operation::*;
fn main() {
let my_vec = vec![5, 3, 7, 9, 1, 11, 25, 5, 11, 11];
for elem in &my_vec { print!("{} ", elem);}
println!("");
println!("Mean: {}", calculate_mean(&my_vec));
for elem in &my_vec { print!("{} ", elem);}
println!("");
println!("Median:... |
use anyhow::Result;
use chrono::{DateTime, Utc};
use diesel::{
r2d2::{ConnectionManager, Pool},
SqliteConnection,
};
use tokio::{
sync::{
mpsc::{Receiver, Sender},
Mutex,
},
task::JoinHandle,
};
use crate::{
config::Config,
database::{entity::IndexState, index_state::IndexSt... |
#![feature(proc_macro_hygiene)]
extern crate config;
extern crate dirs;
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate log;
extern crate env_logger;
mod bar;
mod keyboard;
mod layout_manager;
mod oscillator;
mod setting;
mod utils;
use clap::App;
use config::Config;
use config:... |
#[macro_use]
extern crate lazy_static;
use regex::Regex;
struct Node {
x: u8,
y: u8,
size: u32,
used: u32,
avail: u32,
usep: u8,
marker: Option<char>,
}
impl std::fmt::Display for Node {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
if let Some(m) = self.marker {
write!(f, "{}", m)
}... |
import front.ast;
import front.ast.ident;
import front.ast.def;
import front.ast.ann;
import driver.session;
import util.common.span;
import std.map.hashmap;
import std.list.list;
import std.list.nil;
import std.list.cons;
import std.option;
import std.option.some;
import std.option.none;
import std._str;
import std._v... |
use crate::{
core::expr::{Expr, Primitive, RcExpr},
syntax::ast::Literal,
};
use super::Desugarer;
/// Desugarer literal
///
/// Required by disembedding and standard desugaring
pub fn desugar_literal(desugarer: &mut Desugarer, lit: &Literal) -> RcExpr {
match lit {
Literal::Sym(s, v) => RcExpr::f... |
use memory::Memory;
use rom::Mirroring;
use std::rc::Rc;
use std::cell::RefCell;
pub struct Vram {
rom: Rc<RefCell<Box<Memory>>>,
memory: Vec<u8>, // regular 2kb ram
palette_memory: Vec<u8>, // memory for palettes, 32 bytes
mirroring: Mirroring,
}
impl Vram {
pub fn new(mirroring: Mirroring, rom:... |
pub mod big_step_evaluator;
pub mod evaluator;
mod lexer;
pub mod parser;
pub use evaluator::eval;
pub use parser::parse;
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Term {
True,
False,
If(Box<Term>, Box<Term>, Box<Term>),
Zero,
Succ(Box<Term>),
Pred(Box<Term>),
IsZero(Box<Term>),
}
p... |
use futures::stream::{FuturesUnordered, StreamExt};
use std::any::type_name;
use std::path::{Path, PathBuf};
use tokio::fs::DirEntry;
use tracing::error;
pub async fn scan_for_files(path: impl AsRef<Path>) -> anyhow::Result<Vec<DirEntry>> {
let dir_entries = tokio::fs::read_dir(path).await?;
let files_in_fold... |
use serde::{Serialize, Deserialize};
use serde_json::{self, Value, Deserializer};
use crate::nn::variables::{Variables, VarStore};
use crate::nn::linear::Linear;
use crate::nn::sequential::Sequential;
use crate::nn::module::Module;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use std::collections::HashM... |
use qrcode_generator::QrCodeEcc;
use url::Url;
type SvgCode = String;
// &format!("https://{}.monetashi.io", anode)
pub fn generate(url: &str) -> SvgCode {
qrcode_generator::to_svg_to_string(url, QrCodeEcc::Low, 400, None).unwrap()
}
pub fn generate_url(name: &str, url: &str, source: &str) -> String {
let an... |
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Subscribe {
pub action: String,
pub address_prefixes: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct BlockChainEvent {
pub block_id: String,
pub block_num: String,
pub previous_block_id: String,
pub state_chan... |
use std::slice::from_raw_parts;
use ffi_toolkit::{raw_ptr, rust_str_to_c_str};
use filecoin_proofs as api_fns;
use filecoin_proofs::types as api_types;
use libc;
use once_cell::sync::OnceCell;
use crate::helpers;
use crate::responses::*;
use storage_proofs::sector::SectorId;
/// Verifies the output of seal.
///
#[no... |
pub static GUPPYBOT_SERVICE: &'static [u8] = include_bytes!("../../build/guppybot.service");
pub static SYSROOT_TAR_GZ: &'static [u8] = include_bytes!("../../build/sysroot.tar.gz");
|
pub(crate) mod main;
pub(crate) mod alloc; |
use bevy::prelude::*;
use crate::assets::FontAssets;
use super::GameState;
#[derive(Debug, Default, Clone, Copy)]
pub struct Score(u64);
impl Score {
pub fn increment(&mut self) {
self.0 += 1;
}
pub fn reset(&mut self) {
self.0 = 0;
}
}
impl Into<String> for Score {
fn into(self) -> String {
... |
use crate::bytecode::block::*;
use crate::bytecode::instructions::*;
use crate::runtime::object::Function;
use std::collections::{BTreeSet, HashMap, HashSet};
pub fn simplify_cfg(code: &mut Vec<BasicBlock>) {
if code.len() == 0 {
return;
}
let n_basic_blocks = code.len();
let mut out_edges: Vec<... |
pub mod cgroups;
pub mod thread;
mod parsers; |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::account_address::AccountAddress;
use crate::block_metadata::BlockMetadata;
use crate::genesis_config::{ChainId, ConsensusStrategy};
use crate::language_storage::CORE_CODE_ADDRESS;
use crate::transaction::SignedUserTransac... |
use std::hash as stdhash;
use std::marker::{Sized, PhantomData};
use byteorder::{ByteOrder, LittleEndian, BigEndian};
/**
* The Hasher trait specifies an interface common to hash functions, such as SHA-1 and the SHA-2
* family of hash functions.
*/
pub trait Hasher: Sized {
// TODO Make this a fixed struct ins... |
mod column;
mod ping;
mod query;
mod quit;
mod row;
pub(crate) use column::{ColumnDefinition, ColumnFlags, ColumnType};
pub(crate) use ping::Ping;
pub(crate) use query::Query;
pub(crate) use quit::Quit;
pub(crate) use row::TextRow;
|
use crate::live::{LiveAgent, RequestEvt, Requirement, ResponseEvt};
use std::collections::HashSet;
use yew::{Bridge, Bridged, Component, ComponentLink, Html, Properties, Renderable, ShouldRender};
pub type Reqs = Option<HashSet<Requirement>>;
pub type View<T> = Html<WidgetModel<T>>;
pub trait Widget: Sized + 'static ... |
// Project Euler: Problem 19
fn main() {
let d = Date::new(0, 0, 1900);
let sundays_on_the_first: usize = (1901i64..2001)
.map(|year| {
(0u64..12)
.filter(|&month| {
let dd = d.until(Date::new(0, month, year));
dd % 7 == 6
... |
mod app;
mod components;
mod db;
mod system;
mod systems;
use crate::app::App;
use crate::db::Database;
use crate::system::System;
use crate::systems::collision::CollisionSystem;
use crate::systems::gravity::GravitySystem;
use crate::systems::movement::MovementSystem;
use anyhow::Result;
use minifb::{Window, WindowOp... |
#[macro_use] extern crate chiisai;
extern crate hyper;
extern crate futures;
// Imports traits and the rexported hyper and futures crates
use chiisai::*;
use futures::future::ok;
fn main() {
let server = Chiisai::new()
// We define routes here with parameters here.
... |
#[macro_use] extern crate nickel;
use nickel::{Nickel, HttpRouter};
use nickel::hyper::method::Method;
mod routes;
fn main() {
let mut server = Nickel::new();
server.get("/", middleware!({format!("{}", routes::hello("index"))}));
server.get("/hello", middleware!({format!("{}", routes::hello("world"))}))... |
// Copyright 2020 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under the MIT license <LICENSE-MIT
// http://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 di... |
use crate::address::{Address, Url, Protocol};
use crate::commands::{Command, CommandReceiver as CommandRx};
use crate::conns::BytesSender;
use crate::errors;
use crate::events::{Event, EventPublisher as EventPub, EventSubscriber as EventSub};
use crate::tcp;
use crate::utils;
use async_std::task::{self, spawn};
use as... |
extern crate minesweeper;
use minesweeper::annotate;
fn remove_annotations(board: &[&str]) -> Vec<String> {
board.iter().map(|r| remove_annotations_in_row(r)).collect()
}
fn remove_annotations_in_row(row: &str) -> String {
row.chars()
.map(|ch| match ch {
'*' => '*',
_ => ' ',... |
pub fn run() {
println!("{}", std::i32::MAX);
println!("{}", true && true);
println!("{}", 'A');
println!("{}", '\u{1F600}');
}
|
// Generated file, please don't edit manually.
impl BatchCommandsRequest {
pub fn new_() -> BatchCommandsRequest {
::std::default::Default::default()
}
#[inline]
pub fn clear_requests(&mut self) {
self.requests.clear();
}
#[inline]
pub fn set_requests(&mut self, v: ::std::ve... |
use serde::{Deserialize, Serialize};
use std::env;
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
use std::path::{Path, PathBuf};
#[derive(Debug, Deserialize, Serialize)]
#[serde(default)]
pub struct Config {
pub max_depth_search: usize,
pub ignored_folders: Option<Vec<String>>,
... |
mod color;
pub struct Color {
red: u8,
green: u8,
blue: u8,
alpha: u8
}
#[derive(Clone)]
pub enum Cell {
Empty,
Food,
Head,
Tail
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum GameState {
Over,
Playing
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Direction... |
use std::cell::RefCell;
use ynab_api::apis;
use ynab_api::models;
use args::*;
use types::*;
type YnabClient =
apis::client::APIClient<::hyper_tls::HttpsConnector<hyper::client::HttpConnector>>;
struct CoreAndClient {
core: tokio_core::reactor::Core,
client: YnabClient,
}
//@@@ RENAME?
pub struct YnabSt... |
use ark_crypto_primitives::sponge::poseidon::{PoseidonConfig, PoseidonDefaultConfigEntry};
use ark_mnt6_753::Fq;
use super::{create_parameters, DefaultPoseidonParameters};
// Parameters have been generated using the reference implementation here: https://extgit.iaik.tugraz.at/krypto/hadeshash/-/blob/master/code/gener... |
// Copyright © 2019 mozias-api 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,
... |
use base64::Engine;
use regex::Regex;
use std::io;
use log::{debug, error};
use actix::prelude::Addr;
use actix::Actor;
use actix_web::http::header::HeaderValue;
use actix_web::web::Data;
use actix_web::*;
use awc::Client;
use hmac::{Hmac, Mac};
use sha2::Sha256;
use lazy_static::lazy_static;
use std::sync::Arc;
... |
// This file is part of Substrate.
// Copyright (C) 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://www.a... |
struct Solution;
impl Solution {
fn array_nesting(nums: Vec<i32>) -> i32 {
let mut res = 0;
let n = nums.len();
let mut visited = vec![false; n];
for i in 0..n {
if visited[i] {
continue;
}
let mut j = i;
let mut length... |
use std::fs;
fn main() {
let content = fs::read_to_string("input.txt").unwrap();
let trimmed = content.trim();
let ops: Vec<usize> = trimmed
.split(",")
.map(|s| s.parse::<usize>().unwrap())
.collect();
println!("first {}", first(&ops));
println!("second {}", second(&ops))... |
use FuncTracked;
use LibUnsafe;
use std::rc::Rc;
/// A pointer to a shared function which uses non-atomic ref-counting to avoid outliving its library.
pub type FuncRc<T> = FuncTracked<T, Rc<LibUnsafe>>;
|
use super::app::App;
use super::async_executor;
use super::editor::Keypress;
use super::imgui_support;
use super::ui_toolkit::{Color, SelectableItem, UiToolkit};
use nfd;
use crate::colorscheme;
use crate::ui_toolkit::{
ChildRegionFrameStyle, ChildRegionHeight, ChildRegionStyle, ChildRegionTopPadding,
ChildReg... |
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Node<'a> {
/// unique identifier
id: String,
/// offset for the weight of the node when a next node is added
offset: i32,
/// value to compute the shortest path : distance or running time
value: i32,
/// next nodes
next: ... |
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::io::{BufReader, BufWriter};
use std::path::PathBuf;
use std::iter::Iterator;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
struct Opt {
// The number of occurrences of the `v/verbose` flag
/// Verbose mode (-v, -vv, -vvv, etc.)
#[st... |
pub mod prime {
use std::iter;
/// Extracts all f-ness is n
/// e.g. extract all evenness in n by passing `(n, 2)`
fn extract(n: &mut u64, f: u64) -> u32 {
let mut count = 0;
while *n % f == 0 {
*n /= f;
count += 1;
}
count
}
// Basic Idea is to iterate over (2..=n), test for c... |
pub const CONFIGURE_HOST: &str = "127.0.0.1";
pub const CONFIGURE_PORT: u16 = 8062;
pub const CHATWHEEL_ALL_PATH: &str = "./data/chatwheel.json";
pub const CHATWHEEL_CONF_PATH: &str = "chatwheel.json";
pub const CHATWHEEL_CONF_AUDIO_PATH: &str = "audio";
pub const CHATHWHEEL_PIPE_PATH: &str = "/tmp/chatwheel-rs.input";... |
use crate::{
commands::GlobalOpts,
utils::{git, target::Target, user},
};
use anyhow::{ensure, Result};
use std::fs;
use structopt::StructOpt;
#[derive(StructOpt, Debug)]
pub struct Move {
/// The source to move
#[structopt(name = "SOURCE")]
source: Target,
/// The destination to move the sour... |
#![cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
use rvemu_core::bus::DRAM_BASE;
wasm_bindgen_test_configure!(run_in_browser);
const DEFAULT_SP: i64 = 1048000 + 0x8000_0000;
#[wasm_bindgen_test]
pub fn fcvtls_rd_rs1_rs2() {
let mut emu = Emulator::new();
let mut bus = rvemu_core::bus::Bus::new();
... |
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use cosmwasm_std::{CanonicalAddr, HumanAddr, StdResult, Storage};
use cosmwasm_storage::{
bucket, bucket_read, singleton, singleton_read, Bucket, ReadonlyBucket, ReadonlySingleton,
Singleton,
};
pub static CONFIG_KEY: &[u8] = b"config";
pub static... |
#[repr(C)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Luid {
low_part: u32,
high_part: i32,
}
impl Luid {
pub fn as_i64(&self) -> i64 {
(self.low_part as i64) | (self.high_part as i64) << 32
}
}
impl std::fmt::Debug for Luid {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt:... |
use crate::{
global::Global, instance::InstanceInner, memory::Memory, module::ExportIndex,
module::ModuleInner, table::Table, types::FuncSig, vm,
};
use hashbrown::hash_map;
use std::sync::Arc;
#[derive(Debug, Copy, Clone)]
pub enum Context {
External(*mut vm::Ctx),
Internal,
}
#[derive(Debug, Clone)]... |
// Copyright 2020 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 generators;
pub mod str_util;
mod gen_util;
mod generator;
mod setting;
mod writer;
pub use generator::*;
pub use setting::*;
pub use writer::*;
|
pub mod connection;
mod decoder;
mod objchildren;
mod objdef;
mod execiter;
mod sql;
#[cfg(test)]
mod tests;
use self::connection::{connect, Connection, SqlState, SqlStateClass, Oid};
use self::objchildren::children_query;
use self::objdef::definition_query;
use self::execiter::PgExecIter;
use self::sql::{quote_ident... |
use ockam::{Context, Result};
#[ockam_node_test_attribute::node]
async fn main(mut ctx: Context) -> Result<()> {
ctx.stop().await
}
|
use crate::{active_obj::activeobj, class_type::classtype, obj_def_type::objdeftype};
#[derive(Copy, Clone)]
pub struct objtype {
pub active: bool,
pub class: classtype,
pub x: u8,
pub y: u8,
pub stage: u8,
pub delay: u8,
pub dir: u16,
pub hp: i8,
pub oldx: u8,
pub oldy: u8,
... |
use std::io::prelude::*;
use std::net::TcpStream;
use std::result::Result;
use std::time::Duration;
pub struct Connector {
server: String,
port : u32,
channel : String,
nick: String,
pass: String,
}
impl Connector{
pub fn new(sserver : &str, sport : u32, schannel: &str, snick : &str, spass :&str) -> Self {
Co... |
use anomaly::{BoxError, Context};
use thiserror::Error;
use crate::ics24_host::error::ValidationKind;
pub type Error = anomaly::Error<Kind>;
#[derive(Clone, Debug, Error)]
pub enum Kind {
#[error("invalid trusting period")]
InvalidTrustingPeriod,
#[error("invalid unbonding period")]
InvalidUnboundin... |
use intcode::Program;
use std::collections::HashMap;
use std::env;
use std::fmt;
use std::io;
#[derive(Eq, PartialEq)]
enum Tile {
EMPTY,
WALL,
BLOCK,
PADDLE,
BALL,
}
pub struct Game {
program: Program,
screen: HashMap<(i128, i128), Tile>,
pub score: i128,
interactive: bool,
pa... |
use chargrid::app;
use chargrid::decorator::*;
use chargrid::input::{keys, Input, KeyboardInput};
use chargrid::menu::*;
use chargrid::render::*;
use chargrid::text::*;
use rand::Rng;
use std::collections::VecDeque;
use std::time::Duration;
use tetris::{Input as TetrisInput, Meta, PieceType, Tetris};
const BLANK_FOREG... |
extern crate chrono;
#[macro_use]
extern crate structopt;
#[macro_use]
extern crate serde_derive;
extern crate csv;
extern crate xml;
use std::fs::File;
use std::io::{BufReader, Read};
use std::path::PathBuf;
use std::error::Error;
use structopt::StructOpt;
use chrono::prelude::*;
use xml::reader::{EventReader, Xm... |
// Copyright (c) 2017-present PyO3 Project and Contributors
//! This crate declares only the proc macro attributes, as a crate defining proc macro attributes
//! must not contain any other public items.
#![cfg_attr(docsrs, feature(doc_cfg))]
extern crate proc_macro;
use proc_macro::TokenStream;
use pyo3_macros_backen... |
use std::fmt::Display;
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() {
x
} else {
y
}
}
struct ImportantExcerpt<'a> {
part: &'a str,
}
fn longest_with_an_announcement<'a, T> (
x: &'a str,
y: &'a str,
ann: T,
) -> &'a str
where
T: Display,
{
... |
use qd_nat::{Equiv, Nat};
fn accepts_pair<N1: Nat, N2: Nat>(n1: N1, n2: N2, _proof: Equiv<N1, N2>) {
assert_eq!(n1.as_usize(), n2.as_usize()); // never fails
}
#[test]
fn checked() {
use qd_nat::with_n;
let n = with_n!(N::from_usize(1).unwrap());
let n1 = with_n!(N::from_usize(1).unwrap());
let n... |
use std::sync::atomic::*;
use std::sync::Arc;
use futures::channel::mpsc;
use futures::{FutureExt, SinkExt, StreamExt, TryFutureExt};
use grpcio::{self, *};
use ekvproto::backup::*;
use security::{check_common_name, SecurityManager};
use violetabftstore::interlock::::worker::*;
use super::Task;
/// Service handles t... |
mod serialize;
use rect::Rect;
/// Handle to a dock
#[derive(Debug, PartialEq, Clone, Copy)]
pub struct DockHandle(pub u64);
/// Holds information about the plugin view, data and handle
#[derive(Debug, Clone)]
pub struct Dock {
pub handle: DockHandle,
pub plugin_name: String,
pub plugin_data: Option<Vec<... |
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate 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 Software Foundation, either version 3 of the License, or
// (at your option) a... |
use matrix;
use matrix::MatrixErr;
fn main() {
let m = matrix::Matrix::new(3,3,vec![1,2,3,4,5,6,7,8,9]).unwrap();
println!("m:Matrix<i32> = {}",m);
let n = matrix::Matrix::new(3,3,vec![1.1,2.2,3.3,4.4,5.5,6.6,7.7,8.8,9.9]).unwrap();
println!("n:Matrix<f64> = {}",n);
println!("{}", MatrixErr:... |
// FEngineLoop::Tick(FEngineLoop *__hidden this)
// _ZN11FEngineLoop4TickEv
#[cfg(unix)]
pub const FENGINELOOP_TICK_AFTER_UPDATETIME: usize = 0x1905D98;
#[cfg(windows)]
pub const FENGINELOOP_TICK_AFTER_UPDATETIME: usize = 0xe8bcc;
#[cfg(unix)]
pub const GMALLOC: usize = 0x58d8e20;
// FApp::DeltaTime
// static variabl... |
fn main(){
use std::io::stdin;
use std::collections::HashMap;
let mut phonebook: HashMap<String, String> = HashMap::new();
let mut input: Vec<String> = Vec::new();
let mut buffer = String::new();
let _ = stdin().read_line(&mut buffer);
buffer.clear();
while stdin().read_line(&m... |
use super::expression::{ExpressionNode, Expression};
use super::declaration::{DeclarationKind, DeclarationNode};
use super::{NodeTrivia, SourceLocation, Node};
use super::super::QuoteKind;
#[derive(Debug, PartialEq, Clone)]
pub struct ImportTrivia {
pub declaration_prefix: String,
pub as_prefix: String,
pu... |
// Copyright 2019 Conflux Foundation. All rights reserved.
// Conflux is free software and distributed under GNU General Public License.
// See http://www.gnu.org/licenses/
mod impls;
#[cfg(test)]
mod test_treap;
mod account_cache;
mod garbage_collector;
mod nonce_pool;
mod transaction_pool_inner;
extern crate rand... |
extern crate arrayvec;
extern crate buffer;
extern crate common;
extern crate gamenet_common;
extern crate packer;
extern crate uuid;
extern crate warn;
pub mod enums;
pub mod msg;
pub mod snap_obj;
pub use gamenet_common::error;
pub use gamenet_common::error::Error;
pub use snap_obj::SnapObj;
|
extern crate datafrog;
extern crate disjoint_sets;
use crate::common::{Triple, URI};
use crate::index::URIIndex;
use datafrog::Iteration;
use disjoint_sets::UnionFind;
use std::collections::HashMap;
pub struct DisjointSets {
lists: HashMap<URI, Vec<URI>>,
uri2idx: HashMap<URI, usize>,
idx2uri: Vec<URI>,
... |
use crate::{app_context::bins, guards::range_header::RangeFromHeader};
use rocket::http::{Header, Status};
use rocket::request::Request;
use rocket::response::{self, Redirect, Responder};
use rocket::Response;
use std::fs::File;
use std::io::prelude::*;
use std::io::SeekFrom;
use std::path::PathBuf;
pub struct StreamR... |
// Time: O(1)
// Space: O(1)
pub struct Solution1 {}
impl Solution1 {
pub fn get_sum(mut a: i32, mut b: i32) -> i32 {
while b != 0 {
let carry = a & b;
a ^= b;
b = carry << 1;
}
a
}
}
// pub struct Solution2 {}
// impl Solution2 {
// pub fn get_... |
extern crate regex;
extern crate bytes;
extern crate futures;
extern crate tokio_io;
extern crate tokio_proto;
extern crate tokio_service;
use model::{ResponseStatusCode,RelpResponse, RelpSyslogMessage, SyslogCommand};
//use relp::codec;
use std::str::FromStr;
use std::io;
use std::str;
use bytes::BytesMut;
use toki... |
use rayon::prelude::*;
use fnv::FnvHashMap;
use crate::{
handle::Handle,
packed::{self, *},
packedgraph::index::list,
pathhandlegraph::*,
};
use crate::handlegraph::IntoSequences;
use super::{defragment::Defragment, OneBasedIndex, RecordIndex};
pub(crate) mod packedpath;
pub(crate) mod properties;
... |
use std::env;
use std::process;
use groovemaster5000::instrument;
use groovemaster5000::note_sheet;
use groovemaster5000::picked_string;
use groovemaster5000::player;
use groovemaster5000::sound;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
eprintln!("ERROR: no infil... |
use byteorder::{ReadBytesExt, BE};
use super::*;
pub trait ReadType<'a, R> {
type Output;
type Context;
fn read(reader: &mut Reader<'_, R>, context: &'a Self::Context) -> Result<Self::Output>;
}
pub struct ReadContext<'a> {
pub constants: &'a [Constant],
}
#[derive(Copy, Clone)]
pub struct NullCont... |
use plastic_core::{
nes_controller::{StandardNESControllerState, StandardNESKey},
nes_display::{Color as NESColor, TV_HEIGHT, TV_WIDTH},
BackendEvent, UiEvent, UiProvider,
};
use std::collections::HashSet;
use std::io;
use std::sync::{
mpsc::{Receiver, Sender},
Arc, Mutex,
};
use std::thread;
use st... |
#![cfg_attr(not(test), no_std)]
#![feature(generic_associated_types)]
#![allow(incomplete_features)]
mod bit_twiddling;
mod bounds;
mod commands;
pub mod display;
mod gpio16bit_interface;
pub use bounds::Bounds;
use commands::{CommandCode, CommandData};
use core::fmt::Debug;
use core::{cmp::min, convert::TryFrom, op... |
#[doc = "Reader of register FDCR"]
pub type R = crate::R<u32, super::FDCR>;
#[doc = "Writer for register FDCR"]
pub type W = crate::W<u32, super::FDCR>;
#[doc = "Register FDCR `reset()`'s with value 0"]
impl crate::ResetValue for super::FDCR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
use metrics;
mod errno;
pub mod process;
pub mod tls_config_reload;
pub use self::errno::Errno;
|
use worker::{Response, Result};
pub(crate) trait Service {
fn error(message: &str, status_code: u16) -> Result<Response>;
fn help() -> Result<Response>
where
Self: Sized;
///
/// A service can be created with an optional body (generally, anything that requires something
/// like an ar... |
//シーザー暗号に変換する関数
fn encrypt(text: &str, shift: i16) -> String {
let code_a = 'A' as i16;
let code_z = 'Z' as i16;
let mut result = String::new();
for ch in text.chars() {
let mut code = ch as i16;
if code_a <= code && code <= code_z {
code = (code - code_a + shift + 26) ... |
#[macro_export]
/// Macro for sending on a Tx until it does not return an `TxError::InvalidTx`.
macro_rules! tx_send {
($create:expr; $($arg:expr),*) => {{
let mut result = Err(TxError::InvalidTx);
while let Err(TxError::InvalidTx) = result {
let mut tx = $create();
result = ... |
#![warn(
missing_docs,
future_incompatible,
missing_debug_implementations,
rust_2018_idioms
)]
//! Deltastepping applications
///
/// Copyright (c) 2020, Institute for Defense Analyses
/// 4850 Mark Center Drive, Alexandria, VA 22311-1882; 703-845-2500
///
/// All rights reserved.
///
/// This file is ... |
use utils::print_mat;
fn main() {
let input = "babab";
tricky(input.chars().collect());
dp(input.chars().collect());
}
fn tricky(strs: Vec<char>) {
let mut result = &strs[0..1];
for i in 0..strs.len() {
let a = expand(&strs, i, i);
result = if result.len() < a.len() { a } else { r... |
/*
The cube, 41063625 (345^3), can be permuted to produce two other cubes: 56623104 (384^3) and 66430125 (405^3). In fact,
41063625 is the smallest cube which has exactly three permutations of its digits which are also cube.
Find the smallest cube for which exactly five permutations of its digits are cube.
*/
use co... |
use super::super::super::ArmCpu;
use super::super::super::alu::*;
fn dataproc_imm_operands(cpu: &ArmCpu, instr: u32) -> (u32, u32) {
let _rm = cpu.rget(instr & 0xf);
let shift_amt = (instr >> 7) & 0x1f;
(_rm, shift_amt)
}
fn dataproc_reg_operands(cpu: &ArmCpu, instr: u32) -> (u32, u32) {
let rm = instr & 0xf;
//... |
use super::todo_item::*;
use reqwest::blocking::*;
pub trait DataManager {
fn list(&self) -> Vec<TodoItem>;
fn create(&self, todo: String) -> TodoItem;
fn remove(&mut self, todo: TodoItem);
fn mark(&self, todo: &mut TodoItem, complete: bool);
}
pub struct RemoteDataManager {
pub base_url: String,
... |
pub use super::config;
use bson;
use bson::oid::ObjectId;
use bson::Document;
use mongodb::{Client, ThreadedClient};
use mongodb::db::ThreadedDatabase;
use mongodb::coll::Collection;
mod users;
mod projects;
mod like;
mod follow;
mod comment;
mod job;
mod team;
mod proposal;
mod message;
pub use self::users::User;
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.