text stringlengths 8 4.13M |
|---|
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub mod network_experiment_profiles {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu}... |
#![recursion_limit = "256"]
extern crate serde;
use self::serde::Deserialize;
use anyhow::Error;
use yew::format::{Json, Nothing};
use yew::services::fetch::{FetchService, FetchTask, Request, Response};
use yew::services::ConsoleService;
use yew::{html, Component, ComponentLink, Html, ShouldRender};
pub struct Model... |
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#![allow(unused_comparisons)]
use core::ops::{Range, RangeTo};
/// Objects that can be interpreted as a bounded ran... |
#[derive(Deserialize, Debug)]
pub struct GithubAuth {
/// Client ID of the Github app
client_id: String,
/// Secret identifier of the Github app
secret: String,
/// Address to redirect to after a login attempt
redirect: String,
}
impl GithubAuth {
/// Gets the client ID from the config
... |
use std::process::Stdio;
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader, BufWriter};
use tokio::process::Command;
use std::env;
use std::fmt;
mod calculation;
mod geod_error;
#[derive(Debug)]
enum Error {
ArgumentError,
}
impl std::error::Error for Error {}
impl fmt::Display for Error {
fn fmt(&... |
mod moves {
// This function takes ownership of the heap allocated memory
fn destroy_box(c: Box<i32>) {
println!("Destroying a box that contains {}", c);
}
#[test]
fn main() {
// _Stack_ allocated integer
let x = 5u32;
// *Copy* `x` into `y` - no resources are moved... |
// error-pattern:fail
iter x() -> int {
fail;
put 0;
}
fn main() {
let a = @0;
for each x in x() {
}
} |
use actix_web::{
HttpResponse,
};
use super::super::{
service,
response,
};
pub fn index() -> HttpResponse {
let domain_designs = &service::pickup::index();
response::pickup_index::response(domain_designs)
}
|
use actix_files::NamedFile;
use actix_web::{cookie, http, web, HttpMessage, HttpRequest, HttpResponse};
use actix_web::{get, Responder};
use std::path::PathBuf;
use crate::application::app::AppState;
use crate::handle_to_app;
use serde::Deserialize;
const DEPLOY_OR_STATIC: &str = "static";
#[derive(Deserialize)]
... |
/*
---Adding Words - Part 1---
Add two English words together!
Implement a class Arith (struct struct Arith{value : &'static str,} in Rust) such that
//javascript
var k = new Arith("three");
k.add("seven"); //this should return "ten"
//c++
Arith* k = new Arith("three");
k->add("seven"); //this should retu... |
//! An HTTP library for the Lunatic Virtual Machine.
#![deny(missing_debug_implementations, unused_must_use)]
use std::{collections::HashMap, io::Write, net::ToSocketAddrs};
#[macro_use]
extern crate derivative;
#[cfg(test)]
mod regressions;
use body::{mime::HTML, Body};
pub use puck_codegen::handler;
pub use any... |
pub use crate::tmux_bindings::{
plugin,
format_tree,
format_entry,
plugin__bindgen_ty_1 as plugin_inner,
format_plugin,
function_plugin,
cmd_entry,
notification_plugin,
FORMAT_PLUGIN,
FORMAT_FUNCTION_PLUGIN,
CMD_PLUGIN,
NOTIFICATION_PLUGIN,
MULTI_PLUGIN,
notif... |
// warning: globals should be all caps
// warning: unused
const foo: &'static str = "foo";
fn main() {
println!("Hello, world!");
}
|
use std::collections::HashMap;
use std::time::Instant;
use itertools::Itertools;
const INPUT: &str = include_str!("../input.txt");
fn build_happiness_map() -> HashMap<&'static str, HashMap<&'static str, i64>> {
let mut happiness_map: HashMap<&'static str, HashMap<&'static str, i64>> = HashMap::new();
for li... |
use std::fs;
use std::path::Path;
use std::collections::BTreeMap;
use serde::Serialize;
use super::{BasicBlock, Branch};
/// Final trace representation, for serialization.
#[derive(Debug, Clone, Serialize)]
pub struct BasicBlockList {
list: Vec<BasicBlock>,
}
impl BasicBlockList {
/// Constructor, resolves:... |
pub mod generator;
pub mod item;
pub mod parser;
pub mod table;
|
use crate::sleeper::Sleeper;
use crate::waiter::*;
use boolinator::Boolinator;
use std::error::Error;
use std::fmt;
use std::path::PathBuf;
use std::thread;
pub struct FileWaiter {
file_path: PathBuf,
sleeper: Sleeper,
}
impl Waiter for FileWaiter {
fn start(argument: &str, sleeper: Sleeper) -> WaiterStar... |
#[macro_use] extern crate cpython;
extern crate curl;
extern crate serde;
extern crate serde_json;
pub mod utils;
use cpython::{Python, PyDict, PyList, PyResult, ToPyObject, PyObject};
use curl::http;
use std::collections::BTreeMap;
use serde_json::Value;
fn retpy(py: Python) -> PyResult<String> {
let locals = Py... |
mod http;
mod kafka;
pub use self::http::HttpSink;
pub use kafka::*;
use crate::sender::PublishOutcome;
use async_trait::async_trait;
use cloudevents::Event;
use drogue_client::registry;
use std::ops::Deref;
use thiserror::Error;
pub enum SinkTarget<'a> {
Events(&'a registry::v1::Application),
Commands(&'a r... |
static mut STASH: &i32 = &10;
static CONST: i32 = 100;
fn main() {
let x = 10;
let y = 20;
let mut r = &x;
struct Point { x: i32, y: i32 }
let point = Point { x: 1000, y: 729 };
let r: &Point = &point;
let rr: &&Point = &r;
let rrr: &&&Point = &rr;
let x = 10;
let y = 10;
... |
pub use ugh_privacy::DbError;
use byteorder;
use openssl::ssl::error::SslError;
use phf;
use std::error;
use std::convert::From;
use std::fmt;
use std::io;
use Result;
use types::Type;
include!(concat!(env!("OUT_DIR"), "/sqlstate.rs"));
/// Reasons a new Postgres connection could fail.
#[derive(Debug)]
pub enum Con... |
use std::env;
use std::io::{self, Write};
use std::process;
use std::collections::VecDeque;
use std::collections::HashMap;
extern crate pnet;
use pnet::datalink::{self, NetworkInterface};
use pnet::packet::Packet;
use pnet::packet::arp::ArpPacket;
use pnet::packet::ethernet::{EtherTypes, EthernetPacket};
use pnet::pa... |
use std::io::{self, Read};
fn main() {
let mut input = String::new();
let stdin = io::stdin();
let mut handle = stdin.lock();
handle.read_to_string(&mut input).unwrap();
let integer: i32 = input.parse().unwrap();
println!("");
for i in 1..=integer {
println!("{}", i);
}
}
|
//! A [`Visit`](`crate::visit::Visitor`) implementation which deploys the items.
pub mod deployment;
use cfg_if::cfg_if;
use color_eyre::eyre::Context;
use crate::profile::{source::PunktfSource, MergeMode};
use crate::visit::*;
use crate::profile::transform::Transform as _;
use crate::profile::LayeredProfile;
use c... |
use super::compile::Instruction;
use std::convert::TryFrom;
pub(crate) struct Machine {
accumulator: i32,
instruction_pointer: usize,
instructions: Vec<Instruction>,
}
impl Machine {
pub fn new(instructions: &[Instruction]) -> Self {
Self {
accumulator: 0,
instruction_pointer: 0,
instructions: instruct... |
//! Make sure that the timing information is preserved as floats
use std::fs::File;
use anyhow::Result;
use libosu::prelude::*;
const F64_EPSILON: f64 = 0.0001;
const TEST_DATA: &[(&str, &[(usize, f64)])] = &[(
"tests/files/129891.osu",
&[
(0, 270.002700027),
(1, -100.0),
(2, -100.0),... |
// -------------------------------------------------------------------------------//
// Cryptopals, Set 1, Challenge 6: https://cryptopals.com/sets/1/challenges/6
// Impl by Frodo45127
// -------------------------------------------------------------------------------//
use crate::utils::*;
use std::io::{BufReader, Re... |
use failure::Fail;
use std::io;
#[derive(Fail, Debug)]
pub enum KvsError {
/// IO error
#[fail(display = "{}", _0)]
Io(#[cause] io::Error),
}
impl From<io::Error> for KvsError {
fn from(err: io::Error) -> KvsError {
KvsError::Io(err)
}
}
/// Result type for kvs
pub type Result<T> = std::r... |
#[doc = "Register `ISR` reader"]
pub type R = crate::R<ISR_SPEC>;
#[doc = "Register `ISR` writer"]
pub type W = crate::W<ISR_SPEC>;
#[doc = "Field `ALRAWF` reader - Alarm A write flag"]
pub type ALRAWF_R = crate::BitReader<ALRAWFR_A>;
#[doc = "Alarm A write flag\n\nValue on reset: 1"]
#[derive(Clone, Copy, Debug, Parti... |
/*
* Copyright 2019 Cargill Incorporated
*
* 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 a... |
use playhead::PlayHead;
#[test]
fn start(){
let ph:PlayHead = PlayHead::new();
let rt = ph.time();
assert_eq!(rt,0);
}
//#[test]
// fn play_pause(){
// let mut ph:PlayHead = PlayHead::new();;
// ph.play();
// let start_time = ph.time();
// // let mut time_after_pause:u128 ;
// let numbe... |
use crate::connection::MavConnection;
use crate::{read_versioned_msg, MavHeader, MavlinkVersion, Message};
use std::fs::File;
use std::io::{self};
use std::sync::Mutex;
/// File MAVLINK connection
pub fn open(file_path: &str) -> io::Result<FileConnection> {
let file = match File::open(&file_path) {
Err(e)... |
use crystalorb::{
client::{
stage::{Stage, StageMut},
Client,
},
clocksync::ClockSyncMessage,
command::Command,
fixed_timestepper::Stepper,
server::Server,
timestamp::Timestamped,
world::{DisplayState, World},
Config, TweeningMethod,
};
use crystalorb_mock_network::Mo... |
use std::collections::HashMap;
use bstr::ByteSlice;
use crate::{
annotations::{AnnotationCollection, AnnotationRecord, ColumnKey},
gui::windows::filters::{
FilterNum, FilterNumOp, FilterString, FilterStringOp,
},
};
use super::ColumnPickerMany;
#[derive(Debug, Clone, PartialEq)]
pub struct Quick... |
use std::os::raw::c_void;
use std::ffi::CString;
use std::sync::mpsc::{Sender, Receiver, channel};
use windows::*;
#[allow(non_camel_case_types, unused, non_snake_case)]
#[repr(C)]
pub struct SERVICE_STATUS {
dwServiceType : SERVICE_TYPE,
dwCurrentState : CURRENT_SERVICE_STATUS,
dwControlsAccepted : ACCEPT... |
use rl::Vector2;
use rl::Color;
const FPS: i32 = 120;
const TRANSPARENT_WHITE: Color = Color {
a: 10,
..rl::WHITE
};
#[derive(Clone, Debug)]
pub struct TurtleState {
pub time: f32,
/// in pixels
pub pos: Vector2,
/// in radians
pub rot: f32,
pub is_drawing: bool,
}
pub struct GameSta... |
//! Contains the sync API. This is only available when the `sync` feature is enabled.
mod change_stream;
mod client;
mod coll;
mod cursor;
mod db;
pub mod gridfs;
#[cfg(test)]
mod test;
pub use change_stream::{ChangeStream, SessionChangeStream};
pub use client::{session::ClientSession, Client};
pub use coll::Collect... |
use std::thread;
use std::time::Duration;
use tokio::prelude::*;
use rustygear::client::{Client, WorkerJob};
/// When we use the status method, we need to be async!
async fn status_user(mut job: WorkerJob) -> Result<Vec<u8>, io::Error> {
job.work_status(50, 100).await?;
thread::sleep(Duration::from_secs(1));... |
use getopts;
use rpassword;
use std::fs::File;
use std::io::{stdout, Read, Write};
use std::path::PathBuf;
use std::path::Path;
use std::process::exit;
use audio_backend::{BACKENDS, Sink};
use authentication::{Credentials, facebook_login, discovery_login};
use cache::{Cache, DefaultCache, NoCache};
use player::Player;... |
// Copyright 2019 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
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... |
use std::cmp::max;
use std::collections::BTreeMap;
struct Service {
a: i64,
b: i64,
c: i64,
}
fn main() {
let (n, c) = {
let mut line = String::new();
std::io::stdin().read_line(&mut line).unwrap();
let mut ws = line.trim_end().split_whitespace();
let n1 = ws.next().unw... |
pub mod pwm_inverter;
pub mod blocking_delay;
pub mod rotor_position_sensor;
pub mod current_sensor; |
#![no_main]
extern crate abxml;
#[macro_use]
extern crate libfuzzer_sys;
use abxml::chunks::XmlTagEndWrapper;
use abxml::model::TagEnd;
fuzz_target!(|data: &[u8]| {
let xtew = XmlTagEndWrapper::new(data);
xtew.get_id();
});
|
use awc::Client;
use axum_websockets::{
configuration::get_configuration,
message::ResultMessage,
telemetry::{get_subscriber, init_subscriber},
Application,
};
use futures::{SinkExt, StreamExt};
use once_cell::sync::Lazy;
use std::time::Duration;
// Ensure that 'tracing' stack is only initialized once ... |
use futures::stream::StreamExt;
use tokio::net::TcpListener;
#[derive(Debug)]
pub struct Server {
listener: TcpListener
}
impl Server {
pub async fn new(bind_addr: String, db_addr: String) -> Server {
Server {
listener: TcpListener::bind(bind_addr).await.unwrap()
}
}
pub async fn run(&mu... |
use crate::consts::SELECTION_TOLERANCE;
use crate::message_prelude::*;
use crate::tool::ToolActionHandlerData;
use glam::DVec2;
use graphene::{Operation, Quad};
#[derive(Default)]
pub struct Fill;
#[impl_message(Message, ToolMessage, Fill)]
#[derive(PartialEq, Clone, Debug, Hash)]
pub enum FillMessage {
MouseDown,
}... |
use bytes::{as_i32_le, as_i64_le, i32_as_u8_le, i64_as_u8_le, u32_as_u8_le};
use std::{slice, str};
use wasmtime_runtime::VMMemoryDefinition;
#[derive(Debug)]
pub struct Mem {
pub definition: Option<*mut VMMemoryDefinition>,
}
impl Mem {
pub fn new() -> Self {
Self { definition: None }
}
}
pub tr... |
#[macro_use]
extern crate diesel;
mod schema {
table! {
posts (id) {
id -> Int4,
title -> Varchar,
body -> Text,
published -> Bool,
}
}
}
mod models {
use schema::posts;
#[derive(Queryable)]
pub struct Post {
pub id: i32,
pub title: String,
... |
use crate::data::Data;
use std::iter;
use crate::data::subnet::SubnetState;
use crate::data::component::components::*;
use crate::data::component::{Component, ComponentId};
use crate::data::component::statefuls::*;
#[cfg(test)]
mod test;
#[no_mangle]
pub extern "C" fn init() -> *mut Data {
Box::into_raw(Box::new(... |
#[cfg(not(windows))]
use crate::os::HRESULT;
use com_rs::{com_interface, IUnknown, IID};
extern "C" {
static IID_IUnknown: IID;
}
#[cfg(not(windows))]
// Steal the interface ID from IUnknown:
com_interface! {
/// Insert complete object and deleting destructor on non-Windows platforms, where Dxc shims IUnknown... |
use crate::ping_result_processors::ping_result_processor_console_logger::PingResultProcessorConsoleLogger;
use crate::ping_result_processors::ping_result_processor_csv_logger::PingResultProcessorCsvLogger;
use crate::ping_result_processors::ping_result_processor_json_logger::PingResultProcessorJsonLogger;
use crate::pi... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
/// SyntheticsGlobalVariable : Synthetics global variable.
#[derive(Clone, Debug, PartialEq, Serializ... |
mod assembler;
mod token;
mod lexer;
mod parser;
pub use self::assembler::{Assembler, CodeSegment};
pub use self::token::LexerToken;
pub use self::lexer::Lexer; |
#[doc = "Register `OPTSR2_PRG` reader"]
pub type R = crate::R<OPTSR2_PRG_SPEC>;
#[doc = "Register `OPTSR2_PRG` writer"]
pub type W = crate::W<OPTSR2_PRG_SPEC>;
#[doc = "Field `SRAM1_3_RST` reader - SRAM1 and SRAM3 erase upon system reset Note: SRAM erase is triggered by option byte change operation, when enabling this ... |
#![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 ErrorResponse {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
#[... |
fn main() {
let vec = read_line();
// 0 0 1 2
let sx : i32 = vec[0];
let sy : i32 = vec[1];
let tx : i32 = vec[2];
let ty : i32 = vec[3];
// 1 s-->t
// 2 t-->s
{
// go ahead
let h = (sy - ty).abs();
let w = (sx - tx).abs();
for _ in 0..h {
... |
#[cfg(feature = "simdcompression")]
mod build {
extern crate cc;
pub fn build() {
let mut config = cc::Build::new();
config
.include("./cpp/simdcomp/include")
.file("cpp/simdcomp/src/avxbitpacking.c")
.file("cpp/simdcomp/src/simdintegratedbitpacking.c")
... |
use crate::asm;
use crate::console::{inthandler0c, inthandler0d};
use crate::keyboard::inthandler21;
use crate::mouse::inthandler2c;
use crate::timer::inthandler20;
use crate::{exception_handler, handler};
use asm::{interrupt_hrb_api, load_gdtr, load_idtr};
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct SegmentDe... |
#[macro_use]
extern crate failure;
extern crate chrono;
extern crate nom;
extern crate prettytable;
#[macro_use]
extern crate lazy_static;
extern crate pdatastructs;
mod app;
mod common;
mod execution;
mod logical;
mod syntax;
use crate::app::AppError;
use clap::load_yaml;
use clap::App;
use prettytable::{Cell, Row, ... |
use std::ops::Bound;
use std::sync::Arc;
use anyhow::Context;
use axum::extract::{Extension, Path};
use hyper::{Body, Response};
use serde_derive::Deserialize;
use sqlx::Acquire;
use svc_authn::AccountId;
use svc_utils::extractors::AccountIdExtractor;
use uuid::Uuid;
use super::{find, AppResult};
use crate::app::erro... |
use crate::autofrag::auto_fragmentization;
use crate::consts::{
typename_field_def, typename_field_node, EMPTY_DIRECTIVES, MUTATION_TYPE_NAME, QUERY_TYPE_NAME,
TYPENAME_FIELD_NAME,
};
use crate::context::*;
use crate::federation::Federation;
use crate::groups::{
FetchGroup, GroupForField, GroupForSubField, ... |
use ethereum_types::U256;
use juniper::{
graphql_object, graphql_value, EmptyMutation, EmptySubscription, FieldError, FieldResult,
RootNode,
};
use rustc_hex::{FromHex, ToHex};
use simple_program::state::SimpleProgram;
use solana_client::rpc_client::RpcClient;
use solana_sdk::{program_pack::Pack, pubkey::Pubkey... |
#[doc = "Register `CR` reader"]
pub type R = crate::R<CR_SPEC>;
#[doc = "Register `CR` writer"]
pub type W = crate::W<CR_SPEC>;
#[doc = "Field `WUCKSEL` reader - ck_wut wakeup clock selection 10x: ck_spre (usually 1Â Hz) clock is selected 11x: ck_spre (usually 1Â Hz) clock is selected and 216Â is added to the WUT count... |
use crate::cargo::{self, Metadata, PackageMetadata};
use crate::dependencies::{self, Dependency, EditionOrInherit};
use crate::directory::Directory;
use crate::env::Update;
use crate::error::{Error, Result};
use crate::expand::{expand_globs, ExpandedTest};
use crate::flock::Lock;
use crate::manifest::{Bin, Build, Confi... |
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
#[pyclass]
struct MyClass{
#[pyo3(get, set)]
num: usize,
#[pyo3(get, set)]
val: String,
}
#[pyfunction]
fn sum_as_str(a: usize, b: usize) -> MyClass {
MyClass {
num: (a + b),
val: (a+b).to_string()
}
}
#[pymodule]
f... |
use paras_vesting_contract::ContractContract as VestingContract;
use near_sdk::json_types::{U128, U64};
use near_sdk::serde_json::json;
use near_sdk_sim::{
deploy, init_simulator, to_yocto, ContractAccount, UserAccount, DEFAULT_GAS, STORAGE_AMOUNT,
};
// Load in contract bytes at runtime
near_sdk_sim::lazy_static_... |
pub mod gpio;
pub mod max31855;
|
use std::fmt::Debug;
use std::ops::Deref;
#[derive(Debug)]
enum List<T> {
Cons(T, Box<List<T>>),
Nil,
}
#[derive(Debug)]
struct MyBox<T: Debug>(T);
impl<T> MyBox<T>
where
T: Debug,
{
fn new(x: T) -> MyBox<T> {
MyBox(x)
}
}
impl<T> Deref for MyBox<T>
where
T: Debug, {
type Target... |
use super::{Concrete, Endpoint, Logical};
use crate::{resolve, stack_labels};
use linkerd_app_core::{
classify,
config::ProxyConfig,
metrics, profiles,
proxy::{api_resolve::Metadata, core::Resolve, http},
retry, svc,
tls::ReasonForNoPeerName,
Addr, Error, CANONICAL_DST_HEADER, DST_OVERRIDE_H... |
#![allow(clippy::type_complexity)]
#![allow(clippy::unused_unit)]
#![allow(clippy::from_over_into)]
#[macro_use]
extern crate serde_derive;
mod client;
mod connection;
mod misc;
pub use client::WebsocketClientTransport;
pub use connection::WebsocketConnection;
pub use misc::{connect, new_payload, JsClient, JsPayload... |
use crate::service::id_generator::snow_worker::SnowWorkerM1;
use crate::service::id_generator::id_generator_options::IdGeneratorOptions;
use std::sync::{Mutex};
use lazy_static::lazy_static;
lazy_static! {
pub static ref WORKPOLL:Mutex<Vec<SnowWorkerM1>> = Mutex::new(Vec::new());
}
pub fn run() {
//let mut wo... |
#![feature(phase)]
#![feature(macro_rules)]
extern crate document;
#[phase(plugin, link)]
extern crate xpath;
use std::collections::HashMap;
use std::num::Float;
use document::Package;
use document::dom4::{Document,Root,Element,Text};
use xpath::XPathValue::{Boolean,Number,String,Nodes};
use xpath::{Functions,Varia... |
mod data_processing;
use sprs::CsVec;
use rand::thread_rng;
use rand::seq::SliceRandom;
use std::time::{Duration, Instant};
fn main() {
let n = 120000;
let w_c = 4;
let w_r = 8;
let n = w_r * (n / w_r);
let m = n * w_c/w_r;
println!("n={}", n);
let crossover_proba = 0.05;
let seed = 10... |
extern crate time;
/*pub fn get_time() -> f64 {
let current_time = time::get_time();
let unix_timestamp = (current_time.sec as f64) + ((current_time.nsec as f64) * 1e-09);
return unix_timestamp;
}*/
pub fn get_precise_time() -> f64 {
let current_time = time::precise_time_s();
return current_time;
... |
#![feature(plugin)]
#![plugin(rocket_codegen)]
#![feature(custom_attribute)]
#[macro_use]
extern crate diesel;
#[macro_use]
extern crate serde_derive;
extern crate dotenv;
extern crate rocket;
extern crate serde_json;
extern crate rocket_contrib;
use rocket::request::Request;
mod controllers;
use controllers::*;
... |
use serde::de::Error;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
// Custom wrapper so we don't have to write serialization/deserialization code manually
#[derive(Serialize, Deserialize)]
struct Commitment(#[serde(with = "hex::serde")] pub(super) [u8; 48]);
impl Serialize for super::Commitment {
... |
use ::std::{
io::{self,
// Read,
},
};
fn main ()
{
#[derive(Debug)] // allows using {:?} formatting
enum FruitKind {
Apple,
Orange,
}
println!("Enter your favourite fruit: ");
let mut fruit = String::new();
io::stdin().read_line(&mut fruit).unwrap();
let... |
// This file is part of Substrate.
// Copyright (C) 2019-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
//
// ht... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - rising trigger selection register"]
pub rtsr1: RTSR1,
#[doc = "0x04 - falling trigger selection register"]
pub ftsr1: FTSR1,
#[doc = "0x08 - software interrupt event register"]
pub swier1: SWIER1,
#[doc = "0x0c ... |
#[derive(RustEmbed)]
#[folder = "examples/public/"]
struct Asset;
pub fn radio_play(){
use std::fs::{self, File};
use std::io::BufReader;
use std::time::Duration;
use std::thread::sleep;
use std::io::{Read, Write};
let device = rodio::default_output_device().expect("error 1");
let shaolin... |
//! Module defining the `ReportInfo` struct, useful to format the output report file and
//! to keep track of statistics about the sniffed traffic.
use std::collections::{HashMap, HashSet};
use indexmap::IndexMap;
use crate::networking::types::address_port_pair::AddressPortPair;
use crate::networking::types::data_in... |
use std::fmt::Display;
/// String to search for in a JSON document, conforming to the
/// [RFC7159, section 7](https://www.rfc-editor.org/rfc/rfc7159#section-7)
///
/// Represents the bytes defining a label/key in a JSON object
/// that can be matched against when executing a query.
///
/// # Examples
///
/// ```
/// ... |
use yew::{html, Component, ComponentLink, Html, Renderable, ShouldRender};
pub struct PageNotFound {}
pub enum Msg {}
impl Component for PageNotFound {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
PageNotFound {}
}
fn update(... |
#[test]
pub fn setup() {
println!("common setup print");
}
|
use actix_web::web::ServiceConfig;
use actix_web::{delete, get, patch, post, web, Error, HttpRequest, HttpResponse};
use crate::db::PgPool;
use crate::db::finance as db;
use crate::db::types::Branch;
use chrono::{Date, NaiveDateTime};
use crate::db::finance::FilterQuery;
use diesel::PgConnection;
use serde::Serialize;
... |
use super::crypto::{read_rmux_event, CryptoContext};
use super::event::{
get_event_type_str, new_ping_event, new_pong_event, new_routine_event, new_shutdown_event,
new_syn_event, new_window_update_event, Event, FLAG_DATA, FLAG_FIN, FLAG_PING, FLAG_PONG,
FLAG_ROUTINE, FLAG_SHUTDOWN, FLAG_SYN, FLAG_WIN_UPDATE... |
use addressing;
use curve25519_dalek::montgomery::MontgomeryPoint;
use itertools::Itertools;
use rand::seq::IteratorRandom;
use sphinx::route::{Node as SphinxNode, NodeAddressBytes};
use std::cmp::max;
use std::collections::HashMap;
use std::net::SocketAddr;
#[derive(Debug, Clone)]
pub struct MixNode {
pub host: S... |
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let memory_x = include_bytes!("memory.x.in");
let mut f = File::create(out_dir.join("memory.x")).unwrap();
f.write_all(memory_x).unwrap();
println!("... |
use tree_sitter::{Point, Range, Tree};
#[derive(Debug)]
pub struct ScopeSequence(Vec<ScopeStack>);
type ScopeStack = Vec<&'static str>;
impl ScopeSequence {
pub fn new(tree: &Tree) -> Self {
let mut result = ScopeSequence(Vec::new());
let mut scope_stack = Vec::new();
let mut cursor = tr... |
pub trait BpLoudsCommonTrait {
fn isleaf (&self,pos:u64) -> bool;
fn parent(&self,pos:u64) -> Option<u64>;
fn first_child(&self,pos:u64) -> Option<u64>;
fn next_sibling(&self,pos:u64) -> Option<u64>;
} |
//! Use ExifTool to extract photo metadata
use crate::{
config::PhotoConfig,
deserialize::{date_time_string, string_number, string_sequence},
html,
models::{
Camera, ExposureMode, Location, Photo, PhotoFile, SizeCollection,
},
tools::pos_from_name,
};
use chrono::{DateTime, FixedOffset}... |
use std::clone::Clone;
use std::convert::From;
use std::default::Default;
use std::fmt;
use std::ops::{Index, IndexMut};
fn main() -> std::io::Result<()> {
let input = std::fs::read_to_string("examples/17/input.txt")?;
let data: Vec<Vec<_>> = input
.lines()
.map(|line| line.trim().chars().map(|x... |
#![allow(clippy::missing_safety_doc)]
use polodb_core::{DbContext, DbErr, DbHandle, TransactionType, Config};
use polodb_bson::{Value, ObjectId, Document, Array, UTCDateTime, ty_int};
use polodb_bson::linked_hash_map::Iter;
use std::cell::RefCell;
use std::rc::Rc;
use std::os::raw::{c_char, c_uint, c_int, c_double, c_... |
use lazy_static::lazy_static;
use regex::Regex;
use std::collections::HashMap;
lazy_static! {
static ref MASK_REGEX: Regex = Regex::new(r"^mask = (?P<mask>[X10]+)$").unwrap();
static ref MEM_REGEX: Regex =
Regex::new(r"^mem\[(?P<address>\d+)\] = (?P<value>\d+)$").unwrap();
}
fn main() {
let part_... |
pub struct HtmlEntities {
} |
// error-pattern:whatever
fn main() {
log(error, "whatever");
// Setting the exit status only works when the scheduler terminates
// normally. In this case we're going to fail, so instead of of
// returning 50 the process will return the typical rt failure code.
sys::set_exit_status(50);
fail;
... |
#[doc = "Register `ISR` reader"]
pub type R = crate::R<ISR_SPEC>;
#[doc = "Field `EOCALF` reader - End of calibration flag"]
pub type EOCALF_R = crate::BitReader;
#[doc = "Field `JEOCF` reader - End of injected conversion flag"]
pub type JEOCF_R = crate::BitReader;
#[doc = "Field `JOVRF` reader - Injected conversion ov... |
use crate::appkit::NSApplication;
use crate::appkit::NSApplicationActivationOptions;
use crate::appkit::NSApplicationActivationPolicy;
use crate::appkit::NSImage;
use crate::appkit::NSMenu;
use crate::appkit::NSMenuItem;
use crate::appkit::NSRunningApplication;
use crate::appkit::NSStatusBar;
use crate::appkit::NSStatu... |
extern crate libloading;
extern crate chan;
extern crate rustc_serialize;
extern crate regex;
pub mod core;
use regex::Regex;
use core::net::TcpWriter;
use core::threads::HandlerThread;
use core::parser;
use core::parser::IrcMessage;
pub struct SayPlugin;
macro_rules! command_match {
($m:ident =~ $c:expr) => {
... |
use crate::decoder::decoder::{Decoder, DecoderResult};
// http://webassembly.github.io/spec/core/binary/values.html#integers
fn decode_unsigned_leb_128(decoder: &mut Decoder) -> DecoderResult<u64> {
let mut result: u64 = 0;
let mut shift = 0;
loop {
let byte = decoder.eat_byte()?;
// Extr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.