text stringlengths 8 4.13M |
|---|
use juniper::{
graphql_object, EmptySubscription, FieldError, GraphQLInputObject, GraphQLObject, RootNode,
};
use serde::{Deserialize, Serialize};
use crate::db::Db;
type FieldResult<T> = std::result::Result<T, FieldError>;
fn timestamp() -> String {
chrono::Local::now().naive_utc().format("%+").to_string()
... |
use actix::Addr;
use actix_identity::Identity;
use actix_web::{
web::{block, Data},
HttpResponse, Result,
};
use auth::{get_claim_from_identity, PrivateClaim, Role};
use db::{get_conn, models::Round, Connection, PgPool};
use errors::Error;
use crate::websocket::{client_messages, Server};
pub async fn lock_ro... |
// Copyright 2015 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 ... |
// 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.
//! This is the client library for interacting with the Cobalt FIDL service.
#![deny(missing_docs)]
pub mod cobalt_event_builder;
pub mod connector;
pub ... |
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Operation {
Acc,
Jmp,
Nop,
}
#[derive(Debug)]
pub struct Instruction {
pub op: Operation,
arg: i32,
}
#[derive(Debug)]
pub struct Emulator<'a> {
code: &'a Vec<Instruction>,
pc: usize,
acc: i32
}
impl<'a> Emulator<'a> {
pub fn new(c... |
#[macro_use]
extern crate tera;
use actix_files as fs;
use actix_session::{CookieSession, Session};
use actix_utils::mpsc;
use actix_http::{body::Body, Response};
use actix_web::{
dev::ServiceResponse,
http::StatusCode,
middleware::{
self,
errhandlers::{
ErrorHandlerResponse,
... |
use crate::lz4;
use crate::entity::EntityEntry;
use crate::vec2::{vec2,Vec2};
pub struct DataDef {
pub offset: usize,
pub pal: usize,
}
impl DataDef {
pub fn data(&self) -> &'static [u8] {
unsafe { &DATA[self.offset..] }
}
pub fn pal(&self) -> &'static [u32] {
&PAL_DATA[self.pal..]... |
#![allow(dead_code)]
use crate::{aocbail, utils};
use std::iter::Peekable;
use utils::{AOCError, AOCResult};
pub fn re_weird_parse(
tokens: &mut Peekable<impl Iterator<Item = char>>,
precedence: bool,
greedy: bool,
) -> AOCResult<u64> {
let mut left_expr = match tokens.next()? {
'(' => {
... |
pub mod root {
// use std::fmt::Pointer;
use std::alloc::Layout;
use std::collections::HashMap;
use std::ptr::hash;
struct Test {
name: String
}
impl std::fmt::Display for Test {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
... |
extern crate reqwest;
use dotenv::dotenv;
use std::collections::HashMap;
use std::env;
use std::io::Read;
fn main() {
// load env vars
dotenv().ok();
use env::var;
let client_id = var("PLAID_CLIENT_ID").unwrap();
let secret = var("PLAID_SECRET").unwrap();
let access_token = var("PLAID_TOKEN")... |
use crate::config::PlatformConfiguration;
use crate::errors::*;
use crate::overlay::Overlayer;
use crate::project::Project;
use crate::toolchain::Toolchain;
use crate::Build;
use crate::Device;
use crate::Platform;
use crate::SetupArgs;
use dinghy_build::build_env::set_env;
use std::fmt::{Debug, Display, Formatter};
us... |
pub struct MonsterSpawner{
pub zombie_spawn_chance: f64,
pub wolf_pack_spawn_chance: f64
}
|
use int::Int;
macro_rules! div {
($intrinsic:ident: $ty:ty, $uty:ty) => {
div!($intrinsic: $ty, $uty, $ty, |i| {i});
};
($intrinsic:ident: $ty:ty, $uty:ty, $tyret:ty, $conv:expr) => {
/// Returns `a / b`
#[cfg_attr(not(test), no_mangle)]
pub extern "C" fn $intrinsic(a: $ty, ... |
use nom::*;
use nom::types::*;
use std::str;
use std::str::FromStr;
use std::str::Utf8Error;
pub mod token;
use lexer::token::*;
// operators
named!(equal_operator<CompleteByteSlice, Token>,
do_parse!(tag!("==") >> (Token::Equal))
);
named!(not_equal_operator<CompleteByteSlice, Token>,
do_parse!(tag!("!=") >> (... |
use crate::parsing::parse_bag_def;
#[test]
fn test1() {
let bag = parse_bag_def("dotted black bags contain no other bags.");
assert_eq!(bag.color, "dotted black");
assert!(bag.inner_bags.is_empty());
}
#[test]
fn test2() {
let bag = parse_bag_def("bright white bags contain 1 shiny gold bag.");
ass... |
#[doc = "Reader of register TXCNTMCOL"]
pub type R = crate::R<u32, super::TXCNTMCOL>;
#[doc = "Reader of field `TXMULTCOLG`"]
pub type TXMULTCOLG_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - This field indicates the number of successfully transmitted frames after multiple collisions in the half-duplex mode... |
//Subscribe
use ws::{connect, Handler, Sender, Handshake, Message, CloseCode};
use serde_json::{Value};
use std::sync::Arc;
use crate::api::config::Config;
use crate::api::subscription::data::{
SubscribeResponse,
SubscribeCommand
};
pub struct Client {
out: Sender,
op: Arc<dyn Fn(R... |
//! C API wrappers to work with a Telamon search space.
use std;
use super::error::TelamonStatus;
use super::ir::Function;
use telamon::search_space;
/// Opaque type that abstracts away the lifetime parameter of
/// `search_space::SearchSpace`.
#[derive(Clone)]
pub struct SearchSpace(pub(crate) search_space::SearchS... |
#![allow(clippy::comparison_chain)]
#![allow(clippy::collapsible_if)]
use std::cmp::Reverse;
use std::cmp::{max, min};
use std::collections::{BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::Debug;
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000_000_007;
/// 2の逆元 mod te... |
pub mod gate_desc;
pub mod circuit_desc_gen;
|
use crypto;
use util;
use rustc_serialize::Decodable;
use rustc_serialize::base64::{self, ToBase64};
use rustc_serialize::json::{self, Json};
use rust_multihash::Multihash;
use std::io::Read;
use std::path::PathBuf;
pub const DEFAULT_REPO_ROOT: &'static str = "~/";
pub const DEFAULT_REPO_PATH: &'static str = ".rust-i... |
extern "C" {
pub fn fcntl(fd: i32, cmd: i32, ...) -> i32;
}
pub const F_GETFD: i32 = 1;
pub const F_SETFD: i32 = 2;
pub const FD_CLOEXEC: i32 = 2;
pub const EBADF: i32 = 9;
|
//! Contains an ffi-safe equivalent of `std::string::String`.
use std::{
borrow::{Borrow, Cow},
fmt::{self, Display, Formatter},
iter::{FromIterator, FusedIterator},
marker::PhantomData,
ops::{Deref, Index, Range},
ptr,
str::{from_utf8, Chars, FromStr, Utf8Error},
string::FromUtf16Error... |
/*
* Copyright 2020 Fluence Labs Limited
*
* 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... |
// Copyright 2015 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 ... |
extern crate ansi_term;
extern crate difference;
pub mod macros;
pub mod table;
mod formater;
mod test_case;
|
//https://leetcode.com/problems/di-string-match/submissions/
impl Solution {
pub fn di_string_match(s: String) -> Vec<i32> {
let mut perm = Vec::with_capacity(s.len());
let mut left: i32 = 0;
let mut right = s.len() as i32;
let mut last_char = s.chars().nth(0).unwrap();
... |
use std::time::SystemTime;
fn main() {
let server = tiny_http::Server::http("0.0.0.0:6099").unwrap();
loop {
let request = match server.recv() {
Ok(rq) => rq,
Err(e) => { println!("error: {}", e); break }
};
let response = tiny_http::Response::empty(200);
... |
use crate::any::connection::AnyConnectionKind;
use crate::any::{
Any, AnyColumn, AnyConnection, AnyQueryResult, AnyRow, AnyStatement, AnyTypeInfo,
};
use crate::database::Database;
use crate::describe::Describe;
use crate::error::Error;
use crate::executor::{Execute, Executor};
use either::Either;
use futures_core:... |
//! Protobuf types for errors from the google standards and
//! conversions to `tonic::Status`
//!
//! # Status Responses
//!
//! gRPC defines a standard set of [Status Codes] to use for various purposes. In general this
//! combined with a textual error message are sufficient. The status code allows the client to
//! ... |
extern crate ggez;
extern crate markedly;
extern crate markedly_ggez;
use std::env;
use std::path;
use ggez::{Context, GameResult, GameError};
use ggez::conf::{Conf, WindowMode, WindowSetup};
use ggez::event::{self, EventHandler, MouseButton, MouseState};
use ggez::graphics::{self, Point2, Vector2};
use markedly::cl... |
use crate::erts::term::prelude::*;
#[repr(C)]
pub struct BinaryMatchResult {
// The value matched by the match operation
pub value: Term,
// The rest of the binary (typically a MatchContext)
pub rest: Term,
// Whether the match was successful or not
pub success: bool,
}
impl BinaryMatchResult {... |
extern crate clap;
extern crate sys_mount;
use clap::{App, Arg};
use std::process::exit;
use sys_mount::{unmount, UnmountFlags};
fn main() {
let matches = App::new("umount")
.arg(Arg::with_name("lazy").short("l").long("lazy"))
.arg(Arg::with_name("source").required(true))
.get_matches();
... |
#![allow(clippy::nonstandard_macro_braces, clippy::too_many_arguments)]
mod empty_structs;
mod one_field_structs;
mod structs_with_generic_type_params;
mod two_field_structs;
mod enums_ignore_variant;
mod enums_with_generic_type_params;
mod enums_with_items_with_and_without_fields;
mod enums_with_multiple_empty_items;... |
use crate::protocol::{AlphaKeys, BackKeys, Command, DirectionKeys, MetaKeys, Stick};
use crate::uinput::{Key, Side, UInputHandle};
pub fn apply_keys(input: &UInputHandle, command: Command) {
match command {
Command::Terminate => {}
Command::Xbox(pressed) => send_xbox_key(input, pressed),
Co... |
//! Reading and writing sequentially from buffers.
//!
//! This is called buffered I/O, and allow buffers to support sequential reading
//! and writing to and from buffer.
//!
//! The primary traits that govern this is [ReadBuf] and [WriteBuf].
pub use audio_core::{ReadBuf, WriteBuf};
mod utils;
pub use self::utils::... |
use super::*;
#[test]
fn without_boolean_right_errors_badarg() {
run!(
|arc_process| strategy::term::is_not_boolean(arc_process.clone()),
|right_boolean| {
prop_assert_is_not_boolean!(result(true.into(), right_boolean), right_boolean);
Ok(())
},
);
}
#[test]
fn... |
mod lexer;
mod parser;
mod token_stream;
mod graphviz;
use std::fs;
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
println!("Usage: [invocation] filename")
}
else {
let contents: String = fs::read_to_string(&args[1]).expect("Could not open... |
use std::env;
use std::error::Error;
use std::fs;
use std::str;
use bioinformatics_algorithms::{pos_to_nt, profile_most_probable, score, Matrix};
pub fn profile_matrix_with_pseudocounts(motifs: &[String], k: usize) -> Matrix {
let mut matrix: Matrix = vec![vec![0.0; k]; 4];
for i in 0..k {
for nt in ... |
#![crate_type = "staticlib"]
type ScriptFn = unsafe extern "C" fn() -> ();
static mut THREADS: Vec<std::thread::JoinHandle<()>> = Vec::new();
#[no_mangle]
extern "C" fn support_spawn_script(f: ScriptFn) {
unsafe {
THREADS.push(std::thread::spawn(move || {
f()
}));
}
}
#[no_mangle... |
#![warn(clippy::all, clippy::pedantic)]
#![allow(dead_code)]
mod http;
mod io;
mod lttp;
use crate::{
io::logic_files,
lttp::{
AppState,
DungeonState,
GameState,
LocationState,
ServerConfig,
},
};
use anyhow::{
bail,
Result,
};
use clap::{
crate_authors... |
//! # Elements of Programming Languages
//!
//! These are short recipes for accomplishing common tasks.
//!
//! * [Whitespace](#whitespace)
//! + [Wrapper combinators that eat whitespace before and after a parser](#wrapper-combinators-that-eat-whitespace-before-and-after-a-parser)
//! * [Comments](#comments)
//! + ... |
/// File to define symbols in LaTeX
///
#[derive(Debug, PartialEq, Clone)]
pub enum Symbols {
/// =
Equals,
/// <=
LessOrEquals,
/// <
Less,
/// >=
MoreOrEquals,
/// >
More,
/// !=
Diff,
}
impl Symbols {
/// Returns the enum corresponding to the String
pub fn ge... |
// Copyright 2022 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 ... |
//! EVM module.
pub mod backend;
pub mod derive_caller;
pub mod precompile;
pub mod raw_tx;
pub mod types;
use evm::{
executor::{MemoryStackState, StackExecutor, StackSubstateMetadata},
Config as EVMConfig,
};
use thiserror::Error;
use oasis_runtime_sdk::{
context::{BatchContext, Context, TxContext},
... |
// FIXME: Most of these should be uints.
const rc_base_field_refcnt: int = 0;
// FIXME: import from std::dbg when imported consts work.
const const_refcount: uint = 0x7bad_face_u;
const task_field_refcnt: int = 0;
const task_field_stk: int = 2;
const task_field_runtime_sp: int = 3;
const task_field_rust_sp: in... |
//! Clause allocator.
use std::{mem::transmute, slice};
use varisat_formula::{lit::LitIdx, Lit};
use super::{Clause, ClauseHeader, HEADER_LEN};
/// Integer type used to store offsets into [`ClauseAlloc`]'s memory.
type ClauseOffset = u32;
/// Bump allocator for clause storage.
///
/// Clauses are allocated from a s... |
fn main() {
if_let_expressions();
while_loop();
for_loop();
let_statement();
function_parameters();
}
/*
The line if let Ok(age) = age introduces a new shadowed age variable that
contains the value inside the Ok variant. This means we need to place the if age
> 30 condition within that block: we c... |
use proconio::{input, marker::Usize1};
fn solve(i: usize, g: &Vec<Vec<usize>>, y: &Vec<u64>, acc: u64, cover: &mut Vec<bool>) {
// eprintln!("i = {}, y[i] = {}, acc = {}",i, y[i], acc);
cover[i] = y[i].max(acc) >= 1;
for &j in &g[i] {
solve(
j,
g,
y,
... |
use std::{
mem::MaybeUninit,
sync::atomic::{
fence, AtomicPtr,
Ordering::{Acquire, Relaxed, Release},
},
};
use crate::ebr::Ebr;
/// A simple lock-free Treiber stack
pub struct Stack<T: Send + 'static> {
head: AtomicPtr<Node<T>>,
ebr: Ebr<Box<Node<T>>>,
}
impl<T: Send + 'static> D... |
mod option;
pub use option::*;
|
mod errors;
mod qrcode;
use crate::qrcode::route::route_qrcode;
use actix_cors::Cors;
use actix_web::*;
use serde_derive::*;
use std::env;
#[derive(Clone, Deserialize)]
pub struct Config {
github_url: String,
redis_url: String,
redis_ttl: usize,
}
const DEFAULT_REDIS_TTL: usize = 2592000;
const DEFAULT_G... |
use avro_rs::types::Value;
use rdkafka::client::ClientContext;
use rdkafka::config::{ClientConfig, RDKafkaLogLevel};
use rdkafka::consumer::base_consumer::BaseConsumer;
use rdkafka::consumer::{Consumer, ConsumerContext, Rebalance};
use rdkafka::message::BorrowedMessage;
use rdkafka::Message;
use schema_registry_convert... |
use ethcontract::prelude::*;
use std::str::FromStr;
use std::fmt::{Display, Formatter};
/// Trait for CLI arguments that represent an amount of some currency.
pub trait Currency: FromStr {
/// Get the underlying int type.
fn as_inner(&self) -> U256;
}
/// For CLI arguments that take amount of ether.
///
/// S... |
use futures::{Future, Stream, Poll, Async};
use futures::executor::{spawn, Spawn, Notify};
use std::time::{Duration, Instant};
use std::sync::{Arc, Mutex, Condvar};
use std::sync::atomic::{AtomicUsize, Ordering};
/// Wraps a future, providing an API to interact with it while off task.
///
/// This wrapper is intended... |
/*
* Copyright (c) 2016 Boucher, Antoni <bouanto@zoho.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy,... |
use crate::{Call, Error, Trait};
use frame_support::debug;
use frame_system::offchain::{SendSignedTransaction, Signer};
pub fn send_signed<T: Trait>(
signer: Signer<T, T::AuthorityId>,
call: Call<T>,
) -> Result<(), Error<T>> {
// `result` is in the type of `Option<(Account<T>, Result<(), ()>)>`. It is:
... |
use input_i_scanner::{scan_with, InputIScanner};
use join::Join;
use std::cmp::Reverse;
use std::collections::BinaryHeap;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
let (n, m) = scan_with!(_i_i, (usize, usize));
let mut g = vec![vec![]; n];
for _ in... |
// Copyright 2019 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.
use crate::{
channel::ChannelConfigs,
inspect::{AppsNode, StateNode},
};
use failure::{bail, Error, ResultExt};
use fidl_fuchsia_update::{
Chec... |
// compile-flags: -Zalways-encode-mir
static S: usize = 42;
pub fn f() -> &'static usize {
&S
}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C, packed(1))]
pub struct APPLICATION_EVENT_DATA {
pub cbApplicationEventData: u32,
pub ApplicationId: ::windows... |
use cgmath::{Vector2, Zero};
use utilities::prelude::*;
#[derive(Copy, Clone, Debug)]
pub struct ControllerAxis {
pub left_stick: Vector2<f32>,
pub right_stick: Vector2<f32>,
pub left_trigger: f32,
pub right_trigger: f32,
}
impl Default for ControllerAxis {
fn default() -> Self {
Controlle... |
#[doc = "Reader of register SR"]
pub type R = crate::R<u32, super::SR>;
#[doc = "Writer for register SR"]
pub type W = crate::W<u32, super::SR>;
#[doc = "Register SR `reset()`'s with value 0"]
impl crate::ResetValue for super::SR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
const ISA_TESTS: &[(&str, &str)] = &[
("rv32ui", "add"),
("rv32ui", "addi"),
("rv32ui", "and"),
("rv32ui", "andi"),
("rv32ui", "auipc"),
("rv32ui", "beq"),
("rv32ui", "bge"),
("rv32ui", "bgeu"),
("rv32ui", "blt"),
("rv32ui", "bltu"),
("rv32ui", "bne"),
("rv32ui", "fence_i... |
use std::io::Write;
use std::io;
//convenience method for saving a few
//lines of boilerplate when reading a response from
//standard input
fn read_result()->String{
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
input
}
pub fn solution(){
println!("Compounding interest... |
use nalgebra::base::Vector3;
use rand::{
distributions::uniform::{UniformFloat, UniformSampler},
random, thread_rng,
};
use std::f64::consts::PI;
use crate::{
hittable::{HitRecord, Hittable},
material::Material,
};
pub type V3 = Vector3<f64>;
pub type Point = V3;
pub struct Ray {
pub orig: Point... |
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use glib;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::GString;
use glib_sys;
us... |
use crate::ast;
use crate::{Parse, ParseError, Parser, Peeker, Spanned, Storage, ToTokens};
use runestick::Span;
/// A literal value
#[derive(Debug, Clone, PartialEq, Eq, ToTokens, Spanned)]
pub enum Lit {
/// A boolean literal
Bool(ast::LitBool),
/// A byte literal
Byte(ast::LitByte),
/// A string... |
macro_rules! c_str {
($s:expr) => {
concat!($s, "\0").as_ptr() as *const std::os::raw::c_char
};
}
/// Create a `SurfaceDescriptor` from a Winit `Window`.
///
/// # Winit Note
///
/// Winit is in the process of a major API refactor. If using winit `v0.19`, the `winit-eventloop-2`
/// feature needs to b... |
use crate::module::ModuleManifest;
use game_lib::{
anyhow::{anyhow, bail, Context},
bevy::utils::{HashMap, HashSet},
};
use std::{
fmt::{Debug, Formatter},
fs::File,
io::BufReader,
path::{Path, PathBuf},
};
use wasmer::{
import_namespace, ExportError, Instance, Memory, MemoryType, Module, Pa... |
use crate::decode::Decode;
use crate::encode::{Encode, IsNull};
use crate::io::{Buf, BufMut};
use crate::postgres::types::raw::sequence::PgSequenceDecoder;
use crate::postgres::{PgData, PgRawBuffer, PgValue, Postgres};
use crate::types::Type;
use byteorder::BE;
use std::marker::PhantomData;
// https://git.postgresql.o... |
use rust_gpu_tools::{cuda, opencl, program_closures, Device, GPUError, Program};
/// Returns a `Program` that runs on CUDA.
fn cuda(device: &Device) -> Program {
// The kernel was compiled with:
// nvcc -fatbin -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_61,cod... |
use std::collections::BTreeMap;
use std::sync::{Arc, RwLock};
use std::net::{SocketAddr,IpAddr,Ipv4Addr};
use std::error::Error;
use std::thread;
use mio::{EventLoop,EventLoopConfig, Sender, Handler};
use eventual::Async;
use util;
use def::*;
use def::TopologyChangeType::*;
use def::StatusChangeType::*;
use def::Cql... |
#[macro_export]
macro_rules! impl_error_group {
//( $name:ident { $( $x:ident : $y:path ),* } ) |
( enum $name:ident { $( $kind:ident ( $kind_type:path $( , $desc:expr )* ) ),* $(,)* } ) => {
#[derive(Debug)]
enum $name {
$( $kind($kind_type), )*
}
impl ::std::error... |
use std::fmt::{Debug, Display};
use crate::arguments::Arguments;
use crate::connection::Connect;
use crate::cursor::HasCursor;
use crate::error::DatabaseError;
use crate::row::HasRow;
use crate::types::TypeInfo;
use crate::value::HasRawValue;
/// A database driver.
///
/// This trait encapsulates a complete driver im... |
use crate::api::v1::ceo::auth::model::{Login, New, QueryUser, SlimUser, User};
use crate::errors::ServiceError;
use crate::models::msg::Msg;
use crate::models::shop::Shop;
use crate::models::DbExecutor;
use actix::Handler;
use diesel;
use diesel::prelude::*;
use diesel::sql_query;
use serde_json::json;
// register/si... |
use rust_blog::establish_connection;
use rust_blog::models::User;
use rust_blog::schema::users;
use diesel::RunQueryDsl;
fn main() {
let connection = establish_connection();
let results: Vec<User> = users::table.get_results(&connection).unwrap();
results.into_iter().for_each(|user| println!("{:?}", user... |
// #![deny(unsafe_code)]
// #![deny(warnings)]
#![no_main]
#![no_std]
extern crate cortex_m as cm;
extern crate cortex_m_rt as rt;
extern crate panic_itm;
extern crate stm32f1xx_hal as hal;
// #[macro_use(block)]
extern crate nb;
use nb::block;
use cm::iprintln;
use hal::prelude::*;
use hal::{
delay::Delay,
... |
#[macro_use]
extern crate honggfuzz;
extern crate orion;
extern crate ring;
pub mod utils;
use orion::hazardous::constants::SHA512_OUTSIZE;
use orion::hazardous::kdf::{hkdf, pbkdf2};
use utils::{make_seeded_rng, ChaChaRng, RngCore};
fn fuzz_hkdf(fuzzer_input: &[u8], seeded_rng: &mut ChaChaRng) {
let mut ikm = vec... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type CoreFrameworkInputView = *mut ::core::ffi::c_void;
pub type CoreFrameworkInputViewAnimationStartingEventArgs = *mut ::core::ffi::c_void;
pub type CoreF... |
#![allow(non_snake_case)]
//! https://github.com/lumen/otp/tree/lumen/lib/xmerl/src
use super::*;
test_compiles_lumen_otp!(xmerl);
test_compiles_lumen_otp!(xmerl_b64Bin_scan);
test_compiles_lumen_otp!(xmerl_eventp);
test_compiles_lumen_otp!(xmerl_html);
test_compiles_lumen_otp!(xmerl_lib);
test_compiles_lumen_otp!(xm... |
#[rustversion::stable]
#[test]
fn test_compile_errors() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/invalid_macro_args.rs");
t.compile_fail("tests/ui/invalid_property_args.rs");
t.compile_fail("tests/ui/invalid_pyclass_args.rs");
t.compile_fail("tests/ui/invalid_pymethod_names.rs"... |
#![feature(transpose_result)]
extern crate actix_web;
extern crate cookie;
extern crate downcast;
extern crate env_logger;
extern crate failure;
#[macro_use]
extern crate failure_derive;
extern crate fst;
extern crate handlebars;
extern crate itertools;
#[macro_use]
extern crate log;
extern crate pretty_bytes;
extern ... |
// 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.
use crate::ast::ServiceSet;
use failure::Error;
use std::env;
use std::fs;
#[cfg(test)]
use crate::tests;
mod ast;
mod codegen;
#[cfg(test)]
mod tests;
f... |
use crate::analysis::{reaching_definitions, LocationSet};
use crate::il;
use crate::Error;
use std::collections::HashMap;
#[allow(dead_code)]
/// Compute use definition chains for the given function.
pub fn use_def(
function: &il::Function,
) -> Result<HashMap<il::ProgramLocation, LocationSet>, Error> {
let rd... |
// Copyright 2019 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.
use {
failure::{Error, ResultExt},
fidl_fuchsia_test_hub as fhub, fuchsia_async as fasync,
fuchsia_component::client::connect_to_service,
};
m... |
use test_implement::*;
use windows::core::*;
use Windows::Foundation::IClosable;
// TODO: this just tests the syntax until #81 is further along.
#[test]
fn test_implement() -> Result<()> {
let app: IClosable = AppWithOverrides {}.into();
app.Close()?;
let app: IClosable = AppNoOverrides {}.into();
ap... |
use std::borrow::Borrow;
use std::cell::RefCell;
use std::fmt::{Display, Formatter};
use std::fmt;
use std::rc::Rc;
use rand_distr::{Distribution, Normal};
use crate::structs::offset4::Offset4;
use crate::structs::shape4::Shape4;
use crate::structs::view4::View4;
use crate::traits::view::View;
#[derive(Debug)]
pub s... |
{{#if NumericSet}}{{NumericSet}}{{else}}&(){{/if}}
|
#[macro_use]
extern crate guitk;
use guitk::logger;
fn setup_logger() {
logger::set_default_log_tag("pkdx");
logger::set_default_log_priority(logger::LogPriority::DEBUG);
}
fn setup_test_layer(w: f32, h: f32) -> guitk::view::Layer {
use guitk::view::*;
use guitk::entity::core::*;
use guitk::entity::animati... |
use crate::schema;
use arrow::datatypes::{
DataType as ArrowDataType, Field as ArrowField, Schema as ArrowSchema, TimeUnit,
};
use lazy_static::lazy_static;
use regex::Regex;
impl From<&schema::Schema> for ArrowSchema {
fn from(s: &schema::Schema) -> Self {
let fields = s
.get_fields()
... |
//https://leetcode.com/problems/count-the-number-of-consistent-strings/submissions/
impl Solution {
pub fn count_consistent_strings(allowed: String, words: Vec<String>) -> i32 {
let mut good: Vec<bool> = vec![false; 26];
for c in allowed.chars() {
let c_value = c as i32 - 'a' as... |
use super::*;
/// The output of a [`TagAttributeIterator`].
///
/// Attributes within an XML tag are key-value pairs. Only `Start` and `Empty`
/// tags have attributes.
///
/// Each key is expected to only appear once in a given tag. The order of the
/// keys is not usually significant.
#[derive(Debug, Clone, Default,... |
use P80::digraph_converters::labeled;
use P81::*;
pub fn main() {
let g = labeled::from_string("[p>q/9, m>q/7, k, p>m/5]");
println!("Paths from p to q: {:?}", g.find_paths('p', 'q'));
println!("Paths from p to k: {:?}", g.find_paths('p', 'k'));
}
|
extern crate time;
extern crate openrpg;
use time::{PreciseTime};
const MS_PER_UPDATE: i64 = 16;
#[allow(dead_code)]
fn gameloop() {
let mut previous = PreciseTime::now(); // Get Current time
let mut lag: i64 = 0;
loop {
let current = PreciseTime::now();
let elapsed = previous.to(current)... |
use super::connect_params::ServerCerts;
use super::connect_params_builder::ConnectParamsBuilder;
use super::cp_url::UrlOpt;
use crate::{HdbError, HdbResult};
use url::Url;
/// A trait implemented by types that can be converted into a `ConnectParamsBuilder`.
///
/// # Example
/// ```rust
/// use hdbconnect::IntoCon... |
use ndarray::{Array, Array1, Array3, ArrayView3};
use std::convert::From;
use std::ops::{Add, Mul};
use std::vec::IntoIter;
use crate::voxel::Voxel;
use crate::iso_field_generator::ScalarField;
type Indexes = (usize, usize, usize);
type Mask = (usize, usize, usize);
const MASKS: [Mask; 8] = [
(0, 0, 0),
(1, 0... |
use std::ops::{Deref, DerefMut};
use super::*;
pub struct WriteBufferMap <'a, T, Kind, Acces>
where
T: Sized + BufferData,
Kind: BufferType,
Acces: BufferAcces
{
pub(crate) buff: &'a mut Buffer<T, Kind, Acces>,
pub(crate) buffer: &'a mut [T]
}
impl<T, Kind, Acces> Deref for WriteBufferMap<'_, T,... |
mod app;
mod callback;
mod hooks;
use crate::app::AppStartup;
use wasm_bindgen::prelude::*;
use yew::prelude::*;
#[wasm_bindgen(start)]
pub fn run_app() {
App::<AppStartup>::new().mount_to_body();
}
|
#![feature(str_split_once)]
use std::path::Path;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::io::Write;
use std::any::type_name;
mod convert;
mod info;
mod utility;
#[derive(Debug)]
struct Parser {
symbol_stack: Vec<String>,
content_stack: Vec<String>,
}
fn parse_markdown_file(_filename: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.