text stringlengths 8 4.13M |
|---|
#![cfg_attr(feature="clippy", feature(plugin))]
#![cfg_attr(feature="clippy", plugin(clippy))]
extern crate glium;
extern crate glium_text;
extern crate cgmath;
#[macro_use]
extern crate clap;
use std::io::Read;
use std::fs::File;
use std::time::Duration;
use std::thread;
use clap::{Arg, App};
use glium::{DisplayBu... |
use crate::budget::data::{Budget, BudgetEntry, NewBudgetEntry};
use crate::datastruct::SqlResult;
use chrono::Utc;
use rusqlite::{params, Result};
use std::ops::DerefMut;
pub fn get_budget(
conn: r2d2::PooledConnection<r2d2_sqlite::SqliteConnectionManager>,
id: i32,
) -> Result<Budget> {
let mut stmt = con... |
use alloc::sync::Arc;
use rcore_fs::vfs::FileSystem;
use linux_object::fs::MemBuf;
use kernel_hal_bare::drivers::virtio::{BlockDriverWrapper, BLK_DRIVERS};
pub fn init_filesystem(ramfs_data: &'static mut [u8]) -> Arc<dyn FileSystem> {
#[cfg(target_arch = "x86_64")]
let device = Arc::new(MemBuf::new(ramfs_data)... |
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let h: usize = rd.get();
let w: usize = rd.get();
let a: Vec<Vec<char>> = (0..h)
.map(|_| {
let r: String = rd.get();
r.chars().collect::<Vec<char>>()
})
.collect(... |
use std::{convert::TryFrom, ffi::OsString, os::windows::prelude::OsStringExt};
use win32_error::Win32Error;
use winapi::shared::minwindef::FALSE;
use winapi::um::handleapi::{CloseHandle, INVALID_HANDLE_VALUE};
use winapi::um::tlhelp32::{
CreateToolhelp32Snapshot, Process32FirstW, Process32NextW,
PROCESSENTRY32W... |
extern crate permutohedron;
extern crate pcre;
use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
use std::collections::{HashMap, HashSet};
use std::cmp::{min, max};
use permutohedron::Heap;
use pcre::Pcre;
fn main() {
let f = File::open("day9.in").unwrap();
let file = BufReader::new(&f);
l... |
#[cfg(feature = "rustpython-ast")]
pub(crate) mod ast;
pub mod atexit;
pub mod builtins;
mod codecs;
mod collections;
pub mod errno;
mod functools;
mod imp;
pub mod io;
mod itertools;
mod marshal;
mod operator;
// TODO: maybe make this an extension module, if we ever get those
// mod re;
mod sre;
mod string;
#[cfg(feat... |
use std::fmt;
use std::fs::{self, File};
use std::io::{BufReader, Read, Write};
use std::path::Path;
use std::str::FromStr;
use chrono::prelude::*;
use glob::glob;
use serde::{Deserialize, Serialize};
use slog::Logger;
use zip::write::FileOptions;
use zip::{ZipArchive, ZipWriter};
use crate::connection::Connection;
u... |
use serde::{Deserialize, Serialize};
use std::fmt::Write;
use time::{OffsetDateTime, UtcOffset};
use crate::{
default_datetime, direction::Direction, distance::Distance, humidity::Humidity,
latitude::Latitude, longitude::Longitude, precipitation::Precipitation, pressure::Pressure,
speed::Speed, temperature... |
use std::{
convert::TryInto,
io::{self, Read, Write},
};
use tokio::{
io::{AsyncRead, AsyncWrite},
prelude::Async,
sync::lock::Lock,
};
use zmq::{Context, Message, Result, Socket, REQ};
use enclave_protocol::FLAGS;
macro_rules! lock {
($e:expr) => {
match $e.poll_lock() {
... |
//! Passes between intermediate languages.
//!
//! The most significant step in this process is the [`surface_to_core`] pass,
//! which handles elaboration of the surface language into the core language,
//! and is the source of most user-facing typing diagnostics.
pub mod core_to_pretty;
pub mod core_to_surface;
pub ... |
use super::is_transient_error;
use crate::listener::Listener;
use crate::{log, Server};
use std::fmt::{self, Display, Formatter};
use async_std::net::{self, SocketAddr, TcpStream};
use async_std::prelude::*;
use async_std::{io, task};
/// This represents a tide [Listener](crate::listener::Listener) that
/// wraps a... |
use crate::v0::support::{
try_only_named_multipart, with_ipfs, MaybeTimeoutExt, NotImplemented, StringError,
StringSerialized,
};
use cid::{Cid, Codec};
use futures::stream::Stream;
use ipfs::{Ipfs, IpfsTypes};
use mime::Mime;
use serde::Deserialize;
use serde_json::json;
use warp::{query, reply, Buf, Filter, ... |
//! Representations of various client errors
use std::io::Error as IoError;
use hyper::Error as HttpError;
use hyper::status::StatusCode;
use rustc_serialize::json::{DecoderError, EncoderError, ParserError};
#[derive(Debug)]
pub enum Error {
Decoding(DecoderError),
Encoding(EncoderError),
Parse(ParserErro... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type AppServiceClosedEventArgs = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct AppServiceClosedStatus(pub i32);
impl AppServiceClosedStatus {
... |
//! UDP relay local server
use std::{io, net::SocketAddr, sync::Arc, time::Duration};
use async_trait::async_trait;
use log::{debug, error, info, trace, warn};
use tokio::{self, net::UdpSocket, time};
use crate::{
context::SharedContext,
relay::{
loadbalancing::server::{PlainPingBalancer, ServerType}... |
use crate::{
mock::{Origin, ProviderMembers, TestProvider, USD_ASSET},
Balance, Call, Module, Trait,
};
use alloc::{boxed::Box, vec, vec::Vec};
use frame_benchmarking::{benchmarks, whitelisted_caller};
use frame_system::{offchain::SigningTypes, RawOrigin};
use vln_commons::{
runtime::{AccountId, Signature},... |
use super::error_types::XpsError;
use super::loader::open;
use super::types;
use std::alloc::{dealloc, Layout};
use std::ffi::CStr;
use std::os::raw::c_char;
use std::ptr;
#[repr(C)]
pub struct Vector3 {
x: f32,
y: f32,
z: f32,
}
#[repr(C)]
pub struct Vector2 {
x: f32,
y: f32,
}
#[repr(C)]
pub st... |
use core::cmp::{Eq, Ord};
use std::list;
use std::list::{List, Cons, Nil};
/**
* A purely functional Pairing Heap [FSST86]
*
* Our implementation uses Linked List (cons cells) so may not be the
* fastest way to implement this in Rust.
*
* This implementation is a port of the Standard ML found in Okasaki's
* Pur... |
use std::default::Default;
use std::ops::Sub;
use std::time::Duration;
pub trait Pacer {
/// fn pace(&self, elapsed: Duration, hits: u64) -> (wait: Duration, stop: bool)
fn pace(&self, elapsed: Duration, hits: u64) -> (Duration, bool);
fn rate(&self, elapsed: Duration) -> f64;
}
#[derive(Clone, Debug, Par... |
// 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 ... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct CurrencyFormatter(pub ::windows::core::IInspec... |
fn main() {
println!("usage: cargo run --bin day_*");
}
|
use super::xtunel_connect;
use super::XReqq;
use crate::config::{TunCfg, KEEP_ALIVE_INTERVAL};
use crate::lws::{RMessage, TMessage, WMessage};
use crate::tunnels::{Cmd, THeader, THEADER_SIZE};
use byte::*;
use failure::Error;
use futures_03::prelude::*;
use log::{debug, error, info};
use nix::sys::socket::{shutdown, Sh... |
#[doc = "Reader of register EEPASS0"]
pub type R = crate::R<u32, super::EEPASS0>;
#[doc = "Writer for register EEPASS0"]
pub type W = crate::W<u32, super::EEPASS0>;
#[doc = "Register EEPASS0 `reset()`'s with value 0"]
impl crate::ResetValue for super::EEPASS0 {
type Type = u32;
#[inline(always)]
fn reset_va... |
// Copyright 2021 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 ... |
use super::Constant;
use super::run_fn;
pub fn map(args: Vec<Constant>) -> Constant {
let pair: (&Constant, &Constant) = (args.get(0).unwrap(), args.get(1).unwrap());
match pair {
(&Constant::Function(ref v1), &Constant::List(ref v2)) =>
Constant::List(v2.into_iter().map(|a| run_fn(Constant::Function(v1... |
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
pub fn run_puzzle() {
let file = File::open("input_day3.txt").expect("Failed to open input_day3.txt");
let br = BufReader::new(file);
let mut wires: HashMap<(i64, i64), (u64, u64)> = HashMap::new();
let mut curwire = ... |
#[doc = "Reader of register D2CCIP2R"]
pub type R = crate::R<u32, super::D2CCIP2R>;
#[doc = "Writer for register D2CCIP2R"]
pub type W = crate::W<u32, super::D2CCIP2R>;
#[doc = "Register D2CCIP2R `reset()`'s with value 0"]
impl crate::ResetValue for super::D2CCIP2R {
type Type = u32;
#[inline(always)]
fn re... |
// 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 {
bitfield::bitfield,
failure::{bail, format_err, Error, ResultExt},
fidl::endpoints::ClientEnd,
fidl_fuchsia_media::{
AudioSam... |
use std::env::current_dir;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::time::Duration;
use process_control::{ChildExt, ExitStatus, Output, Timeout};
#[allow(unused_macros)]
macro_rules! test_stdout {
($func_name:ident, $expected_stdout:literal) => {
#[test]
fn $fun... |
#[doc = "Reader of register DIFSEL"]
pub type R = crate::R<u32, super::DIFSEL>;
#[doc = "Writer for register DIFSEL"]
pub type W = crate::W<u32, super::DIFSEL>;
#[doc = "Register DIFSEL `reset()`'s with value 0"]
impl crate::ResetValue for super::DIFSEL {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
pub use self::path::{ReadPath, WritePath};
pub use self::state::State;
use std::fmt::Debug;
use std::future::Future;
use std::pin::Pin;
use deck_core::FilesystemId;
mod path;
mod state;
// NOTE: All this noise has been to work fine with a simple `async fn`, with no need for associated
// types, this type alias, or ... |
extern crate fiber;
use fiber::Fiber;
#[test]
fn basic_usage() {
fn fiber_proc(suspended: Fiber) -> ! {
println!("Suspended fiber: {:?}", suspended);
unsafe { suspended.resume(); }
panic!("Uh-oh, shouldn't have resumed this fiber again");
}
let fiber = Fiber::new(1024, fiber_proc... |
#[path = "spawn_link_1/with_function.rs"]
pub mod with_function;
// `without_function_errors_badarg` in unit tests
|
use std::io::{Read, Result as IOResult};
use nalgebra::{Vector2, Vector3};
use crate::{PrimitiveRead, BoneWeight};
#[derive(Clone)]
pub struct Vertex {
pub bone_weights: BoneWeight,
pub vec_position: Vector3<f32>,
pub vec_normal: Vector3<f32>,
pub vec_tex_coord: Vector2<f32>,
}
impl Vertex {
pub fn read(r... |
pub mod entity;
pub mod camera;
|
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn serialize_operation_create_replication_set(
input: &crate::input::CreateReplicationSetInput,
) -> Result<smithy_http::body::SdkBody, smithy_types::Error> {
let mut out = String::new();
let mut object = smithy_json::seria... |
// auto generated, do not modify.
// created: Wed Jan 20 00:44:03 2016
// src-file: /QtNetwork/qnetworkaccessmanager.h
// dst-file: /src/network/qnetworkaccessmanager.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block e... |
use std::fmt;
use std::iter;
use std::ops::{Index, Mul};
use super::tools::iter_complement;
/// Naive representation of a matrix as a single consecutive chunk of memory.
pub struct Matrix<T> {
height: usize,
width: usize,
data: Vec<T>,
}
// Custom trait for matrices that can be right-multiplied by a c... |
use std::mem::ManuallyDrop;
use win32_error::Win32Error;
use winapi::um::{
handleapi::CloseHandle,
memoryapi::{ReadProcessMemory, VirtualAllocEx, VirtualFreeEx, WriteProcessMemory},
processthreadsapi::CreateRemoteThread,
synchapi::WaitForSingleObject,
winbase::*,
winnt::*,
};
use crate::os::wi... |
use super::super::constants::*;
use super::FileTypeTrait;
use libc::c_int;
use std::fs;
#[derive(Debug, Clone)]
pub enum FileType {
File,
Directory,
Symlink,
Unknown,
}
impl FileType {
pub fn from_ftw(ftw: c_int) -> Self {
match ftw {
FTW_F => FileType::File,
FTW_D ... |
use std::collections::HashSet;
use crate::{
fixture,
vector::{sql, Geometry},
Dataset,
};
#[test]
fn test_sql() {
let ds = Dataset::open(fixture!("roads.geojson")).unwrap();
let query = "SELECT kind, is_bridge, highway FROM roads WHERE highway = 'pedestrian'";
let mut result_set = ds
.... |
use solana_program::{
program_error::ProgramError,
pubkey::Pubkey,
};
use std::mem::size_of;
use arrayref::array_ref;
use gravity_misc::validation::{build_range_from_alloc, extract_from_range, retrieve_oracles};
use gravity_misc::ports::{
state::ForeignAddress,
instruction::ATTACH_VALUE_INSTRUCTION_IND... |
use ::Payload;
use byteorder::{self, ByteOrder};
use core::cmp::PartialEq;
use core::fmt::{self, Debug, Formatter};
use core::ops::Deref;
use crc16;
/// A checksum algorithm configuration to use when encoding data.
#[derive(Clone, Debug)]
pub enum Checksum {
/// Use no checksum.
None,
/// CRC-16/CDMA2000 ... |
#[cfg(feature = "screen")]
use framebuffer::Framebuffer;
#[cfg(feature = "screen")]
use image::{Rgb, RgbImage};
use crate::Ev3Result;
/// Represents the device screen.
/// Advanced drawing operations can be performed with the `imageproc` crate.
#[cfg(feature = "screen")]
#[derive(Debug)]
pub struct Screen {
/// ... |
// Copyright 2018 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 std::fs::File;
use std::collections::HashMap;
use std::io::Read;
type Input<'a> = HashMap<&'a str, Vec<&'a str>>;
pub fn parse(s: &str) -> Input {
s.lines()
.map(|line| {
let split: Vec<_> = line.split("->").collect();
let name = split[0].split_whitespace().collect::<Vec<_>>()[0... |
// 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 ... |
// This file is Copyright its original authors, visible in version control
// history.
//
// This file is 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.
// You may... |
pub fn raindrops(n: u32) -> String {
let mut result = String::new();
if n % 3 == 0 {
result.push_str("Pling");
}
if n % 5 == 0 {
result.push_str("Plang");
}
if n % 7 == 0 {
result.push_str("Plong");
}
if result.is_empty() {
n.to_string()
}else {
... |
extern crate day10;
use std::fmt;
use std::io::Write;
use day10::*;
pub fn count_used(key: &str) -> usize {
let mut sum: usize = 0;
let mut buf: Vec<u8> = Vec::with_capacity(key.len() + 4);
for n in 0..128 {
write!(&mut buf, "{}-{}", key, n).unwrap();
let hash = KnotHash::hash(&buf).hash;... |
#![feature(test)]
extern crate test;
use smaz::{compress};
use lz4_flex::{compress_prepend_size};
pub const INPUT: &str = "Put request on \"/boot-source\" with body \"{\\n \\\"kernel_image_path\\\": \\\"/home/elavtob/tmp/hello-vmlinux.bin\\\",\\n \\\"boot_args\\\": \\\"console=ttyS0 reboot=k pan... |
pub struct Solution;
impl Solution {
pub fn rob(nums: Vec<i32>) -> i32 {
if nums.len() == 0 {
return 0;
}
if nums.len() == 1 {
return nums[0];
}
let case_use_0 = {
let mut a = nums[0];
let mut b = nums[0];
for i in ... |
use error;
use ffi;
use MantleObject;
use std::mem;
use std::ptr;
use std::ffi::CStr;
use std::slice::Iter;
use std::iter::Take;
use std::sync::{Once, ONCE_INIT};
static mut GPUS: [ffi::GR_PHYSICAL_GPU; ffi::GR_MAX_PHYSICAL_GPUS] = [0; ffi::GR_MAX_PHYSICAL_GPUS];
static mut GPUS_COUNT: ffi::GR_UINT = 0;
#[derive(De... |
use std::convert::TryInto;
use proptest::prop_assert_eq;
use proptest::strategy::Just;
use liblumen_alloc::erts::term::prelude::*;
use crate::erlang::setelement_3::result;
use crate::test::strategy;
#[test]
fn without_tuple_errors_badarg() {
run!(
|arc_process| {
(
Just(arc_p... |
//! `IndexMap` is a hash table where the iteration order of the key-value
//! pairs is independent of the hash values of the keys.
mod core;
mod iter;
mod slice;
#[cfg(feature = "serde")]
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
pub mod serde_seq;
#[cfg(test)]
mod tests;
pub use self::core::{Entry, Occupied... |
#[derive(Serialize, Deserialize, Debug)]
pub struct Task {
content: String,
id: u32
}
impl Task {
pub fn new(content: String, id: u32) -> Task {
Task {
content,
id,
}
}
}
|
extern crate gitlab;
extern crate github_rs;
extern crate toml;
#[macro_use] extern crate serde_derive;
extern crate failure;
#[macro_use]
extern crate failure_derive;
extern crate rayon;
extern crate serde_json;
extern crate clap;
mod action;
mod actions;
mod config;
mod gitlab_impl;
mod github_impl;
use self::actio... |
use crate::{
analysis::Analysis,
app::{AppContext, AppContextPointer},
errors::SondeError,
};
use gtk::{
glib::translate::IntoGlib, prelude::*, EventControllerKey, Inhibit, TextBuffer, TextTag,
TextView,
};
use metfor::{Fahrenheit, Inches, Quantity};
use std::{fmt::Write, rc::Rc};
const TEXT_AREA_I... |
pub mod constructors;
pub mod tycons;
use super::*;
use crate::elaborate::*;
fn define_constructor<'arena>(
ctx: &mut elaborate::Context<'arena>,
con: Constructor,
sch: Scheme<'arena>,
) {
ctx.define_value(con.name, Span::dummy(), sch, IdStatus::Con(con));
}
/// This is not pretty, but we have to han... |
extern crate cc;
#[cfg(target_os="macos")]
fn main() {
cc::Build::new()
.cpp(true)
.warnings(true)
.flag("-std=c++11")
.file("src/webcam/cpp/src/webcam.cpp")
.include("src/webcam/cpp/include")
.include("/usr/local/opt/opencv/include/opencv4")
.compile("libweb... |
pub use VkCommandBufferResetFlags::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkCommandBufferResetFlags {
VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
}
use crate::SetupVkFlags;
#[repr(C)]
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub struct VkCommandBufferResetFlagBit... |
use ic_cdk::export::candid::{CandidType, Deserialize, Principal};
use std::fmt::{Display, Formatter};
#[derive(CandidType, Deserialize)]
pub enum Error {
AlreadyIsAMember,
IsNotAMember,
AccessDenied,
ForbiddenOperation,
}
impl Display for Error {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::R... |
#[doc = "Reader of register _1_CTL"]
pub type R = crate::R<u32, super::_1_CTL>;
#[doc = "Writer for register _1_CTL"]
pub type W = crate::W<u32, super::_1_CTL>;
#[doc = "Register _1_CTL `reset()`'s with value 0"]
impl crate::ResetValue for super::_1_CTL {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use std::error;
use std::fmt;
use std::io;
use hyper;
use serde_json;
#[derive(Debug)]
pub enum DropBoxError {
APIError(String),
HyperError(hyper::error::Error),
IOError(io::Error),
SerdeError(serde_json::error::Error),
}
impl fmt::Display for DropBoxError {
fn fmt(&self, f: &mut fmt::Formatter) -... |
pub mod instruction;
pub mod parsing;
pub type Word = u16;
|
use std::pin::Pin;
use futures::{future, stream};
use juniper::{graphql_subscription, GraphQLObject};
type Stream<'a, I> = Pin<Box<dyn futures::Stream<Item = I> + Send + 'a>>;
#[derive(GraphQLObject)]
struct ObjA {
test: String,
}
struct ObjB;
#[graphql_subscription]
impl ObjB {
async fn id(&self, obj: Obj... |
// Example is taken from
// http://matt2xu.github.io/async-http-client
extern crate async_http_client;
use async_http_client::prelude::*;
use async_http_client::{HttpRequest, HttpCodec};
fn main() {
let req = HttpRequest::get("http://www.google.com").unwrap();
let mut core = Core::new().unwrap();
let add... |
use crate::vec3::Vec3;
use crate::ray::Ray;
use rand::prelude::*;
use std::f64::consts::PI;
pub struct ScatterInfo(pub Ray,pub Vec3);
pub trait Material : Sync + Send {
fn scatter(&self, ray_in : Ray, point : Vec3, normal: Vec3) -> Option<ScatterInfo>;
}
fn random_unit_vector() -> Vec3 {
let mut rng=rand::t... |
use std::default::Default;
#[derive(PartialEq)]
pub enum Type {
A,
NS,
MD,
MF,
CNAME,
SOA,
MB,
MG,
MR,
NULL,
WKS,
PTR,
HINFO,
MINFO,
MX,
TXT,
RP,
AFSDB,
X25,
ISDN,
RT,
NSAP,
NSAPPTR,
SIG,
KEY,
PX,
GPOS,
AAAA... |
use crate::buffer::StreamBuffer;
use crate::constants;
use crate::constraints::Constraints;
use crate::content_disposition::ContentDisposition;
use crate::helpers;
use crate::state::{MultipartState, StreamingStage};
use crate::Field;
use bytes::Bytes;
use futures::stream::{Stream, TryStreamExt};
use std::ops::DerefMut;... |
use thiserror::Error;
#[derive(Error, Debug)]
pub enum BinaryParsingError {
#[error("too small buffer, expected minimum {0} bytes")]
BufferSmall(usize),
#[error("invalid command given: 0x{0:X}")]
InvalidCommand(u8),
#[error("invalid transport protocol given: 0x{0:X}")]
InvalidTransportProtoco... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - endpoint 0 register"]
pub ep0r: EP0R,
#[doc = "0x04 - endpoint 1 register"]
pub ep1r: EP1R,
#[doc = "0x08 - endpoint 2 register"]
pub ep2r: EP2R,
#[doc = "0x0c - endpoint 3 register"]
pub ep3r: EP3R,
#[d... |
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::DLY {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W... |
use super::{Dispatch, NodeId, ShardId, State};
use crate::{
NodeQueue, NodeQueueEntry, NodeThreadPool, ProbabilisticDispatcher, Query, QueryEstimate,
QueryId,
};
use std::collections::HashSet;
use std::rc::Rc;
use simrs::{Key, QueueId};
pub struct OptPlusDispatch {
node_queues: Vec<QueueId<NodeQueue<Node... |
use std::fs::File;
use std::io::prelude::*;
fn main() {
println!("Hello!");
// Read a file
let mut fp = File::open("ip.txt").expect("File not found!");
let mut contents = String::new();
fp.read_to_string(&mut contents)
.expect("something went wrong reading the file");
println!("{}", co... |
use crate::util::{self, color};
use crate::{config, git};
use anyhow::Result;
use std::cmp::max;
use std::path::{Path, PathBuf};
use std::time::SystemTime;
use std::{env, fs};
use walkdir::WalkDir;
/// Represents which direction to sync dotfiles.
#[derive(PartialEq)]
enum SyncDirection {
FromRemote,
ToRemote,
N... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::FIFOLVL {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, ... |
const width:usize = 25;
const height:usize = 6;
fn main() {
let input: &str = include_str!("./input.txt").lines().next().unwrap();
let data: Vec<isize> = input.chars().map(|x| x.to_digit(10).unwrap() as isize).collect();
let mut layer = 0;
let total_layers = data.len() / width / height;
le... |
//! libc syscalls supporting `rustix::io`.
use crate::backend::c;
#[cfg(not(target_os = "wasi"))]
use crate::backend::conv::ret_discarded_fd;
use crate::backend::conv::{borrowed_fd, ret, ret_c_int, ret_owned_fd, ret_usize};
use crate::fd::{AsFd, BorrowedFd, OwnedFd, RawFd};
#[cfg(not(any(
target_os = "aix",
ta... |
use crate::{DocBase, VarType};
const TR_ARGU: &'static str = r#"
**handle_na (bool)** How NaN values are handled. if true, and previous day's close is NaN then tr would be calculated as current day high-low. Otherwise (if false) tr would return NaN in such cases. Also note, that atr uses tr(true).
"#;
pub fn gen_doc(... |
use serde::{Serialize, Deserialize};
use tokio_pg_mapper_derive::PostgresMapper;
use crate::common::errors::CustomError;
use deadpool_postgres::Pool;
use deadpool_postgres::Client;
use actix_web::{web};
use tokio_pg_mapper::FromTokioPostgresRow;
#[derive(Serialize, Deserialize, PostgresMapper)]
#[pg_mapper(table="esh... |
use std::collections::{HashMap, HashSet};
use std::env;
use std::fs;
use std::io;
use std::io::{BufRead, Read, Write};
use std::path;
use std::path::PathBuf;
use std::process;
use std::sync::mpsc;
use std::thread;
use reqwest;
use tempfile;
use regex;
use tokio;
use crate::bc::pubapi::{JavaClass, JavaField, JavaMetho... |
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Deserialize, Serialize, Debug)]
pub struct OrderBookResult {
pub bids: Vec<(String, String, u32)>,
pub asks: Vec<(String, String, u32)>,
}
#[derive(Deserialize, Serialize, Debug)]
pub struct RawOrderBook {
pub error: Vec<String>,... |
#[macro_use]
extern crate rental;
#[derive(Debug)]
pub struct Foo {
i: i32,
}
rental! {
mod rentals {
use super::*;
#[rental(debug, deref_suffix)]
pub struct SimpleRef {
foo: Box<Foo>,
iref: &'foo i32,
}
#[rental_mut(debug, deref_suffix)]
pub struct SimpleMut {
foo: Box<Foo>,
iref: &'foo... |
/// Represents original source file location information present in Erlang Abstract Format
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub struct Loc {
line: u32,
column: u32,
}
impl Loc {
pub fn new(line: u32, column: u32) -> Self {
Self { line, column }
}
}
|
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// 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 ... |
#![cfg(path_api)]
use tauri_api::path;
use tauri_api::path::BaseDirectory;
use webview_official::Webview;
pub fn resolve_path(
webview: &mut Webview<'_>,
path: String,
directory: Option<BaseDirectory>,
callback: String,
error: String,
) {
crate::execute_promise(
webview,
move || path::resolve_path(... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type Buffer = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct ByteOrder(pub i32);
impl ByteOrder {
pub const LittleEndian: Self = Self(0i32);
... |
use snafu::Snafu;
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(
visibility = "pub",
display("Could not open file '{}': {}", "filename.display()", "source")
)]
OpenFile {
path: std::path::PathBuf,
source: std::io::Error,
},
}
pub type Result<T, E = Error> = std::resu... |
use serde::Deserialize;
use crate::apis::flight_provider::raw_models::airline_code_raw::AirlineCodeRaw;
#[derive(Deserialize, Debug)]
pub struct AirlineRaw {
pub name: Option<String>,
pub short: Option<String>,
pub code: Option<AirlineCodeRaw>,
pub url: Option<String>,
}
|
use std::collections::HashMap;
use crate::ast::node::bind_node::BindNode;
use crate::ast::node::choose_node::ChooseNode;
use crate::ast::node::delete_node::DeleteNode;
use crate::ast::node::foreach_node::ForEachNode;
use crate::ast::node::if_node::IfNode;
use crate::ast::node::include_node::IncludeNode;
use crate::ast... |
//
// Copyright 2019 Sͬeͥbͭaͭsͤtͬian
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this
// list of conditions and the following disc... |
extern crate gst;
use std::io;
use std::io::prelude::*;
use std::thread;
fn player_loop(mut playbin : gst::PlayBin) {
let stdin = io::stdin();
for line in stdin.lock().lines() {
let line = line.unwrap();
let mut line_split = line.split(' ');
let command = line_split.next();
le... |
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("connection error")]
ConnectionError(mobc::Error<mobc_diesel::Error>),
#[error("database error")]
DatabaseError(diesel::result::Error),
}
impl From<mobc::Error<mobc_diesel::Error>> for Error {
fn from(error: mobc::Error<mobc_diesel::Error>... |
use std::env;
fn build_windows() {
#[cfg(windows)]
windows::build!(
windows::win32::windows_programming::{GetUserNameA, GetComputerNameExA, GetTickCount64},
windows::win32::system_services::{GlobalMemoryStatusEx, GetSystemPowerStatus},
);
}
fn build_macos() {
println!("cargo:rustc-link... |
/* Copyright (C) 2016 Yutaka Kamei */
#![allow(non_snake_case)]
use std::error::Error;
use std::fmt::{self, Display};
use regex::Regex;
use rustc_serialize::json;
#[derive(Debug)]
pub struct ScimFilterError {
message: String,
rest: Vec<String>,
}
impl Display for ScimFilterError {
fn fmt(&self, f: &mut ... |
#![allow(dead_code)]
mod colors;
mod components;
mod config;
mod contour;
mod extensions;
mod grid;
mod prelude;
mod snapshot;
use std::env;
use prelude::*;
fn main() {
nannou::app(start).update(update).exit(snapshot::exit).run();
}
fn start(app: &App) -> Model {
let config_params = config::load();
le... |
use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::{
braced,
parse::{Parse, ParseStream, Result},
punctuated::Punctuated,
Ident, ItemEnum, Token, Type,
};
#[derive(Debug, PartialEq)]
pub(crate) struct Event {
pub event_name: Ident,
pub event_type: Type,
}
impl Parse for Event... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.