text stringlengths 8 4.13M |
|---|
use chainerror::*;
use std::io;
#[derive(Clone, PartialEq, Debug)]
pub enum ErrorKind {
Io(::std::io::ErrorKind),
SerdeJsonSer(::serde_json::error::Category),
SerdeJsonDe(String),
InterfaceNotFound(String),
InvalidParameter(String),
MethodNotFound(String),
MethodNotImplemented(String),
... |
#[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::ISC {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... |
use crate::disassembler::Instruction;
pub struct Cpu {
pub memory: [u8; 4096],
pub registers: [u8; 16],
pub stack: [u16; 16],
pub i: u16,
pub vf: u8,
pub delay_timer: u8,
pub sound_timer: u8,
pub pc: u16,
pub sp: u8,
}
impl Cpu {
pub fn load_program(&mut self, program: &Vec<Ins... |
use crate::config::config;
use crate::error::HandleError;
use crate::error::HandleError::SessionError;
use anyhow::Result;
use model::*;
use redis::{Commands, Connection, RedisResult};
use repository::AccountByGoogleId;
use warp::Rejection;
pub const SESSION_KEY: &str = "session-token";
const EXPIRE_SECONDS: usize = 3... |
/*!
All libsodacrypt apis will return an errors::Result.
*/
error_chain! {
links {
}
foreign_links {
Io(::std::io::Error);
}
errors {
InvalidPubKey
InvalidPrivKey
InvalidSeed
InvalidSignature
InvalidNonce
InvalidPresharedKey
InvalidC... |
pub mod algorithm_binary;
pub mod chip;
pub mod chip_family;
pub mod flash_device;
pub mod parser;
pub mod raw_flash_algorithm;
use crate::chip::Chip;
use crate::chip_family::ChipFamily;
use crate::raw_flash_algorithm::RawFlashAlgorithm;
use anyhow::{anyhow, bail, ensure, Context, Result};
use cmsis_pack::pdsc::{Core... |
/* Podos System by Julius */
rs_prog podos:
[
input : [
start_button, /* inicia o processo do podos */
stop_button, /* termina o processo do podos */
heart_button, /* mostra a batidas do coracao por segundo */
veloc_button, /* mos... |
use crate::Context;
/// Algorithms that can be used to scale the game's screen.
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum ScalingMode {
/// The game will always be displayed at its native resolution, with no scaling applied.
/// If the window is bigger than the native resolution, letterboxing will be a... |
#[doc = "Reader of register FRAMEFLTR"]
pub type R = crate::R<u32, super::FRAMEFLTR>;
#[doc = "Writer for register FRAMEFLTR"]
pub type W = crate::W<u32, super::FRAMEFLTR>;
#[doc = "Register FRAMEFLTR `reset()`'s with value 0"]
impl crate::ResetValue for super::FRAMEFLTR {
type Type = u32;
#[inline(always)]
... |
use std::fmt::{Debug, Formatter, Result};
use std::iter::Enumerate;
use std::{
cmp::{Ordering, Reverse},
marker::PhantomData,
};
use std::{
collections::{BinaryHeap, HashMap},
hash::Hash,
};
use crate::{
properties::{WithRegion, WithRegionCore},
ChromName,
};
pub struct Point<C: ChromName, T: ... |
#[doc = "Reader of register DSI_VVACCR"]
pub type R = crate::R<u32, super::DSI_VVACCR>;
#[doc = "Reader of field `VA`"]
pub type VA_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:13 - Vertical Active duration"]
#[inline(always)]
pub fn va(&self) -> VA_R {
VA_R::new((self.bits & 0x3fff) as u16)
... |
use hyper::server::{Handler, Listening, Request, Response, Server};
use metric;
use protobuf::Message;
use protobuf::repeated::RepeatedField;
use protocols::prometheus::*;
use sink::{Sink, Valve};
use source::report_telemetry;
use std::io;
use std::io::Write;
use std::mem;
use std::str;
use std::sync;
use std::sync::Mu... |
extern crate libc;
extern crate time;
#[cfg(windows)] extern crate winapi;
#[macro_use]
mod macros;
pub mod fs;
pub mod parse_time;
pub mod utf8;
#[cfg(unix)] pub mod c_types;
#[cfg(unix)] pub mod process;
#[cfg(unix)] pub mod signals;
#[cfg(unix)] pub mod utmpx;
#[cfg(windows)] pub mod wide;
|
use proconio::{input, marker::Bytes};
fn main() {
input! {
n: usize,
s: Bytes,
t: Bytes,
};
{
let mut ss = s.clone();
let mut tt = t.clone();
ss.sort();
tt.sort();
if ss != tt {
println!("-1");
return;
}
}
... |
use std::{future::Future, sync::Arc, time::Duration};
use async_trait::async_trait;
use futures::FutureExt;
use tokio::{sync::Barrier, task::JoinHandle};
#[async_trait]
pub trait EnsurePendingExt {
type Out;
/// Ensure that the future is pending. In the pending case, try to pass the given barrier. Afterwards... |
use crate::{sealed::Sealed, tuple::append::TupleAppend};
/// Takes element from the **start** of the tuple, producing new tuple.
///
/// Return tuple of taked element and remaining tuple.
///
/// ## Examples
/// ```
/// use fntools::tuple::take::TupleTake;
///
/// assert_eq!((999,).take(), (999, ()));
/// assert_eq!((... |
use crate::{
builtins::{type_::PointerSlot, PyInt, PyStr, PyStrInterned, PyStrRef, PyType, PyTypeRef},
bytecode::ComparisonOperator,
common::hash::PyHash,
convert::{ToPyObject, ToPyResult},
function::{
Either, FromArgs, FuncArgs, OptionalArg, PyComparisonValue, PyMethodDef, PySetterValue,
... |
use std::{fmt::Display, sync::Arc};
use async_trait::async_trait;
use backoff::{Backoff, BackoffConfig};
use data_types::{CompactionLevel, ParquetFile, ParquetFileId, ParquetFileParams, PartitionId};
use iox_catalog::interface::Catalog;
use crate::{commit::Error, Commit};
#[derive(Debug)]
pub(crate) struct CatalogCo... |
mod common;
use common::round_beam_intersect;
use crisscross::{BeamIntersect, Grid, TilePosition, TileRaycaster};
fn cast(grid: &Grid, center: &TilePosition, width: f32, angle: f32) -> Vec<BeamIntersect> {
let tc = TileRaycaster::new(grid.clone());
let bis: Vec<BeamIntersect> = tc
.cast_beam(¢er, w... |
use crate::ecs::*;
use shrinkwraprs::Shrinkwrap;
#[derive(Shrinkwrap, Debug, Copy, Clone, Eq, PartialEq)]
#[shrinkwrap(mutable)]
pub struct Parent(pub Entity);
#[derive(Shrinkwrap, Debug, Copy, Clone, Eq, PartialEq)]
#[shrinkwrap(mutable)]
pub struct PreviousParent(pub Option<Entity>);
|
use std::fs::File;
use std::path::Path;
use std::io::prelude::*;
use std::io;
pub struct Image<T> {
pub data: Vec<Vec<T>>,
pub width: usize,
pub height: usize,
}
impl<T: Copy> Image<T> {
pub fn new(fill: T, width: usize, height: usize) -> Image<T> {
Image {
data: vec![vec![fill; width]; height],
... |
// 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 ... |
mod config;
mod error;
mod models;
mod schema;
pub use crate::error::Error;
use crate::models::PlayerStatForUpdate;
use crate::models::{
CanGetHash, Hash, PlayerStatForInsert, ScoreSnapForUpdate, User, UserStatus,
UserStatusForInsert,
};
use anyhow::Result;
use chrono::{NaiveDateTime, Utc};
use diesel::prelude... |
//! # global properties
//! - `#![no_std]`
//! ban std lib
#![no_std]
//!
//! - `#![no_main]`
#![no_main]
#![feature(llvm_asm)]
#![feature(global_asm)]
#![feature(panic_info_message)]
#[macro_use]
mod console;
mod panic;
mod sbi;
global_asm!(include_str!("asm/entry.asm"));
/// cover _start function of crt0
/// we... |
use std::cmp::Ordering;
use std::mem;
// courtesy of https://stackoverflow.com/a/28294764
fn swap<T>(x: &mut [T], i: usize, j: usize) {
let (lo, hi) = match i.cmp(&j) {
// no swapping necessary
Ordering::Equal => return,
// get the smallest and largest of the two indices
Ordering::... |
pub fn chunkinfy(vec_len: usize, chunk_num: usize) -> Vec<usize> {
let chunk_size: usize = vec_len / chunk_num;
let mut res_vec: Vec<usize> = (vec![chunk_size])
.iter()
.cycle()
.take(chunk_num)
... |
pub mod decompressor;
pub mod stream;
pub mod video;
|
// Copyright 2014 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 ... |
#[macro_use] extern crate lazy_static;
extern crate reactive_net;
mod __authentic_execution;
pub mod __run;
#[allow(unused_imports)] use __authentic_execution::authentic_execution;
#[allow(unused_imports)] use __authentic_execution::authentic_execution::{MODULE_NAME, success, failure, handle_output, handle_request, ... |
use input_i_scanner::{scan_with, InputIScanner};
use mod_int::ModInt998244353;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
let (n, d) = scan_with!(_i_i, (usize, usize));
type Mint = ModInt998244353;
let two = Mint::new(2);
let mut ans = Mint::ne... |
use ropey::Rope;
use std::ops::Range;
#[derive(Debug)]
pub enum EditError {
InvalidPosition,
}
// line and column are one-based index
#[derive(Debug, Clone)]
pub struct TextPosition {
pub line: usize,
pub column: usize,
}
impl TextPosition {
pub fn new(line: usize, column: usize) -> Self {
Te... |
use core::{
cmp,
fmt::{self, Debug, Formatter},
ops::Range,
};
/// A half-open range which indicates the location of something in a body of
/// text.
#[derive(Copy, Clone, Eq)]
#[cfg_attr(
feature = "serde-1",
derive(serde_derive::Serialize, serde_derive::Deserialize)
)]
#[repr(C)]
pub struct Span ... |
use crate::auth;
use crate::diesel::QueryDsl;
use crate::diesel::RunQueryDsl;
use crate::handlers::types::*;
use crate::helpers::{email, email_template, encrypt::decrypt};
use crate::model::{MailList, NewUserMail, Space, SpaceEmail, SpaceUser, User, UserMail};
use crate::schema::maillists::dsl::*;
use crate::schema::sp... |
use std::string::String;
#[derive(Default)]
pub struct MeshNameParser {
pub full_name: String,
pub full_name_normalized: String,
pub render_parameter_normalized: String,
pub camera_targets_normalized: String,
pub tokens: Vec<String>,
pub mesh_name: String,
pub item_name: String,
pub item_mesh_part: Str... |
#![recursion_limit = "128"]
#[macro_use] extern crate quote;
extern crate proc_macro;
extern crate syn;
extern crate validator;
use std::collections::HashMap;
use proc_macro::TokenStream;
use quote::ToTokens;
use validator::{Validator};
static RANGE_TYPES: [&'static str; 24] = [
"usize", "u8", "u16", "u32", "... |
use iron::{Chain, Iron};
use persistent::Read;
use router::router;
use serde_derive::{Deserialize, Serialize};
use serenity::model::id::{ChannelId, GuildId};
use serenity::prelude::*;
use std::collections::HashSet;
use std::fs::DirBuilder;
use std::sync::Arc;
use std::thread;
mod store;
use store::StatsStore;
mod sca... |
#[cfg(feature = "Win32_System_Com")]
::windows_sys::core::link ! ( "xmllite.dll""system" #[doc = "*Required features: `\"Win32_Data_Xml_XmlLite\"`, `\"Win32_System_Com\"`*"] fn CreateXmlReader ( riid : *const :: windows_sys::core::GUID , ppvobject : *mut *mut ::core::ffi::c_void , pmalloc : super::super::super::System:... |
extern crate log;
use log::*;
pub struct SimpleLogger;
impl log::Log for SimpleLogger {
fn enabled(&self, metadata: &LogMetadata) -> bool {
//metadata.level() <= LogLevel::Trace
metadata.level() <= LogLevel::Info
}
fn log(&self, record: &LogRecord) {
use chrono::Local;
//... |
#[doc = "Reader of register OPAMP1_CSR"]
pub type R = crate::R<u32, super::OPAMP1_CSR>;
#[doc = "Writer for register OPAMP1_CSR"]
pub type W = crate::W<u32, super::OPAMP1_CSR>;
#[doc = "Register OPAMP1_CSR `reset()`'s with value 0"]
impl crate::ResetValue for super::OPAMP1_CSR {
type Type = u32;
#[inline(always... |
use std::borrow::Cow;
use tabwriter::TabWriter;
use CliResult;
use config::{Config, Delimiter};
use util;
static USAGE: &'static str = "
Outputs CSV data as a table with columns in alignment.
This will not work well if the CSV data contains large fields.
Note that formatting a table requires buffering all CSV data... |
use log::debug;
use mkit::{
cbor::{FromCbor, IntoCbor},
thread,
};
use std::{
borrow::BorrowMut,
mem,
sync::{
atomic::{AtomicU64, Ordering::SeqCst},
Arc, RwLock,
},
};
use crate::{entry, journal::Journal, state, wral, wral::Config, Error, Result};
#[derive(Debug)]
pub enum Req... |
#[cfg(not(target_arch = "wasm32"))]
use crate::MockedBlockchain;
/// A low-level interface of either real or mocked blockchain that contract interacts with.
pub trait BlockchainInterface {
// #############
// # Registers #
// #############
unsafe fn read_register(&self, register_id: u64, ptr: u64);
... |
//! This module implements the `skipped-compactions` CLI command
use comfy_table::{Cell, Table};
use influxdb_iox_client::{
compactor::{self, generated_types::SkippedCompaction},
connection::Connection,
};
use iox_time::Time;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("JSON Ser... |
extern crate gunship;
use gunship::engine::EngineBuilder;
fn main() {
let mut builder = EngineBuilder::new();
builder.max_workers(1);
builder.build(|| {});
}
|
use chrono::{DateTime, Duration, Utc};
use iox_catalog::interface::{Catalog, ParquetFileRepo};
use object_store::ObjectMeta;
use observability_deps::tracing::*;
use snafu::prelude::*;
use std::collections::HashSet;
use std::sync::Arc;
use tokio::sync::mpsc;
use tokio::time::timeout;
use uuid::Uuid;
#[derive(Debug, Sna... |
use std::collections::HashMap;
use std::rc::Rc;
pub struct Request {
method: String,
url: String,
headers: HashMap<String, String>,
body: Vec<u8>,
}
pub struct Response {
code: u32,
headers: HashMap<String, String>,
body: Vec<u8>,
}
type BoxedCallback = Box<Fn(&Request) -> Response>;
pub... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtGui/qimageiohandler.h
// dst-file: /src/gui/qimageiohandler.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block be... |
extern crate regex;
use std::io::{self, Write};
use regex::RegexSet;
fn main() {
let stdin = io::stdin();
let mut number: String = "".to_string();
let _formats = RegexSet::new(&[
r"^\d{3}-\d{4}$", // 555-1212
r"^\d{7}$", // 5551212
r"^\d{10}$", // 4345551212
r"^\d{6}-\d{4}... |
// Standard library
use std::cell::RefCell;
use std::collections::{hash_map::Entry, HashMap};
use std::mem::take;
use std::sync::{Arc, Mutex, Weak};
// This crate
use crate::stt::{SttPoolItem, SttSet};
// Other crates
use anyhow::{anyhow, Result};
use log::debug;
thread_local! {
pub static CAPS_MANAGER: RefCell<... |
// This file is part of linux-epoll. 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/linux-epoll/master/COPYRIGHT. No part of linux-epoll, including this file, may be copied, modified, propagated, or distri... |
#[derive(Debug)]
pub struct NewtonMethod {
pub tol_f: f64,
pub max_iter: i32,
pub abs_step: f64,
pub rel_step: f64,
pub min_x_step: f64,
pub min_f_x_step: f64
}
impl NewtonMethod {
pub fn solve(self, x0 : f64, fun : (f64) -> f64) -> (f64, f64) {
// TODO: check... |
// Test that a covariant struct does not permit the lifetime of a
// reference to be enlarged.
// revisions: base nll
// ignore-compare-mode-nll
//[nll] compile-flags: -Z borrowck=mir
struct SomeStruct<T>(T);
fn foo<'min,'max>(v: SomeStruct<&'min ()>)
-> SomeStruct<&'max ()>
where 'max : 'min
{... |
// 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 ... |
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
//
extern crate clap;
extern crate gltf_variant_meld;
use std::fs;
use gltf_variant_meld::{Result, VariationalAsset};
mod args;
use args::parse_args;
pub use args::{SourceAsset, SourceAssets, WorkOrder};
fn main() {
let work_order = parse... |
use std::fs::File;
use std::io::{BufReader, ErrorKind};
use std::io::prelude::*;
use std::{fmt, env};
// (C) Copyright 2020 xkr47@outerspace.dyndns.org
//
// Exercise program in Rust to detect file type of raw audio 16/24 bit PCM files
// Uses algorithm purely invented by xkr47
fn main() {
let args: Vec<String> =... |
use std::mem;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::Weak;
use std::sync::mpsc;
use std::thread;
use std::time::Duration;
use backend::*;
use output_log::*;
pub struct OutputState {
backend: Option <Box <Backend>>,
synchronous: bool,
logs: Vec <OutputLogInternal>,
next_log_id: u64,
backgroun... |
use crate::authorize::AuthToken;
use crate::authorize::Login;
use crate::authorize::NewUser;
use crate::authorize::User;
use crate::helpers::*;
use crate::schema::users;
use diesel;
use diesel::prelude::*;
pub fn allusers( connection: &PgConnection)->Vec<User> {
users::table.load::<User>(&*connection).unwrap()
}
pu... |
use std::cmp::Ordering;
#[derive(Default, Clone, Copy, Debug)]
struct BitCount {
zero: u32,
one: u32,
}
fn bit_counts(input: &str) -> Vec<BitCount> {
let len = input.lines().next().unwrap().len();
let mut counts = vec![BitCount::default(); len];
for line in input.lines() {
for (i, count) i... |
#[doc = "Reader of register HWCFGR"]
pub type R = crate::R<u32, super::HWCFGR>;
#[doc = "Writer for register HWCFGR"]
pub type W = crate::W<u32, super::HWCFGR>;
#[doc = "Register HWCFGR `reset()`'s with value 0"]
impl crate::ResetValue for super::HWCFGR {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
#[doc = "Reader of register C3ISR"]
pub type R = crate::R<u32, super::C3ISR>;
#[doc = "Reader of field `TEIF3`"]
pub type TEIF3_R = crate::R<bool, bool>;
#[doc = "Reader of field `CTCIF3`"]
pub type CTCIF3_R = crate::R<bool, bool>;
#[doc = "Reader of field `BRTIF3`"]
pub type BRTIF3_R = crate::R<bool, bool>;
#[doc = "R... |
#[doc = "Reader of register AHB2ENR"]
pub type R = crate::R<u32, super::AHB2ENR>;
#[doc = "Writer for register AHB2ENR"]
pub type W = crate::W<u32, super::AHB2ENR>;
#[doc = "Register AHB2ENR `reset()`'s with value 0"]
impl crate::ResetValue for super::AHB2ENR {
type Type = u32;
#[inline(always)]
fn reset_va... |
use winnow::prelude::*;
mod parser;
use parser::hex_color;
fn main() -> Result<(), lexopt::Error> {
let args = Args::parse()?;
let input = args.input.as_deref().unwrap_or("#AAAAAA");
println!("{} =", input);
match hex_color.parse(input) {
Ok(result) => {
println!(" {:?}", resul... |
use super::error::{PineError, PineErrorKind};
use super::input::{Input, StrRange};
use std::cell::{Cell, RefCell};
#[derive(Debug, PartialEq, Clone)]
pub struct PineInputError {
pub code: PineErrorKind,
pub range: StrRange,
}
impl PineInputError {
pub fn new(code: PineErrorKind, range: StrRange) -> PineIn... |
#[link(name = "foo", kind = "static-nobundle")]
//~^ WARNING: link kind `static-nobundle` has been superseded by specifying modifier `-bundle` with link kind `static`
//~^^ ERROR: link kind `static-nobundle` is unstable
extern "C" {}
fn main() {}
|
use rand::prelude::*;
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(add_one(1), 2);
}
}
pub fn add_one(a: i32) -> i32 {
a + 1
}
pub fn add_rand(a: i32) -> i32 {
let mut rng = rand::thread_rng();
let y: i32 = rng.gen();
a + y
}
|
pub fn bcd_to_binary(bcd: u8) -> u8 {
return (bcd & 0x0f) + ((bcd >> 4) * 10);
}
pub fn read(register: u8) -> u8 {
use x86_64::instructions::port::Port;
let mut port_70 = Port::new(0x70);
let mut port_71 = Port::new(0x71);
unsafe {
port_70.write(register);
port_71.read()
}
}
|
use std::sync::Arc;
use thiserror::Error;
use crate::internals::{
entity::EntityLocation,
insert::ArchetypeSource,
query::filter::{FilterResult, LayoutFilter},
storage::{
archetype::{Archetype, EntityLayout},
component::{Component, ComponentTypeId},
ComponentStorage, Components... |
use itertools::Itertools;
use std::cmp::{max, min};
use whiteread::parse_line;
use std::collections::HashMap;
use std::collections::HashSet;
fn main() {
let n: usize = parse_line().unwrap();
let mut hashiras_vec: Vec<(i64, i64)> = vec![];
let mut hashiras_set: HashSet<(i64, i64)> = HashSet::new();
fo... |
use arrow_util::assert_batches_sorted_eq;
use compactor_test_utils::{format_files, list_object_store, TestSetup};
use data_types::{CompactionLevel, ParquetFile, PartitionId};
mod layouts;
#[tokio::test]
async fn test_compact_no_file() {
test_helpers::maybe_start_logging();
// no files
let setup = TestSet... |
#![deny(clippy::all)]
use num::BigUint;
pub mod mod_p;
/// Diffie-Hellman trait contains common API for any choice of underlying cyclic group
pub trait DH {
type GroupElement;
/// check an element is a valid member in the group
fn check_elm(&self, elm: &Self::GroupElement) -> bool;
/// returns the def... |
/// Receives a word and an array of candidates and returns a
/// vector with the words that are an anagram to that word
/// # Examples
/// ```
/// let inputs = ["tan", "stand", "at"];
/// let outputs: Vec<&str> = vec!["tan"];
/// assert_eq!(anagram::anagrams_for("ant", &inputs), outputs);
/// ```
pub fn anagrams_for<'... |
use std::io::Read;
fn main() {
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
let mut cups = u64::from_str_radix(input.trim(), 16).unwrap();
let cup_count = input.trim().len();
let pick_up_mask = (0..cup_count - 4).fold(0, |acc, n| acc | (0xF << n * 4));
l... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub const Catalog: ::windows_sys::core::GUID = ::windows_sys::core::GUID { data1: 1857169537, data2: 35353, data3: 4560, data4: [129, 182, 0, 160, 201, 35, 28, ... |
pub mod formalargs;
pub mod selectors;
mod strings;
mod unit;
mod util;
pub mod value;
use self::formalargs::{call_args, formal_args};
use self::selectors::selectors;
use self::strings::{sass_string, sass_string_dq, sass_string_sq};
use self::util::{comment, ignore_space, name, opt_spacelike, spacelike};
use self::val... |
use chrono::prelude::*;
use crate::hash::sha256;
fn get_hash_for_block(prev_block_hash: &str, data: &str, timestamp: i64) -> String {
let timestamp_bytes = timestamp.to_le_bytes();
let headers = [
prev_block_hash.as_bytes(),
data.as_bytes(),
×tamp_bytes[..],
]
.concat();
... |
#[derive(Debug)]
enum Never { }
fn f() -> Result<usize, Never> {
Ok(0)
}
fn main() {
println!("{}", f().unwrap());
}
|
mod error;
mod loading;
mod standard;
mod unsupported;
use std::cmp::{Ord, Ordering, PartialOrd};
use chrono::{DateTime, TimeZone};
use failure::Error;
use slack::api;
use models::{AppState, Canvas, ChannelID};
pub use self::error::ErrorMessage;
pub use self::loading::LoadingMessage;
pub use self::standard::Standar... |
#![ doc = include_str!("../README.md")]
#[macro_use]
extern crate clap;
mod app;
mod error;
mod project_config;
mod tmux;
use app::{actions, cli};
use error::AppErrorForDisplay;
fn main() -> Result<(), AppErrorForDisplay> {
let matches = cli::get_cli_command_parser().get_matches();
if let Some(project_name)... |
// 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 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 ... |
use std::fs::File;
use std::io::Write;
use std::vec::Vec;
use getopts::Options;
mod sdf;
use sdf::SDF;
fn main() {
let args: Vec<String> = std::env::args().collect();
let program_name = args[0].clone();
if args.len() == 1 {
println!("Error: \nUsage: cargo run input.png output.png");
retur... |
use liblumen_alloc::erts::exception::InternalResult;
use liblumen_alloc::erts::term::prelude::*;
use liblumen_alloc::erts::Process;
use super::u32;
use crate::distribution::external_term_format::try_split_at;
pub fn decode<'a>(process: &Process, bytes: &'a [u8]) -> InternalResult<(Term, &'a [u8])> {
let (len_u32,... |
use std::borrow::Cow;
use actix_web::{App, Error, HttpServer, Result, dev::{self, ServiceFactory}, web};
use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
use reqwest_tracing::TracingMiddleware;
mod api;
mod config;
mod pokemon;
mod translations;
#[actix_web::main]
async fn main() -> Result<(), Box<dyn ... |
use std::net::{TcpStream, Shutdown};
use std::io::{Write};
use std::io::{self};
fn main() {
match TcpStream::connect("localhost:3333") {
Ok(mut stream) => {
println!("Successfully connected to server in port 3333");
loop {
let mut buffer = String::new();
... |
//! Counter counts recurrent elements of iterables. It is based on [the Python
//! implementation](https://docs.python.org/3/library/collections.html#collections.Counter).
//!
//! The struct [`Counter`](struct.Counter.html) is the entry-point type for this module.
//!
//! # Math Underpinnings
//!
//! Mathematically, a ... |
#![allow(dead_code, non_snake_case)]
use crate::base::{
alu::alu,
dff::Clock,
dff::ClockState::{Tick, Tock},
logic::bit::I,
logic::{and, bit, mux16, not, or, Word},
pc::PC,
register::Register,
};
pub struct CPU {
pc: PC,
d_register: Register,
a_register: Register,
}
impl CPU {
... |
use std::io::IoError;
use std::error::{Error, FromError};
/// Possible parser errors
#[derive(Show, PartialEq)]
pub enum ParserErrorKind {
/// Parser met EOF before parsing a proper datum
UnexpectedEOF,
/// Unexpected token: the first string describes expected token, and the second describes
/// actual... |
pub struct Solution;
impl Solution {
pub fn three_sum_closest(mut nums: Vec<i32>, target: i32) -> i32 {
nums.sort();
let l = nums.len();
let mut closest = nums[0] + nums[1] + nums[2];
let mut distance = (closest - target).abs();
for i in 0..l {
if 3 * nums[i] >= ... |
//! `fsopen` and related functions in Linux's `mount` API.
use crate::backend::mount::types::{
FsMountFlags, FsOpenFlags, FsPickFlags, MountAttrFlags, MoveMountFlags, OpenTreeFlags,
};
use crate::fd::{BorrowedFd, OwnedFd};
use crate::{backend, io, path};
/// `fsopen(fs_name, flags)`
///
/// # References
/// - [U... |
// use std::process::Command;
fn main() {
//ffmpeg -i "001_Minhajulmuslim Bab Adab Pasal Ke-1 Adab Niat.MP4" -b:a 192K -vn "001_Minhajul-muslim-Bab-Adab Pasal Ke-1 Adab Niat.mp3"
let files = vec![
"001_Minhajulmuslim Bab Adab Pasal Ke-1 Adab Niat.MP4",
"002_Minhajul Muslim Bab Adab Pasal Ke-2 Adab Terhada... |
//! Subcommand implementations and dispatch function `run()`.
pub mod info;
pub mod list;
pub mod scan;
pub mod staged;
pub mod stashed;
pub mod status;
pub mod unstaged;
use config::Config;
use errors::{GitGlobalError, Result};
use report::Report;
/// Run the subcommand matching the provided `str`, returning a `Repo... |
mod block;
mod blocks;
mod chunk;
mod chunks;
mod succinct_bit_vector;
mod succinct_bit_vector_builder;
use super::bit_string::BitString;
use super::internal_data_structure::popcount_table::PopcountTable;
use super::internal_data_structure::raw_bit_vector::RawBitVector;
use std::collections::HashSet;
/// Succinct bit... |
pub struct Solution;
impl Solution {
pub fn read_binary_watch(num: i32) -> Vec<String> {
Solver::new().solve(num)
}
}
#[derive(Default)]
struct Solver {
res: Vec<String>,
}
impl Solver {
fn new() -> Self {
Self::default()
}
fn solve(mut self, num: i32) -> Vec<String> {
... |
// DragonflyBSD also!
mod acpi;
mod device;
mod iterator;
mod manager;
pub use self::device::IoCtlDevice;
pub use self::iterator::IoCtlIterator;
pub use self::manager::IoCtlManager;
|
// Copyright © 2019 George Burton
//
// 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, publish, dist... |
use std::path::Path;
use gfapi_sys::gluster::*;
use libc::{
timespec, O_APPEND, O_CREAT, O_RDWR, O_TRUNC, SEEK_SET, S_IRGRP, S_IROTH, S_IRUSR, S_IWUSR,
S_IXUSR,
};
fn main() {
let cluster = match Gluster::connect("test", "localhost", 24007) {
Ok(c) => c,
Err(e) => {
println!... |
#[derive(Copy, Clone, Debug, Serialize, Deserialize)]
pub enum LogLevel {
Trace,
Debug,
Info,
Warn,
Error,
} |
use crate::geometry::*;
use ordered_float::OrderedFloat;
use approx::relative_eq;
trait SliceUp: Sized {
type PerSlice: Iterator<Item = Self>;
type Out: Iterator<Item = Self::PerSlice>;
fn slice_up_x(&self, planes: PlaneSet) -> Self::Out;
fn slice_up_y(&self, planes: PlaneSet) -> Self::Out;
}
type Lin... |
#![cfg_attr(not(feature = "std"), no_std)]
//! **WARNING**: v0.1.x is incompatible with v0.2.x onwards.
//!
//! API to use files as a lock. Supports non-std crates by disabling feature
//! `std`.
//!
//! # Types
//! Currently, only one type is provided: [`LockFile`]. It does not destroy the
//! file after closed. Lock... |
#[path = "with_async_true/with_info_false.rs"]
mod with_info_false;
#[path = "with_async_true/with_info_true.rs"]
mod with_info_true;
#[path = "with_async_true/without_info.rs"]
mod without_info;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.