text stringlengths 8 4.13M |
|---|
//! # ArcGuard
//!
//! A Guard around `Arc<Mutex<T>>` allowing you to write less boilerplate code.
//!
//! # Example
//!
//! Before:
//! ```
//! use std::sync::{Arc, Mutex};
//!
//! let indicator = Arc::new(Mutex::new(Indicator::new()));
//! let indicator_clone = indicator.clone();
//! let indicator_clone = indicator_c... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
//! This crate contains Winterfell STARK prover and verifier.
//!
//! A STARK is a novel proof-of-computation scheme to create efficiently... |
use chrono;
use fern;
pub(crate) fn set_up_logging() {
use fern::colors::{Color, ColoredLevelConfig};
let colors_line = ColoredLevelConfig::new()
.error(Color::BrightRed)
.warn(Color::Yellow);
let colors_level = colors_line.clone().info(Color::Green).debug(Color::Cyan);
// here we set... |
#[doc = "Register `CCIPR2` reader"]
pub type R = crate::R<CCIPR2_SPEC>;
#[doc = "Register `CCIPR2` writer"]
pub type W = crate::W<CCIPR2_SPEC>;
#[doc = "Field `I2S1SEL` reader - 2S1SEL"]
pub type I2S1SEL_R = crate::FieldReader;
#[doc = "Field `I2S1SEL` writer - 2S1SEL"]
pub type I2S1SEL_W<'a, REG, const O: u8> = crate:... |
mod common;
use std::str::FromStr;
fn part1(passports: &[Passport]) -> usize {
passports.iter().filter(|p| p.is_valid()).count()
}
fn part2(passports: &[Passport]) -> usize {
passports.iter().filter(|p| p.is_strictly_valid()).count()
}
#[derive(Debug)]
struct Passport {
byr: Option<String>,
iyr: Opti... |
use std::io::{Write, Result};
use util::join;
use parser::html::Comparator;
use super::Generator;
use super::ast::{Code, Statement, Expression};
pub trait Emit {
fn emit(&mut self, code: &Code) -> Result<()>;
}
fn write_str<W:Write, S: AsRef<str>>(w: &mut W, val: S) -> Result<()> {
try!(w.write_all(b"\""));... |
// file: stochastic.rs
//
// Copyright 2015-2017 The RsGenetic Developers
//
// 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 re... |
// Test compression algorithms for numbers / data
// Written 2016.04.05 by Willi Kappler (grandor@gmx.de)
// External crates:
// none
// Internal crates:
extern crate compression1;
// System modules:
// none
// External modules:
// none
// Internal modules:
use compression1::*;
fn main() {
let y1 = compress_... |
#![windows_subsystem = "windows"]
use std::thread;
use std::time::{
Duration,
Instant
};
#[cfg(windows)]
mod windows;
#[cfg(windows)]
use windows::{get_idle_time, start};
use crossbeam::channel::{
unbounded,
Sender
};
const IDLE_PAUSE_TIME: Duration = Duration::from_secs(60);
const IDLE_RESET_TIME: ... |
use crate::map::triangle::Triangle;
use crate::math::vector::Vector2;
pub struct Sector {
pub index: usize,
pub bottom: f32,
pub floor: f32,
pub ceiling: f32,
pub top: f32,
pub floor_texture: i32,
pub ceiling_texture: i32,
pub vecs: Vec<Vector2>,
pub lines: Vec<usize>,
pub trian... |
use crate::mcc::agent::mcc_agent::MCCAgent;
#[derive(Clone)]
pub struct AgentQueue {
agents: Vec<MCCAgent>,
current_agent_index: usize,
pub max_items_limit: u32,
total_individuals_added: u32,
}
impl AgentQueue {
pub fn new(mcc_agents: Vec<MCCAgent>, max_items_limit: u32) -> AgentQueue {
le... |
extern crate bindgen;
extern crate cc;
use std::env;
use std::path::PathBuf;
fn main() {
println!("cargo:rerun-if-changed=src/c/snes_spc/spc.h");
cc::Build::new()
.include("src/c/")
.flag("-fPIC")
.flag("-fno-exceptions")
// .flag("-Wno-implicit-fallthrough")
.flag("-fn... |
pub fn high_entropy_pass(input: &str) -> bool {
let string_array: Vec<&str> = input.split(' ').collect();
for (ind1, string1) in string_array.iter().enumerate() {
for (ind2, string2) in string_array.iter().enumerate() {
if ind1 == ind2 {
continue;
}
if... |
#[rustfmt::skip]
pub(crate) const LUT_VCOM_DC: [u8; 44] = [
0x00, 0x00,
0x00, 0x1A, 0x1A, 0x00, 0x00, 0x01,
0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08,
0x00, 0x0E, 0x01, 0x0E, 0x01, 0x10,
0x00, 0x0A, 0x0A, 0x00, 0x00, 0x08,
0x00, 0x04, 0x10, 0x00, 0x00, 0x05,
0x00, 0x03, 0x0E, 0x00, 0x00, 0x0A,
0x00, 0x23, 0x00, 0x00, 0x00, 0x... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct ApiErrorBase {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
#[s... |
use std::{
future::Future,
mem,
pin::Pin,
task::{Context, Poll},
};
use futures_core::ready;
use futures_util::{future, FutureExt, Sink, SinkExt};
use tokio::{task::JoinHandle, time::timeout};
/// Returns a future that will flush the sink, even if flushing is temporarily completed.
/// Finishes only i... |
#[doc = "Reader of register RCC_MC_APB2LPENCLRR"]
pub type R = crate::R<u32, super::RCC_MC_APB2LPENCLRR>;
#[doc = "Writer for register RCC_MC_APB2LPENCLRR"]
pub type W = crate::W<u32, super::RCC_MC_APB2LPENCLRR>;
#[doc = "Register RCC_MC_APB2LPENCLRR `reset()`'s with value 0x0137_271f"]
impl crate::ResetValue for super... |
use std::cmp;
#[derive(Debug, PartialEq)]
pub struct SquareLocation {
pub x: i32,
pub y: i32,
}
#[derive(Debug, Clone)]
pub struct Square {
pub index: usize,
pub content: Option<u32>,
}
#[derive(Debug, Clone)]
pub struct Ring {
pub n: u32,
pub squares: Vec<Square>,
}
#[derive(Debug)]
pub str... |
use env_logger::{Builder, Env};
use log::*;
use std::cmp::max;
use std::error::Error;
use std::io;
use std::net::UdpSocket;
use std::sync::{Arc, Mutex};
use std::thread;
use stepper::*;
fn main() -> Result<(), Box<dyn Error>> {
Builder::from_env(Env::default().default_filter_or("info"))
.default_format_tim... |
// Compatibility macros/typedefs needed for Solaris -> Linux port
pub fn p2_align(x: u64, align: u64) -> u64 {
x & -(align as i64) as u64
}
fn p2_cross(x: u64, y: u64, align: u64) -> bool {
x ^ y > align - 1
}
fn p2_round_up(x: u64, align: u64) -> u64 {
((x - 1) | (align - 1)) + 1
}
fn p2_boundary(off: ... |
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 crate::Number;
use super::Term;
///An enum defining the different operations supported by sequence terms
pub enum SequenceOperations
{
Addition,
Multiplication
}
///A term which takes in a vector of terms and combines them together with an operator (i.e. +, *)
pub struct SequenceTerm<T: Number>
{
t... |
use libc::c_int;
use ffi::{core, LLVMPassManager};
use ffi::prelude::LLVMPassManagerRef;
use cbox::CSemiBox;
use std::marker::PhantomData;
use module::Module;
use ffi::transforms::scalar::*;
use ffi::transforms::vectorize::*;
use ffi::transforms::ipo::*;
use value::Value;
use ffi::LLVMPassRegistry;
use ffi::core::LLVMG... |
use std::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
pub enum Version {
V1,
}
impl fmt::Display for Version {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let value = format!("{:?}", self).to_lowercase();
f.write_str(&value)
}
}
|
use super::components::*;
use super::map::Map;
use super::string_writer::StringWriter;
use serde::{Deserialize, Serialize};
use specs::error::NoError;
use specs::prelude::*;
use specs::saveload::{
DeserializeComponents, SerializeComponents, SimpleMarker, SimpleMarkerAllocator,
};
#[derive(Default, Serialize, Deser... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use std::cell::RefCell;
use std::cmp::max;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use crate::block::Heade... |
use crate::{
chat_server::{ChatServer, MessagePayload},
pb::teddy::{
teddy_service_server::{TeddyService, TeddyServiceServer},
SendMessageRep, SendMessageReq,
},
};
use actix::Addr;
use tonic::{Request, Response, Status};
pub struct Teddy {
server: Addr<ChatServer>,
}
impl Teddy {
p... |
use std::fmt::Debug;
pub type Stack<T> = Vec<T>;
pub trait BasicStack<T> {
fn empty_stack() -> Self;
fn push(&mut self, item: T);
fn pop(&mut self) -> Option<T>;
fn peek(&mut self) -> Option<&T>;
fn is_empty(&self) -> bool;
}
pub trait Env<T> {
fn empty_env(&self) -> Self;
fn extend_env(&... |
#[doc = "Interrupt\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).... |
use super::super::atom::{
btn::Btn,
common::Common,
fa,
heading::{self, Heading},
slider::{self, Slider},
text::Text,
};
use super::super::organism::{
popup_color_pallet::{self, PopupColorPallet},
room_modeless::RoomModeless,
};
use super::ShowingModal;
use crate::arena::{block, BlockMut... |
use crate::errors::*;
use crate::game::Game;
use serde::{Deserialize, Serialize};
use std::path::{Path, PathBuf};
const VERSION: usize = 1;
#[derive(Deserialize, Debug, Serialize)]
pub struct Database {
version: usize,
pub games: Vec<Game>,
#[serde(skip)]
path: PathBuf,
}
impl Database {
pub fn n... |
#[macro_use]
extern crate vulkano;
#[macro_use]
extern crate vulkano_shader_derive;
use std::sync::Arc;
use vulkano::buffer::BufferUsage;
use vulkano::buffer::CpuAccessibleBuffer;
use vulkano::command_buffer::AutoCommandBufferBuilder;
use vulkano::command_buffer::CommandBuffer;
use vulkano::descriptor::descriptor_se... |
#[derive(Copy, Clone, Debug, PartialEq)]
struct Number (i32);
fn main() {
let num = Number(8i32);
println!("{:?}", num);
let num_clone = num.clone();
println!("{:?}", num_clone);
println!("num == num_clone ? {}", num == num_clone);
}
|
use crate::applied_channel_txn::AppliedChannelTxn;
use crate::proof::signed_channel_transaction_proof::SignedChannelTransactionProof;
use anyhow::{ensure, Result};
use libra_types::account_address::AccountAddress;
use libra_types::contract_event::ContractEvent;
use libra_types::ledger_info::LedgerInfo;
use libra_types... |
/*
SPDX-License-Identifier: Apache-2.0 OR MIT
Copyright 2020 The arboard contributors
The project to which this file belongs is licensed under either of
the Apache 2.0 or the MIT license at the licensee's choice. The terms
and conditions of the chosen license apply to this file.
*/
//!
//!
//! This implementation is... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct DatadogAgreementProperties {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub publisher: Opti... |
use std::fs::read_to_string;
/// Logic for handling out-of-memory situations.
pub trait MemoryInfo {
/// Return how much memory the computer has, as bytes.
fn total_memory(&self) -> usize;
/// Return how much memory we have, as bytes.
fn get_available_memory(&self) -> usize;
/// Return how much pr... |
// Copyright 2017 rust-ipfs-api Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except accord... |
#![allow(non_camel_case_types)]
#![allow(clippy::upper_case_acronyms)]
use littlefs2::consts;
// TODO: this needs to be overridable.
// Should we use the "config crate that can have a replacement patched in" idea?
pub type MAX_APPLICATION_NAME_LENGTH = consts::U256;
pub const MAX_LONG_DATA_LENGTH: usize = 1024;
pub ... |
mod ssdp;
pub use self::ssdp::SSDPServer;
mod mediaserver;
pub use self::mediaserver::MediaServer;
|
//! # RISC Emulator Core
//! The core library for the rust RISC emulator crate.
pub mod tests;
|
extern crate piston_snake;
fn main() {
piston_snake::run(160, 160);
}
|
use crate::rtb_type;
rtb_type! {
AgentType,
500,
Webbrowser=1;
InApp=2;
PersonBasedId=3
}
|
// Copyright (c) 2016-2017 Chef Software Inc. and/or applicable contributors
//
// 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
//
// Unl... |
use std::{io::Write, net::SocketAddr};
use mio::net::TcpStream;
use serde::Serialize;
use crate::common::message_type::{MsgEncryption, MsgType, UdpPacket};
use super::RendezvousServer;
impl RendezvousServer {
pub fn send_tcp_message<T: ?Sized>(sock: &mut TcpStream, t: MsgType, msg: &T) where T: Serialize {
... |
use super::types::Only;
use crate::data::Entry;
use crate::data::{Item, Status};
use crate::index::Indexer;
use anyhow::Result;
use crossterm::style::Stylize;
use std::path::PathBuf;
pub struct StatusHandler {
indexer: Indexer,
items: Vec<Item>,
}
// Public methods.
impl StatusHandler {
pub fn new(home: P... |
//! Cluster Amazon ratings.
use crate::prelude::*;
use polars::prelude::*;
/// Group Amazon ratings into clusters.
#[derive(Args, Debug)]
#[command(name = "cluster-ratings")]
pub struct ClusterRatings {
/// Rating output file
#[arg(short = 'o', long = "output", name = "FILE")]
ratings_out: PathBuf,
//... |
pub use {Trie, TrieLayer, TrieIter};
pub use tuple_utils::Merge;
pub struct TrieAnd<A, B>(A, B);
impl<A, B> TrieAnd<A, B> {
pub fn new(a: A, b: B) -> TrieAnd<A, B> {
TrieAnd(a, b)
}
}
pub struct TrieAndL2<A, B>(A, B);
pub struct TrieAndL1<A, B>(A, B);
pub struct TrieAndL0<A, B>(A, B);
impl<A, B> Tr... |
use serde::{Deserialize, Serialize};
use typed_builder::TypedBuilder;
#[derive(
Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, TypedBuilder,
)]
#[cfg_attr(feature = "structopt", derive(structopt::StructOpt))]
#[cfg_attr(feature = "poem-openapi", derive(poem_openapi::Object))]
#[cfg_att... |
extern crate lanyout;
#[no_mangle]
pub extern "C" fn test() -> i32 {
let mut err = 0;
err += lanyout::frame::test::test();
err += lanyout::canvas::test::test();
return err;
}
fn main() {
lanyout::init();
test();
lanyout::main_loop();
}
|
use aoc2019::intcode::IntCodeCpu;
use std::collections::HashMap;
use std::fs;
use std::io;
#[derive(PartialEq, Clone, Copy, Debug)]
enum Color {
Black,
White,
}
impl From<i64> for Color {
fn from(val: i64) -> Self {
match val {
0 => Color::Black,
1 => Color::White,
... |
#[doc = "Register `ETH_MACRxTxSR` reader"]
pub type R = crate::R<ETH_MACRX_TX_SR_SPEC>;
#[doc = "Field `TJT` reader - TJT"]
pub type TJT_R = crate::BitReader;
#[doc = "Field `NCARR` reader - NCARR"]
pub type NCARR_R = crate::BitReader;
#[doc = "Field `LCARR` reader - LCARR"]
pub type LCARR_R = crate::BitReader;
#[doc =... |
extern crate advent_of_code_2017_day_13;
use advent_of_code_2017_day_13::*;
#[test]
fn part_1_example() {
let input = "\
0: 3
1: 2
4: 4
6: 4";
assert_eq!(solve_puzzle_part_1(input), "24");
}
#[test]
fn part_2_example() {
let input = "\
0: 3
1: 2
4: 4
6: 4";
assert_eq!(solve_puzzle_part_2(input), "10"... |
#[derive(Debug, PartialEq, Clone)]
pub struct CircularBuffer <T> {
capacity: usize,
buffer: Vec<T>
}
#[derive(Debug, PartialEq)]
pub enum Error {
EmptyBuffer,
FullBuffer,
}
impl<T: std::clone::Clone + std::fmt::Debug> CircularBuffer<T> {
pub fn new(capacity: usize) -> Self {
let vector: Ve... |
use std::fmt;
use std::fs::OpenOptions;
use std::io::{self, LineWriter, Write};
use std::net::IpAddr;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::time::SystemTime;
use anyhow::{anyhow, Error};
use log::debug;
use serde::Serialize;
use structopt::StructOpt;
use hassh::{live, packet::KeyExchange, pc... |
#[doc = "Register `SR2` reader"]
pub type R = crate::R<SR2_SPEC>;
#[doc = "Field `SDBF` reader - Step Down converter Bypass mode flag"]
pub type SDBF_R = crate::BitReader;
#[doc = "Field `SDSMPSF` reader - Step Down converter SMPS mode flag"]
pub type SDSMPSF_R = crate::BitReader;
#[doc = "Field `REGLPS` reader - Low-p... |
#[doc = "Register `SCAR_PRG` reader"]
pub type R = crate::R<SCAR_PRG_SPEC>;
#[doc = "Register `SCAR_PRG` writer"]
pub type W = crate::W<SCAR_PRG_SPEC>;
#[doc = "Field `SEC_AREA_START` reader - Bank 1 lowest secure protected address configuration"]
pub type SEC_AREA_START_R = crate::FieldReader<u16>;
#[doc = "Field `SEC... |
pub fn solve_puzzle_part_1(input: &str) -> String {
input
.lines()
.map(is_valid_passphrase_part_1)
.filter(|&bool| bool)
.count()
.to_string()
}
pub fn solve_puzzle_part_2(input: &str) -> String {
input
.lines()
.map(is_valid_passphrase_part_2)
.... |
use necsim_core::{
cogs::{Habitat, HabitatPrimeableRng, PrimeableRng, TurnoverRate},
intrinsics::floor,
landscape::IndexedLocation,
};
use necsim_core_bond::NonNegativeF64;
use super::EventTimeSampler;
#[allow(clippy::module_name_repetitions)]
#[derive(Clone, Debug)]
#[cfg_attr(feature = "cuda", derive(ru... |
use frame_support::weights::{constants::RocksDbWeight as DbWeight, Weight};
pub trait WeightInfo {
fn on_finalize() -> Weight;
fn account_disable() -> Weight;
fn account_add_with_role_and_data() -> Weight;
fn account_set_with_role_and_data() -> Weight;
fn token_mint_request_create_everusd() -> Weig... |
#![deny(clippy::all)]
#![warn(clippy::pedantic)]
#![allow(clippy::single_match)]
#![allow(clippy::cast_possible_truncation)]
use std::fmt::{Display, Formatter, Result};
use std::fs;
use std::vec::Vec;
use svg2polylines::{parse, CoordinatePair};
static FILLER: char = '#';
#[derive(Debug)]
pub struct AsciiResult {
... |
#[aoc_generator(day01)]
pub fn day01_gen(input: &str) -> Vec<i32> {
input.lines().map(|l| l.parse().unwrap()).collect()
}
#[aoc(day01, part1)]
pub fn day01_part1(input: &[i32]) -> i32 {
input
.iter()
.map(|&n| (n as f32 / 3.0).floor() as i32 - 2)
.sum()
}
fn calculate_fuel(n: i32) -> i... |
use std::cell::RefCell;
use std::rc::Rc;
use web_sys;
use web_sys::{WebGl2RenderingContext, WebGlBuffer, WebGlProgram};
use nalgebra_glm as glm;
use regmach::dsp::types as rdt;
use std::collections::{HashMap, HashSet};
// #[derive(PartialEq, Eq, Hash)]
// pub struct MeshId(u32);
pub struct Mesh {
pub vertices: ... |
use permutohedron::Heap;
use std::collections::HashMap;
pub type Word = i64;
pub struct Computer {
input: Option<Word>,
pc: Word,
pub memory: Memory,
pub outputs: Vec<Word>,
halted: bool,
relative_base: Word,
}
#[derive(Debug)]
pub struct Memory {
mem: HashMap<Word, Word>,
}
impl Memory ... |
///
/// Wraps `s` at each `width`-th character adding `wrapstr` as a kind of line ending.
///
pub fn wrap_words(s: &str, width: u32, wrapstr: &str) -> String {
let mut out = Vec::<String>::new();
for line in s.lines() {
let mut cur_line = String::new();
for word in line.split_whitespace() {
... |
use crate::{Scene, point, GRID_HORZ_COUNT, GRID_VERT_COUNT, SceneParams};
use ggez::{Context, GameError};
use ggez::event::KeyCode;
use crate::data::maps::{Map, read_map_file};
use crate::graphics::renderer::*;
use std::rc::Rc;
use crate::graphics::map_rendering::{draw_map_with_costs, draw_map_with_costs_start_end};
us... |
/*!
```rudra-poc
[target]
crate = "algorithmica"
version = "0.1.8"
[report]
issue_url = "https://github.com/AbrarNitk/algorithmica/issues/1"
issue_date = 2021-03-07
rustsec_url = "https://github.com/RustSec/advisory-db/pull/872"
rustsec_id = "RUSTSEC-2021-0053"
[[bugs]]
analyzer = "UnsafeDataflow"
bug_class = "PanicS... |
use std::fmt;
use std::iter::Peekable;
use std::str::CharIndices;
#[derive(Debug)]
pub enum TokenKind {
LParen,
RParen,
LBracket,
RBracket,
Quote,
Name(String),
Integer(i64),
String(String)
}
#[derive(Debug)]
pub struct Token {
pub kind: TokenKind,
pub pos: usize
}
impl Token {
fn new_simple(ch: char, pos... |
use typesense::Document;
use serde::{Serialize, Deserialize};
#[derive(Document, Serialize, Deserialize)]
struct Company {
company_name: String,
num_employees: i32,
#[typesense(facet)]
#[typesense(facet)]
country_code: String,
}
fn main() {}
|
//! Provides Result type and Error type commonly used in apllodb workspace.
mod from;
pub(crate) mod session_error;
pub(crate) mod sqlstate;
use sqlstate::SqlState;
use std::{error::Error, fmt::Display};
use serde::{Deserialize, Serialize};
/// Result type commonly used in apllodb workspace.
pub type ApllodbResult<... |
use std::{
io,
time::Instant
};
use fibonacci_series::{fibonacci_non_recursive, fibonacci_recursive};
fn main() {
println!("Fibonacci Series");
loop {
println!("please input a positive number:");
let mut target = String::new();
io::stdin()
.read_line(&mut target)
... |
use nom::number::complete::{le_u8, le_u16, le_u32, le_u64, le_f32};
use serde_derive::{Serialize};
#[derive(Debug, PartialEq, Serialize)]
pub struct PacketHeader {
pub m_packetFormat: u16,
pub m_gameMajorVersion: u8,
pub m_gameMinorVersion: u8,
pub m_packetVersion: u8,
pub m_packetId: u8,
pub m... |
//! MIPS CP0 EntryLo register
bitflags! {
pub struct Flags : u32 {
const DIRTY = 0b000100;
const VALID = 0b000010;
const GLOBAL = 0b000001;
const UNCACHED = 0b010000;
const CACHEABLE = 0b011000;
const FLAG_MASK = 0b111111;
const CACHE_MASK =... |
/// Pallet's business-logic public interface
use crate::proposal::{InputProposalBatch, DeipProposal, ProposalId};
use crate::storage::StorageWrite;
use super::{Config, Error};
/// Create proposal
pub fn propose<T: Config>(
author: T::AccountId,
batch: InputProposalBatch<T>,
external_id: Option<ProposalId... |
use std::marker::PhantomData;
use mopa;
use render::RenderBuilder;
use event::{EventHandler, EventArgs};
use geometry::Rect;
pub trait Draw: ::std::fmt::Debug + mopa::Any {
fn draw(&mut self, bounds: Rect, crop_to: Rect, renderer: &mut RenderBuilder);
}
mopafy!(Draw);
pub struct DrawEventHandler<T, E> {
... |
//! Contains marker types used to implement type state for encrypted and signed
//! GBLs.
use self::private::*;
use super::*;
use crate::utils::Blob;
use either::Either;
use std::borrow::Cow;
use std::fmt;
use std::marker::PhantomData;
mod sealed {
use super::*;
pub trait Sealed {}
impl<'a> Sealed for ... |
use crate::db::CONN;
use crate::model::{RegisterRequest, Rights, User};
use rusqlite::{params, Result};
use std::str::FromStr;
pub struct UserRepository {}
impl UserRepository {
pub fn init_tables() -> Result<()> {
CONN.lock().unwrap().execute(
"create table if not exists users (
... |
//! This crate is a wrapper around [PulseAudio's repackaging of WebRTC's AudioProcessing module](https://www.freedesktop.org/software/pulseaudio/webrtc-audio-processing/).
//!
//! See `examples/simple.rs` for an example of how to use the library.
#![warn(clippy::all)]
#![warn(missing_docs)]
mod config;
use std::{err... |
use serde_scan::scan;
use std::cmp::Reverse;
use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque};
type Task = char;
type Result<T> = std::result::Result<T, std::boxed::Box<dyn std::error::Error>>;
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
struct InProgressTask {
task: Task,
remaining_time:... |
extern crate clap;
use clap::{App, Arg, ErrorKind, Shell, SubCommand};
use serde_json::Value;
use std::fs::File;
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use std::process::exit;
use std::{env, fs, io};
use workon_rs::init;
#[allow(unused)]
const RETURN_OK: i32 = 0;
const RETURN_ERROR: i32 = 1;
fn m... |
use crate::errors::FormatError;
use crate::try_continue;
#[derive(Debug, PartialEq)]
enum Segment {
PlaceHolder {
padding: Option<usize>,
index: usize,
},
String(String),
}
#[derive(Debug, PartialEq)]
pub struct Formatter(Vec<Segment>);
impl Formatter {
pub fn new(format: &str) -> Res... |
fn main() {
/*
Formatated print
`format!`: ํฌ๋งท์ด ์๋ ํ
์คํธ๋ฅผ ์คํธ๋ง ํํ๋ก ๋ฆฌํด
`print!`: `format!`๊ณผ ๋์ผํ์ง๋ง ํ
์คํธ๋ฅผ ์ฝ์ ์ถ๋ ฅ(`io::stdout`)
`println!`: `print!`์ ๊ฐํ๋ฌธ์ ์ถ๊ฐ
`eprint!`: `format!`๊ณผ ๊ฐ์ผ๋ ํ
์คํธ๋ฅผ `ํ์ค์๋ฌ`๋ก ์ถ๋ ฅ(`io::stderr`)
`eprintln!`: `eprint!`์ ๊ฐํ๋ฌธ์ ์ถ๊ฐ
*/
let days_of_month = format!("{} days", 31);
... |
//! # The zone/world (`*.luz`) file format
//!
//! This module can be used to read the zone/world file format
//! used in the game LEGO Universe.
/// Data definitions for zone files
pub mod core;
/// Reading of zone files
pub mod io;
/// Parser functions for zone file data
pub mod parser;
/// Module for reading the pa... |
// Copyright (C) 2021 Subspace Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unle... |
#[macro_use]
extern crate tantivy;
#[macro_use]
extern crate serde_derive;
pub mod search;
|
use ws::{Sender,Handshake,Handler,Result,CloseCode,Message};
use socket_server::gamestate;
use std::sync::{Arc,Mutex};
use socket_server::gamestate::GameState;
pub struct Client{
pub id: u64,
pub out: Sender,
gamestate: Arc<Mutex<GameState>>,
}
impl Handler for Client {
fn on_open(&mut self, _: Handshake) -> Resul... |
pub fn start_server(_name: &String) {
use duct::cmd;
use std::io::{prelude::*, BufReader, stdout, Write};
let reader = cmd!("java", "-jar", "server.jar", "nogui").dir("server").reader().unwrap();
let buf_reader = BufReader::new(reader);
let mut stdout = stdout();
for l in buf_reader.lines() {
let line = l.unw... |
use jsonrpc_tcp_server::jsonrpc_core::*;
use mcsql_sys;
pub fn register_mcsql_funcs(io: &mut IoHandler) {
io.add_method("arc_get_all", |_params: Params| {
let res = mcsql_sys::arc_get_all();
Ok(Value::String(res))
});
io.add_method("arc_get_params", |params: Params| {
#[derive(Deserialize)]
struct ArcPara... |
mod api_error;
pub use api_error::*;
|
use crate::miner::MinerClientActor;
use actix::Actor;
use actix_rt::System;
use bus::BusActor;
use config::MinerConfig;
use config::NodeConfig;
use consensus::argon::ArgonConsensus;
use futures_timer::Delay;
use logger::prelude::*;
use sc_stratum::{PushWorkHandler, Stratum};
use starcoin_miner::{
miner::{MineCtx, M... |
use crate::schema::usr_smile;
use chrono::prelude::*;
#[derive(Debug, Queryable, Identifiable, Serialize, Deserialize, PartialEq)]
#[table_name = "usr_smile"]
#[primary_key(user_id)]
pub struct User {
pub user_id: String,
pub username: String,
pub email: Option<String>,
pub joinAt: NaiveDateTime,
p... |
//! Various enums that you can match on.
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
/// The quarantine permissions.
pub struct QuarantinePermissions {
/// If styles are allowed.
pub styles: bool,
/// If sharing is allowed.
pub sharing: bool,
/// If subredd... |
use std::fs::File;
use std::io::{self, BufReader, Cursor, Read, Write};
use std::net::SocketAddr;
use std::path::{Path, PathBuf};
use std::pin::Pin;
use std::ptr::null_mut;
use std::sync::Arc;
use std::task::{Context, Poll};
use futures::ready;
use hyper::server::accept::Accept;
use hyper::server::conn::{AddrIncoming,... |
use glace::Vec3;
use winit::event::ElementState;
pub struct InputMap {
mouse1: ElementState,
mouse_delta: (f32, f32),
}
impl InputMap {
pub fn new() -> Self {
InputMap {
mouse1: ElementState::Released,
mouse_delta: (0.0, 0.0),
}
}
pub fn update_mouse1(&mut ... |
// Copyright (C) 2015-2021 Swift Navigation Inc.
// Contact: https://support.swiftnav.com
//
// This source is subject to the license found in the file 'LICENSE' which must
// be be distributed together with this source. All other rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ... |
use crate::DeriveInputExt;
use itertools::Itertools;
use proc_macro2::{Span, TokenStream};
use quote::quote;
use syn::{DeriveInput, Ident, LitInt, LitStr, Type};
#[allow(clippy::expect_used)]
pub(crate) fn locks_await(input: &DeriveInput) -> TokenStream {
let type_ident = &input.ident;
let from_ctx = LitStr::n... |
fn main() {
let _a = vec![true; 0];
let _b = vec![false; 0];
}
|
pub use super::value::Value;
pub struct Element {
value: Value
} |
extern crate day_08_registers;
extern crate utils;
use day_08_registers::{Processor, ProcessorTrait};
use utils::{file2str, str2linevec};
fn main() {
let puzzle = file2str("puzzle.txt");
let puzzle = str2linevec(&puzzle);
let mut cpu = Processor::new();
for instruction in puzzle.iter() {
cpu.... |
use std::fmt::Write;
use crate::{
commands::{osu::ProfileSize, utility::GuildData},
database::{EmbedsSize, GuildConfig, MinimizedPp},
embeds::Author,
};
pub struct ServerConfigEmbed {
author: Author,
description: String,
footer: &'static str,
title: &'static str,
}
impl ServerConfigEmbed ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.