text stringlengths 8 4.13M |
|---|
use tuple_utils::Split;
use super::{Trie, TrieAnd};
pub trait Join {
type Value;
fn join(self) -> Self::Value;
}
impl<A> Join for (A,)
where A: Trie
{
type Value = A;
fn join(self) -> Self::Value {
self.0
}
}
impl<A, B> Join for (A, B)
where A: Trie,
B: Trie
{
type V... |
#[derive(Debug, thiserror::Error)]
pub enum ServerError {
#[error("custom client error")]
CustomClient(#[from] crate::custom_client::CustomClientError),
#[error("http error")]
Http(#[from] hyper::http::Error),
#[error("hyper error")]
Hyper(#[from] hyper::Error),
#[error("io error")]
Io(#... |
use http::Uri;
use hyper::client::HttpConnector;
use hyper::Client;
use hyper_rustls::HttpsConnector;
use std::sync::mpsc;
use std::sync::mpsc::Sender;
use std::time::{Duration, Instant};
use tokio::prelude::Future;
pub fn run(uri: &Uri, number_of_requests: usize) -> Statistic {
let https = HttpsConnector::new(4);... |
use crate::common::*;
pub(crate) fn canonicalize(path: impl AsRef<Path>) -> Result<PathBuf, Error> {
fs::canonicalize(path.as_ref()).map_err(|io_error| Error::Canonicalize {
io_error,
path: path.as_ref().to_owned(),
})
}
|
// Copyright © 2016 libmussh 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,
//... |
// This file is part of rdma-core. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ... |
//
#![allow(dead_code)]
#![allow(unused_variables)]
mod context;
mod crossroads;
mod ifacedesc;
mod stdimpl;
pub use dbus::tree::MethodErr as MethodErr;
pub use context::Context;
pub use crossroads::{Crossroads, IfaceToken};
pub use ifacedesc::{IfaceDesc, Arguments, Callback, IfaceBuilder};
#[cfg(test)]
mod test;
|
use std::fmt;
use rustc::ty::TyCtxt;
use rustc::session::Session;
use rustc::middle::lang_items::LangItem;
use rustc::middle::exported_symbols::ExportedSymbol;
use rustc::hir::def::{Export, Def};
use rustc::hir::def_id::{DefId, CrateNum, DefIndex, DefIndexAddressSpace};
use rustc_metadata::cstore::{CrateMetadata, Nati... |
#![doc(html_logo_url = "https://raw.githubusercontent.com/mattgathu/cute/master/C!.png")]
//! A Macro for python-esque list and dictionary(hashmap) comprehensions in Rust
//!
//! The `c!` macro implements list and hashmap comprehensions similar to those found in Python,
//! allowing for conditionals and nested comprehe... |
use super::*;
use std::io;
use std::net::SocketAddr;
struct DumbConn;
#[async_trait]
impl Conn for DumbConn {
async fn connect(&self, _addr: SocketAddr) -> io::Result<()> {
Err(io::Error::new(io::ErrorKind::Other, "Not applicable"))
}
async fn recv(&self, _b: &mut [u8]) -> io::Result<usize> {
... |
//#[macro_use]
//extern crate lazy_static;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use std::iter::FromIterator;
use regex::Regex;
const CHECKSUM_LENGTH: usize = 5;
#[derive(Debug)]
struct Room {
name_toks: Vec<String>,
sector_id: u32,
checksum: Strin... |
use std::sync::atomic::{AtomicUsize, Ordering};
pub struct BitMap {
blocks: Vec<AtomicUsize>,
}
const BLK_SIZE: usize = std::mem::size_of::<usize>() * 8;
const BLK_MASK: usize = BLK_SIZE - 1;
impl BitMap {
pub fn with_capacity(cap: usize) -> Self {
let blocks = (cap + BLK_MASK) / BLK_SIZE;
Bit... |
use super::super::BlockId;
use std::collections::HashSet;
use std::rc::Rc;
#[derive(Clone)]
pub enum ChannelPermission {
EveryOne,
Players(HashSet<Rc<String>>),
}
#[derive(Clone)]
pub enum ChannelType {
Public,
Private {
client_id: Rc<String>,
read: ChannelPermission,
write: Ch... |
use crate::{Color, Event};
use std::io::{self, Write};
use std::sync::{mpsc, Arc, Mutex};
use std::thread::JoinHandle;
mod events;
mod flags;
mod input;
mod modes;
mod resize;
pub type WriteResult = Result<usize, io::Error>;
pub struct Terminal {
event_channels: Arc<Mutex<Vec<mpsc::Sender<Event>>>>,
event_thread: ... |
use core::str::Chars;
use text_unit::TextUnit;
pub(crate) struct Ptr<'t> {
text: &'t str,
len: TextUnit,
}
impl<'t> Ptr<'t> {
pub(crate) fn new(text: &'t str) -> Self {
Ptr {
text,
len: 0.into(),
}
}
pub fn into_len(self) -> TextUnit {
self.len
... |
use futures::TryStreamExt;
use warp::http::header::HeaderMap;
use warp::Filter;
#[macro_use]
extern crate log;
use std::io::Write;
#[derive(Debug)]
struct HyperClientError;
impl warp::reject::Reject for HyperClientError {}
#[derive(Debug)]
enum MyError {
Http(reqwest::Error),
}
impl warp::reject::Reject for My... |
pub use super::errors::*;
pub use super::models::*;
pub trait ForContext {
type Output;
fn for_context(&self, context: &str) -> Self::Output;
}
// TODO: borrow content
impl ForContext for Vec<Token<Code>> {
type Output = Vec<Token<Code>>;
fn for_context(&self, context: &str) -> Self::Output {
... |
pub use super::*;
#[derive(Default)]
pub struct DeadScreen;
impl<'a> System<'a> for DeadScreen {
type SystemData = (
Entities<'a>,
ReadExpect<'a, red::Viewport>,
Write<'a, MacroGame>,
Write<'a, Progress>,
Write<'a, UI>,
Write<'a, AppState>,
Write<'a, Current... |
pub fn combination_sum4(mut nums: Vec<i32>, target: i32) -> i32 {
let mut comb = vec![0; target as usize + 1];
comb[0] = 1;
for i in 1..=target as usize {
for &j in &nums {
if j <= i as i32 {
comb[i] += comb[i - j as usize];
}
}
}
comb[target a... |
// Copyright (c) 2017 Anatoly Ikorsky
//
// 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,
// m... |
use std::f64::consts::PI;
const EPSILON: f64 = 1e-6;
const WHOLE_ANGLE: f64 = 360.0;
#[derive(Clone, Copy, Debug)]
pub struct Intersection {
pub point: (f64, f64),
pub normal: (f64, f64),
}
pub trait Shape {
fn intersect(&self, p: (f64, f64), d: (f64, f64)) -> Vec<Intersection>;
fn is_inside(&self, ... |
extern crate iref;
use iref::Iri;
#[test]
fn test1() {
let buffer = "https://www.rust-lang.org/foo/bar#frag";
let iri = Iri::new(buffer).expect("parsing failed");
assert_eq!(iri.scheme(), "https");
assert_eq!(iri.authority().unwrap(), "www.rust-lang.org");
assert_eq!(iri.path(), "/foo/bar");
}
#[test]
fn te... |
use io::{outportb,inportb};
use interrupt::*;
use vga::*;
static mut ticks: usize = 0;
#[allow(unused_variables)]
pub fn timer_tick(regs: Registers)
{
unsafe {
ticks += 1;
if ticks % 100 == 0 {
print!("tick");
}
}
}
pub fn init()
{
::interrupt::register_handler(0, timer_tick);
}
|
use crate::ast;
use crate::{Parse, ParseError, Parser, Spanned, ToTokens};
/// A block of expressions.
#[derive(Debug, Clone, ToTokens, Spanned)]
pub struct ExprAsync {
/// The attributes for the block.
#[rune(iter)]
pub attributes: Vec<ast::Attribute>,
/// The `async` keyword.
pub async_: ast::Asy... |
#![feature(unsafe_destructor, net, io)]
extern crate bincode;
extern crate "rustc-serialize" as serialize;
extern crate bchannel;
pub use tcp::{OutTcpStream, InTcpStream, upgrade_tcp, connect_tcp, listen_tcp};
pub use bincode::SizeLimit;
pub mod tcp;
|
extern crate rand;
use std::io;
use std::cmp::Ordering;
use rand::Rng;
fn main()
{
println!("Vamos a adivinar!");
let numero_elegido = rand::thread_rng().gen_range(1, 101);
loop{
println!("Ingresa un numero del 1 al 100");
let mut adi = String::new();
io::stdin().read_line(&mut adi)
.ok()
.expect("Fall... |
#[doc = "Register `EXTI_EMR1` reader"]
pub type R = crate::R<EXTI_EMR1_SPEC>;
#[doc = "Register `EXTI_EMR1` writer"]
pub type W = crate::W<EXTI_EMR1_SPEC>;
#[doc = "Field `EM0` reader - EM0"]
pub type EM0_R = crate::BitReader;
#[doc = "Field `EM0` writer - EM0"]
pub type EM0_W<'a, REG, const O: u8> = crate::BitWriter<'... |
use std::collections::HashSet;
use regex::Regex;
use crate::{Selector, SkimItem};
#[derive(Debug, Default)]
pub struct DefaultSkimSelector {
first_n: usize,
regex: Option<Regex>,
preset: Option<HashSet<String>>,
}
impl DefaultSkimSelector {
pub fn first_n(mut self, first_n: usize) -> Self {
... |
pub(crate) trait HavingDateValidation {
/// checks emptiness of given date string/s.
fn is_given_date_empty(&self) -> bool;
/// checks validity of given date string/s.
fn is_string_length_valid(&self) -> bool;
// checks overall criteria and includes all the required checking functions.
fn is_... |
use std::collections::HashSet;
use utils;
pub fn problem_023() -> u64 {
let n: u64 = 28124;
let abundant_numbers: Vec<u64> = (1..n).filter(|&x| utils::proper_divisors(x).iter().fold(0,|a,&b| a+b) > x).collect();
let mut sum = HashSet::new();
for num_a in abundant_numbers.clone().into_iter(){
... |
use std::fmt;
use serde::{
de,
ser::{self, SerializeSeq},
};
#[derive(Debug, PartialEq)]
pub enum UniqueItems {
Boolean(bool),
Paths(Vec<String>),
}
impl Default for UniqueItems {
fn default() -> UniqueItems {
UniqueItems::Boolean(false)
}
}
impl UniqueItems {
pub fn is_unique(&s... |
use deck::Card;
#[derive(Serialize, Deserialize, Debug)]
pub enum LobbyToken {
Create(u32, String, String, bool), // As Client, request to create a lobby, u32 doesn't matter, 1st String is the lobby name, 2nd String is the requested password, bool indicates hidden lobby. As Server, u32 is player_id who requests a ... |
use itertools::Itertools;
use std::collections::HashMap;
static FILE: &str = include_str!("../inputs/10.txt");
lazy_static! {
static ref LINES: Vec<i64> = FILE
.lines()
.map(|s| s.parse::<i64>().unwrap())
.sorted()
.collect_vec();
}
pub(crate) fn part1() {
println!("day 10 par... |
#[allow(dead_code)]
pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
// we will get better error messages if our code ever panics.
//
// For more details see
// https://... |
fn main() {
proconio::input! {
n: usize,
t: [i32; n],
m: usize,
px: [(usize, i32); m],
}
// println!("{:?}", t);
// println!("{:?}", px);
let sum: i32 = t.iter().sum();
// println!("{}", sum);
for i in 0..m {
println!("{}", sum + (px[i].1 - t[px[i].0... |
//! Resource enums.
use http::Method;
/// Resource
#[derive(Debug)]
pub enum Resource {
Show,
Create,
Update(Method),
Delete,
Edit,
New,
}
impl Resource {
pub fn as_tuple(&self) -> (&str, Method) {
match self {
Self::Show => ("", Method::GET),
Self::Create ... |
// El discurso de Zoe
//
// Copyright (C) 2016 GUL UC3M
//
// 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 Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Th... |
#![feature(proc_macro_hygiene)]
#![feature(stmt_expr_attributes)]
const ROOT: &'static str = "https://yolodev.github.io/semantic-rpg/";
const DIRS: &'static [&'static str] = &["data", "schema"];
const OUT_DIR: &'static str = "out";
use std::path::Path;
use tracing::info;
mod rdf;
mod walker;
mod writer;
// mod turtl... |
//! Tests auto-converted from "sass-spec/spec/non_conformant/parser/malformed_expressions/at-error"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/non_conformant/parser/malformed_expressions/at-error/incomplete-expression.hrx"
// Ignoring "incomplete_expression", error tests are not supported yet.
// Fro... |
#![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 domains {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub async fn g... |
pub fn run() {
println!("patterns");
}
|
pub mod cp1;
pub mod runner;
|
#![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
extern crate byteorder;
extern crate mio;
extern crate slab;
mod worker;
mod connection;
mod server;
pub mod errors {
use worker::MsgBuf;
// Create the Error, ErrorKind, ResultExt, and Result types
error_... |
extern crate chrono;
use std::io::prelude::*;
use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian};
use self::chrono::{Duration, NaiveDate, NaiveTime, NaiveDateTime, DateTime, UTC, Local,
FixedOffset};
use Result;
use error::Error;
use types::{FromSql, ToSql, IsNull, Type, SessionInfo};
fn base... |
/// An enum to represent all characters in the Lisu block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Lisu {
/// \u{a4d0}: 'ꓐ'
LetterBa,
/// \u{a4d1}: 'ꓑ'
LetterPa,
/// \u{a4d2}: 'ꓒ'
LetterPha,
/// \u{a4d3}: 'ꓓ'
LetterDa,
/// \u{a4d4}: 'ꓔ'
LetterTa,
/// \u{a... |
use actix_http::ResponseBuilder;
use actix_web::error::ResponseError;
use actix_web::{http::StatusCode, HttpResponse};
use log::{error, info};
use serde_json::json;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Errors {
#[error("user exists")]
UserExists(String),
#[error("invalid login")]
... |
use crossterm::{cursor, terminal, RawScreen};
use crossterm::{InputEvent, KeyEvent};
use nu::{
serve_plugin, AnchorLocation, CallInfo, Plugin, Primitive, ShellError, Signature, SourceMap,
Tagged, Value,
};
use syntect::easy::HighlightLines;
use syntect::highlighting::{Style, ThemeSet};
use syntect::parsing::Sy... |
// Copyright 2016 The Fancy Regex Authors.
//
// 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, modify, merge, p... |
#[macro_use]
extern crate log;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate bitflags;
mod config;
mod rdwm;
use env_logger::WriteStyle::Auto;
use rdwm::Rdwm;
/// Starts logging for Rdwm and initialises the main event loop.
fn main() -> Result<(), Box<dyn std::error::Error>> {
env_logger::buil... |
use std::time::SystemTime;
fn main() {
hw21();
}
fn hw21() {
let local1 = SystemTime::now();
hw2();
let local2 = SystemTime::now();
let rtime = local2.duration_since(local1);
println!("{:?}", rtime);
}
fn hw2() {
let mut tx: i32 = 0;
for x in 0..10000000 {
if hw(x) == true {
... |
use serde::{Deserialize, Serialize};
use typesense::document::Document as DocumentTrait;
use typesense::ClientBuilder;
use typesense::Document;
#[cfg(all(test, feature = "tokio-rt", not(target_arch = "wasm32")))]
mod hyper_tests {
use super::*;
#[tokio::test]
async fn collection_create() {
let host... |
use std::fmt;
use ::symb::base::{Node, NodeID, NodeData};
use ::symb::graph::{Graph};
use ::arrayfire::{Dim4};
//TODO: variants with mu/sigma for normal, p0/p1 for uniform, reparam-based grad
#[derive(Debug)]
pub struct Uniform {
dims: Dim4,
}
impl Uniform {
pub fn new(dims: Dim4) -> Box<Uniform> {
... |
// An attribute to hide warnings for unused code.
#![allow(dead_code)]
/* 来自 Tuples BEGIN */
use std::fmt; // Import `fmt`
// Tuples can be used as function arguments and as return values.
fn reverse(pair: (i32, bool)) -> (bool, i32) {
// `let` can be used to bind the members of a tuple to variables.
let (int_... |
#[doc = "Register `PTPPPSCR` reader"]
pub type R = crate::R<PTPPPSCR_SPEC>;
#[doc = "Field `PPSFREQ` reader - PPS frequency selection"]
pub type PPSFREQ_R = crate::FieldReader<PPSFREQ_A>;
#[doc = "PPS frequency selection\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum PPSFREQ_A ... |
/// NO. 55: Jump Game
pub struct Solution;
// ----- submission codes start here -----
impl Solution {
pub fn can_jump(nums: Vec<i32>) -> bool {
let mut reach = 0;
for (i, &v) in nums.iter().enumerate() {
if i > reach { return false; }
reach = reach.max(i + v as usize);
... |
use regex::Regex;
use std::collections::{HashMap, HashSet};
const INPUT: &str = include_str!("../../input/day_4.txt");
fn main() {
let passports = parse_passports(INPUT);
let required_fields_validator = RequiredFieldsValidator::new();
let valid_passports = passports
.iter()
.filter(|p| re... |
pub use self::sysval::NodeValue;
pub use self::sysval::Overview;
// pub use self::systemvalues::NodeValue;
// pub use self::systemvalues::Overview;
mod sysval;
// mod systemvalues;
|
use cpython::ObjectProtocol; //for call method
use cpython::{PyBytes, PyDict, PyErr, PyObject, PyString, Python, NoArgs, ToPyObject};
use std::collections::HashMap;
use std::fmt;
use term_painter::ToStyle;
use term_painter::Color::*;
use term_painter::Attr::*;
use super::checks::*;
use super::protocols::*;
pub type K... |
//! A tiny asynchronous HTTP/1.1 client library.
//!
//! # Examples
//!
//! ```no_run
//! # extern crate fibers_global;
//! # extern crate fibers_http_client;
//! # extern crate url;
//! use fibers_http_client::connection::Oneshot;
//! use fibers_http_client::Client;
//! use url::Url;
//!
//! # fn main() {
//! let url ... |
pub fn setup() {
println!("Setup it");
}
|
macro_rules! set {
{ $( $n:expr ),* } => {
{
use std::collections::HashSet;
#[allow(unused_mut)]
let mut tmp = HashSet::new();
$(
tmp.insert($n);
)*
tmp
}
};
}
macro_rules! map {
{ $( $n:tt : $v:expr ),... |
use std::collections::{HashMap, HashSet};
static FILENAME: &str = "input/data";
static DIRECTIONS: [Coord; 6] = [(1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1)];
type Coord = (isize, isize);
enum Direction {
E, // (1, 0)
SE, // (1, -1)
SW, // (0, -1)
W, // (-1, 0)
NW, // (-1, 1)
NE, // ... |
//! Memory Protection Unit
use volatile_register::{RO, RW};
/// Register block for ARMv7-M
#[cfg(not(armv8m))]
#[repr(C)]
pub struct RegisterBlock {
/// Type
pub _type: RO<u32>,
/// Control
pub ctrl: RW<u32>,
/// Region Number
pub rnr: RW<u32>,
/// Region Base Address
pub rbar: RW<u32>... |
use super::{Game, Unit, CELL_SIZE, CELL_PADDING, cell_pos};
use std::ops::{Index, IndexMut};
use graphics::Context;
use opengl_graphics::GlGraphics;
use vec_map::VecMap;
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum Cell {
Empty,
Floor,
}
#[derive(Clone)]
pub struct Grid {
pub grid: Vec<Cell>,
... |
mod bcrypt_hasher;
mod jwt_encoder;
pub use bcrypt_hasher::*;
pub use jwt_encoder::*;
|
use std::fmt;
use std::result;
use cassandra::CassError_;
error_chain! {
errors {
LIB_BAD_PARAMS(t:CassError_){}
LIB_NO_STREAMS (t:CassError_){}
LIB_UNABLE_TO_INIT(t:CassError_){}
LIB_MESSAGE_ENCODE(t:CassError_){}
LIB_HOST_RESOLUTION(t:CassError_){}
LIB_UNEXPECTED_RESPONSE(t:CassError_){}
... |
use amethyst::shrev::{EventChannel, ReaderId};
use amethyst::ecs::{Entities, Join, Read, ReadStorage, System, SystemData, World, WriteStorage};
use amethyst::input::{InputEvent, InputEvent::ActionPressed, StringBindings};
use crate::components::{Direction, Action, Intent, Player};
#[derive(Default)]
pub struct InputS... |
extern crate serde;
extern crate serde_json;
mod tqapi_ffi;
mod dapi;
mod tapi;
mod utils;
pub mod api {
pub use super::dapi::*;
pub use super::tapi::*;
pub use super::utils::*;
}
|
use std::char;
use unicode_xid::UnicodeXID;
use {
LexError,
Span,
Symbol,
ByteSymbol,
TokenStream,
TokenTree,
TokenKind,
Delimiter,
CommentKind,
OpJoin,
IntVal,
FloatVal,
};
pub fn lex_str(input: &str, offset: usize) -> Result<TokenStream, LexError> {
let mut lexer... |
use crate::options::ParseOptions;
use std::error::Error;
use std::fmt;
use std::sync::Arc;
use std::sync::RwLock;
use swc_common::errors::Emitter;
use swc_common::{
self,
comments::Comments,
errors::{Diagnostic, DiagnosticBuilder, Handler, HandlerFlags},
FileName, Globals, SourceMap,
};
use swc_ecma_par... |
use std::fmt::Debug;
use crate::{
bson::{doc, spec::ElementType, Bson, Document},
bson_util::get_int,
event::{cmap::CmapEvent, command::CommandEvent, sdam::ServerDescription},
test::{Event, SdamEvent},
};
use super::{
test_event::{ExpectedSdamEvent, TestServerDescription},
EntityMap,
Expec... |
//! Handles thread related syscalls.
use core::time::Duration;
/// The number of the exit syscall.
const SLEEP_SYSCALL_NUM: u64 = 4;
/// The number of the syscall to create a new thread.
const NEW_THREAD_SYSCALL_NUM: u64 = 5;
/// Kills the current thread.
const KILL_THREAD_SYSCALL_NUM: u64 = 6;
/// Lets the curren... |
use isaribi::{
style,
styled::{Style, Styled},
};
use nusa::prelude::*;
pub struct Props {}
pub enum Msg {}
pub enum On {}
pub struct Common;
impl Common {
pub fn layered() -> String {
Self::styled(Self::class("layered"))
}
pub fn layered_item() -> String {
Self::styled(Self::c... |
use math::vec::*;
use math::quat::*;
use math::traits::*;
use std::ops::*;
use std::mem;
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(C)]
pub struct M2x2 {
pub x: V2,
pub y: V2,
}
#[derive(Copy, Clone, Debug, PartialEq)]
#[repr(C)]
pub struct M3x3 {
pub x: V3,
pub y: V3,
pub z: V3,
}
#[derive... |
use crate::{qjs, Result};
use symbolic_common::{Language, Name, NameMangling};
use symbolic_demangle::{Demangle, DemangleOptions};
#[derive(Debug, Clone, Default)]
pub struct SymbolInfo {
pub symbol: String,
pub language: Option<String>,
pub mangled: Option<bool>,
}
impl From<SymbolInfo> for String {
... |
use super::Token;
/// contains all the parsing structures of ghvm
use pest::{iterators::Pair, Parser};
use std::collections::HashMap;
#[derive(Parser)]
#[grammar = "parser/grammar_indented.pest"]
struct DispParser;
#[cfg(test)]
mod tests;
pub fn parse(body: &str) -> Token {
parse_rule(Rule::head, body)
}
fn par... |
pub fn read<T: std::str::FromStr>() -> T {
let mut s = String::new();
std::io::stdin().read_line(&mut s).ok();
s.trim().parse().ok().unwrap()
}
pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
read::<String>()
.split_whitespace()
.map(|e| e.parse().ok().unwrap())
.collect()
}... |
use reqwest::Url;
use uuid::Uuid;
use crate::{traits::IntoUuid, Client, Device, Result};
pub struct Devices {
pub(crate) client: Client,
}
impl Devices {
pub(crate) fn scoped(&self, location_id: Uuid) -> ScopedDevices {
ScopedDevices {
client: self.client.clone(),
location_id,... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
pub mod index_configuration;
pub use index_configuration::IndexConfiguration;
pub mod index_write_parameters;
pub use index_write_parameters::*;
pub mod disk_index_build_parameter;
pub use disk_index_build_parameter... |
use tokio::net::TcpListener;
use tokio::prelude::*;
use tokio::stream::StreamExt;
use tokio::net::TcpStream;
use tokio::stream::Stream;
use std::pin::Pin;
use std::task::{Context, Poll};
pub struct StreamReader {
source: TcpStream,
}
impl StreamReader {
pub fn new(r: TcpStream) -> Self {
StreamReade... |
//!
//! Support to register an [`EglDevice`](EglDevice)
//! to an open [`Session`](::backend::session::Session).
//!
use drm::control::crtc;
use std::os::unix::io::RawFd;
use super::EglDevice;
use crate::backend::drm::Device;
use crate::backend::egl::native::{Backend, NativeDisplay, NativeSurface};
use crate::backend... |
extern crate gl;
extern crate image;
use self::image::{DynamicImage, GenericImage};
use self::image::DynamicImage::*;
use std::os::raw::c_void;
pub struct Texture {
pub id: u32,
}
impl Texture {
// TODO(orglofch): Decouple this from an image so we can programatically
// generate textures.
pub unsafe ... |
extern crate byteorder;
use std::io::Cursor;
use self::byteorder::{ReadBytesExt, WriteBytesExt, BigEndian, LittleEndian};
use std::iter::FromIterator;
pub enum Endian {
Big = 0,
Little = 1,
}
pub fn read_short(bytes: Vec<u8>, endian: Endian) -> i16 {
match endian {
Endian::Big => return Cursor::read_i16::<BigEndi... |
use arr_macro::arr;
use std::cmp;
use crate::card;
use crate::pile;
pub struct Tableau {
pub piles: [pile::Pile; 7]
}
impl Tableau {
pub fn new() -> Tableau {
Tableau{piles: arr![pile::Pile::new(); 7]}
}
pub fn display(&self) -> String {
let rows = self.max_rows();
let mut display = "||__1__||__... |
#![allow(dead_code)]
#![allow(unused_imports)]
#![feature(proc_macro_hygiene, decl_macro)]
#![feature(try_trait)]
#[macro_use]
extern crate serde;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate serde_json;
use pyo3::prelude::*;
use pyo3::types::PyDict;
use pyo3::wrap_pyfunction;
pub mod common;
pub... |
use std::io;
use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket};
#[cfg(feature = "io_timeout")]
use std::time::Duration;
use super::super::{co_io_result, EventData};
use crate::coroutine_impl::{is_coroutine, CoroutineImpl, EventSource};
use crate::scheduler::get_scheduler;
use miow::net::... |
//! Facilities for working with Array `napi_value`s.
use raw::{Local, Env};
use nodejs_sys as napi;
pub unsafe extern "C" fn new(_out: &mut Local, _env: Env, _length: u32) { unimplemented!() }
/// Gets the length of a `napi_value` containing a JavaScript Array.
///
/// # Panics
/// This function panics if `array` i... |
extern crate assign7;
extern crate time;
#[macro_use]
extern crate clap;
extern crate serde;
#[macro_use]
extern crate serde_json;
use clap::{Arg, App};
use std::collections::HashMap;
use assign7::*;
use time::now;
use std::sync::Arc;
use op::*;
macro_rules! bench {
($name:expr, $f:expr, $v:expr, $ops:expr) => {{... |
//#![allow(unused)]
use std::io::prelude::*;
use std::io;
use std::str;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, TcpListener, TcpStream};
fn handle_client(mut stream: TcpStream) -> io::Result<()> {
println!("Got a client! {:?}", stream);
stream.write(b"khi\n");
stream.flush();
let mut ... |
extern crate failure;
use std::collections::HashSet;
use std::env;
use std::fs::File;
use std::io::{BufRead, BufReader};
use failure::Error;
fn main() -> Result<(), Error> {
let args: Vec<String> = env::args().collect();
let file = File::open(&args[1])?;
let changes: Vec<i32> = BufReader::new(file)
... |
use std::collections::HashMap;
/// Retrieve a team's profile.
///
/// Wraps https://api.slack.com/methods/team.profile.get
#[derive(Clone, Debug, Serialize, new)]
pub struct GetRequest {
/// Filter by visibility.
#[new(default)]
pub visibility: Option<Visibility>,
}
#[derive(Clone, Debug, Serialize)]
#[s... |
// Kevin Cantu
// additional vector functions
#[link(name = "vec2", author = "kcantu", vers = "0.0")];
use std;
fn windowed <TT: copy> (nn: uint, xx: [TT]) -> [[TT]] {
let ww = [];
assert 1u <= nn;
vec::iteri (xx, {|ii, _x|
let len = vec::len(xx);
if ii+nn <= len {
let w = vec::slice ... |
extern crate lockbox_lib;
use lockbox_lib::{encryption};
#[test]
fn test_encryption() -> Result<(), std::io::Error> {
match encryption::generate_keys() {
_ => {
let cryptobox = encryption::load_keys().expect("Unable to load encryption keys");
let to_encrypt = String::from("someran... |
mod data;
mod db;
mod handlers;
mod models;
mod routes;
use db::DB;
use routes::router;
pub type Result<T> = std::result::Result<T, warp::Rejection>;
#[tokio::main]
async fn main() {
let db: DB = DB::connect().await.expect("Error creating the db");
let routes = router(db);
warp::serve(routes).run(([127, ... |
//! Supplemental Streaming SIMD Extensions 3 (SSSE3)
use mem::transmute;
use simd::*;
/// Shuffle bytes from `a` according to the content of `b`.
///
/// The last 4 bits of each byte of `b` are used as addresses
/// into the 16 bytes of `a`.
///
/// In addition, if the highest significant bit of a byte of `b`
/// is ... |
macro_rules! create_function {
($func_name:ident) => {
fn $func_name() {
println!("You called {:?}()", stringify!($func_name));
}
};
}
create_function!(foo);
create_function!(bar);
fn main() {
foo();
bar();
}
|
// =========================
// Ppprzlink Messages
// =========================
use std::fs::File;
use std::io::BufReader;
use std::fmt;
use super::xml::reader::{EventReader, XmlEvent};
use super::xml::attribute::OwnedAttribute;
/// define constants
const V1_V2_SENDER_ID: usize = 0;
pub const V1_MSG_ID: usize = 1;
con... |
#[doc = "Reader of register US_OFFSET_STATUS"]
pub type R = crate::R<u32, super::US_OFFSET_STATUS>;
#[doc = "Reader of field `US_OFFSET`"]
pub type US_OFFSET_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:15 - During slave connection event, HW updates this register with the calculated us_offset at anchor point, g... |
use crate::StringExt;
use super::super::{FullType, TypeID};
#[derive(Copy, Clone, Eq, PartialEq)]
#[repr(u8)]
pub enum BuiltinType {
Void,
Bool,
SignedChar,
UnsignedChar,
SignedShort,
UnsignedShort,
SignedInt,
UnsignedInt,
SignedLong,
UnsignedLong,
Float,
Double,
... |
/*
Copyright ⓒ 2016 rust-custom-derive contributors.
Licensed under the MIT license (see LICENSE or <http://opensource.org
/licenses/MIT>) or the Apache License, Version 2.0 (see LICENSE of
<http://www.apache.org/licenses/LICENSE-2.0>), at your option. All
files in the project carrying such notice may not be copied, m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.