text stringlengths 8 4.13M |
|---|
use crate::v0::support::{with_ipfs, InvalidPeerId, StringError};
use ipfs::{BitswapStats, Ipfs, IpfsTypes};
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use warp::{query, reply, Filter, Rejection, Reply};
#[derive(Debug, Deserialize)]
pub struct WantlistQuery {
peer: Option<String>,
}
#[der... |
static EPSILON: f64 = f64::EPSILON;
pub fn safe_invert(v: f64) -> f64 {
1. / (v + EPSILON)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_safe_invert() {
assert_eq!(safe_invert(10.0), 0.1);
assert_eq!(safe_invert(0.0), 1. / EPSILON);
}
}
|
// Copyright 2019, The Tari Project
//
// 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
// disclai... |
#[doc = "Reader of register CTL"]
pub type R = crate::R<u32, super::CTL>;
#[doc = "Writer for register CTL"]
pub type W = crate::W<u32, super::CTL>;
#[doc = "Register CTL `reset()`'s with value 0"]
impl crate::ResetValue for super::CTL {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
pub mod mercury;
pub mod venus;
pub mod earth;
pub mod mars;
pub mod jupiter;
pub mod saturn;
pub mod uranus;
pub mod neptune;
|
// 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 crate::server::LSPServer;
use crate::sources::LSPSupport;
use log::info;
use ropey::Rope;
use std::process::{Command, Stdio};
use tower_lsp::lsp_types::*;
impl LSPServer {
pub fn formatting(&self, params: DocumentFormattingParams) -> Option<Vec<TextEdit>> {
let uri = params.text_document.uri;
i... |
/**
A somewhat reduced test case to expose some Valgrind issues.
This originally came from the word-count benchmark.
*/
use std;
import std::io;
import option = std::option::t;
import std::option::some;
import std::option::none;
import std::str;
import std::vec;
import std::map;
fn map(filename: str, emit: ma... |
pub mod get_message_timestamp_field;
pub mod get_message_type;
|
use serde::Deserialize;
#[derive(Deserialize, Debug)]
pub struct FlightIdentificationNumberRaw {
pub default: Option<String>,
pub alternative: Option<String>, // Guess
} |
use std::collections::BinaryHeap;
#[test]
fn binary_peek_pop_test() {
//Binary heap organizes the greatest values up to the front of the queue
let mut heap = BinaryHeap::from(vec![2, 3, 8, 6, 9, 5, 4]);
//Retrieves a Option<&T> reference without removing
assert_eq!(heap.peek(), Some(&9));
//Pops t... |
//! Expressions
//!
//! See: [6.4 Expressions](http://erlang.org/doc/apps/erts/absform.html#id87350)
use super::*;
pub type LocalCall = common::LocalCall<Expression>;
pub type RemoteCall = common::RemoteCall<Expression>;
pub type Match = common::Match<Pattern, Expression>;
pub type Tuple = common::Tuple<Expression>;
p... |
use rsa::{pkcs8::FromPublicKey, RsaPublicKey};
use collectxyz::nft::{Config, XyzTokenInfo};
use cosmwasm_std::{Addr, StdError, StdResult, Storage};
use cw_storage_plus::{Index, IndexList, IndexedMap, Item, MultiIndex, UniqueIndex};
pub const CONFIG: Item<Config> = Item::new("config");
const CAPTCHA_PUBLIC_KEY: Item<... |
use std::{
pin::Pin,
task::{Context, Poll},
};
use futures::{ready, Stream, StreamExt};
use iox_query::QueryCompletedToken;
/// Wraps an inner query stream, calling the `QueryCompletedToken::set_success` on success
#[derive(Debug)]
pub struct QueryCompletedTokenStream<S, T, E>
where
S: Stream<Item = Resul... |
extern crate libcomchannel;
extern crate libconfig;
extern crate libdb;
extern crate libdbgserver;
extern crate libengine;
extern crate libmercury;
use libcomchannel::*;
use libdb::DataBase;
use libengine::*;
use libmercury::device::*;
use libmercury::iface::*;
use std::cell::RefCell;
use std::io::prelude::*;
use std:... |
use legion::{storage::Component, *};
use super::{
spatial_grid::DenseGrid,
};
use crate::{
simulation::{Config, RigidCircle},
timing::timer::time_func,
};
pub struct PhysicsPipeline {
grid: DenseGrid,
}
impl PhysicsPipeline {
pub fn new(_world: &mut World, config: &Config) -> Self {
let g... |
//! # kdtree
//!
//! K-dimensional tree for Rust (bucket point-region implementation)
//!
//! ## Usage
//!
//! ```
//! use kdtree::KdTree;
//! use kdtree::ErrorKind;
//! use kdtree::distance::squared_euclidean;
//!
//! let a: ([f64; 2], usize) = ([0f64, 0f64], 0);
//! let b: ([f64; 2], usize) = ([1f64, 1f64], 1);
//! l... |
/// Build libspiro binding for Rust.
extern crate bindgen;
extern crate cc;
extern crate dos2unix;
use std::env;
use std::path::PathBuf;
fn do_bindgen() {
// Based on `bindgen` manual.
let bindings = bindgen::Builder::default()
.header("wrapper.h")
// Tell cargo to invalidate the built crate ... |
mod auth;
mod user;
mod channel;
mod login;
mod group;
mod invite;
pub use auth::*;
pub use user::*;
pub use channel::*;
pub use login::*;
pub use group::*;
pub use invite::*;
|
#[doc = "Reader of register MBCNT"]
pub type R = crate::R<u32, super::MBCNT>;
#[doc = "Reader of field `CNTL`"]
pub type CNTL_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:7 - I2C Master Burst Count"]
#[inline(always)]
pub fn cntl(&self) -> CNTL_R {
CNTL_R::new((self.bits & 0xff) as u8)
}
}
|
fn main() {
let a= "Ciao";
let b= "popolo!";
println!("{} {}", a, b)
} |
use crate::position::Position;
use std::collections::VecDeque;
pub struct CharsWithPosition<I: Iterator<Item = char>> {
iter: MultiPeek<I>,
prev_pos: Position,
next_pos: Position,
}
impl<I: Iterator<Item = char>> CharsWithPosition<I> {
pub fn new(iter: I) -> CharsWithPosition<I> {
CharsWithPos... |
#![allow(clippy::comparison_chain)]
#![allow(clippy::collapsible_if)]
use std::cmp::Reverse;
use std::cmp::{max, min};
use std::collections::{BTreeSet, HashMap, HashSet};
use std::fmt::Debug;
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000_000_007;
/// 2の逆元 mod ten97.割りたいときに使う
const in... |
extern crate advent_14;
use std::cmp;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
fn find_max<'a, T: Ord>(lst: &'a Vec<T>) -> Option<&'a T> {
let mut max = None;
let find_max = |i: &'a T| {
max = match max {
None => Some(i),
Some(ref... |
pub use VkCommandPoolTrimFlags::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkCommandPoolTrimFlags {
VK_COMMAND_POOL_TRIM_NULL_BIT = 0,
}
use crate::SetupVkFlags;
#[repr(C)]
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub struct VkCommandPoolTrimFlagBits(u32);
SetupVkFlags!(VkCommandPoo... |
// 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 ... |
// 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 async_dup::{Arc, Mutex};
use async_std::io::{Read, Result, Write};
use async_std::net::TcpStream;
use async_tls::server::TlsStream;
use std::pin::Pin;
use std::task::{Context, Poll};
#[derive(Clone)]
pub(crate) struct TlsStreamWrapper(Arc<Mutex<TlsStream<TcpStream>>>);
impl TlsStreamWrapper {
pub(crate) fn ne... |
use super::*;
#[derive(Debug, PartialEq)]
pub struct UnaryOp {
pub op: UnaryOpKind,
pub rhs: Box<Node>,
}
#[derive(Debug, PartialEq)]
pub enum UnaryOpKind {
/// ~
BitNot,
/// +
Positive,
/// -
Negative,
/// !
LogicalNot,
}
impl From<char> for UnaryOpKind {
fn from(c: char)... |
mod app;
mod config;
mod subcommands;
use log::error;
use std::process;
fn main() {
let matches = app::init();
app::init_logger(&matches);
let mut commands = match config::read() {
Ok(c) => c,
Err(e) => {
error!("{}", e);
process::exit(1);
}
};
app:... |
//! The application domain.
//!
//! The domain is separated in two main areas:
//! * catalog: contains the basic information for a railway models;
//! * collecting: everything related to collecting models, collections and wishlists.
pub mod catalog;
pub mod collecting;
|
use yew::{
format::{
Json,
// Nothing
},
prelude::*,
services::fetch::{FetchService, FetchTask, Request, Response},
};
use yew_router::components::RouterAnchor;
use crate::app::AppRoute;
use yewtil::NeqAssign;
use crate::store::reducer_account::{
AppDispatch,
DataAccountAction,
... |
use std::collections::HashMap;
use std::pin::Pin;
use std::sync::Mutex;
use tokio_stream::Stream;
use tonic::{Request, Response, Status};
use common::t_service_server::TService;
use common::*;
use crate::client_cert::ClientName;
use crate::job::Job;
use crate::output_stream;
type BoxStream<T> = Pin<Box<dyn Stream<I... |
pub mod error;
pub mod language;
pub mod parser;
pub trait NodeExt {
fn matches_subtypes(&self, supertype_id: u16, subtype_ids: &[u16]) -> bool;
}
impl<'tree> NodeExt for tree_sitter::Node<'tree> {
fn matches_subtypes(&self, supertype_id: u16, subtype_ids: &[u16]) -> bool {
if let Some(child) = self.n... |
mod manifest;
pub type Specifier {
type Id;
fn matches(&self, id: &Self::Id) -> bool;
}
|
use criterion::{criterion_group, criterion_main, Criterion};
use day08::{part1, part2};
fn part1_benchmark(c: &mut Criterion) {
let input = include_str!("../../input/2018/day8.txt");
c.bench_function("part1", move |b| b.iter(|| part1(&input)));
}
fn part2_benchmark(c: &mut Criterion) {
let input = include... |
pub mod transform;
pub mod camera;
pub mod mesh;
pub mod light;
pub mod audio;
pub mod alarm;
pub mod singleton_component_manager;
pub mod struct_component_manager;
pub mod collider;
use ecs::*;
use engine::*;
use self::struct_component_manager::StructComponentManager;
use std::boxed::FnBox;
use std::fmt::Debug;
use s... |
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let n: u64 = rd.get();
let x: usize = rd.get();
let m: usize = rd.get();
let b = 34;
let mut nxt = vec![vec![0; m]; b];
// dp[i][j]: x = j から始めたときの a[1] + a[2] + ... + a[2^i]
let mut dp = vec![v... |
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "readlater", about, author)]
pub struct Args {
#[structopt(subcommand)]
pub cmd: Command,
#[structopt(short, long)]
pub verbose: bool,
}
#[derive(Debug, StructOpt)]
pub enum Command {
#[structopt(name = "newsboat")]
News... |
#[doc = "Reader of register IM"]
pub type R = crate::R<u32, super::IM>;
#[doc = "Writer for register IM"]
pub type W = crate::W<u32, super::IM>;
#[doc = "Register IM `reset()`'s with value 0"]
impl crate::ResetValue for super::IM {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
#![crate_name = "cql"]
#![crate_type = "rlib"]
#![crate_type = "dylib"]
#[macro_use]
extern crate enum_primitive as ep;
extern crate mio;
extern crate eventual;
extern crate uuid;
extern crate bytes;
pub use cluster::Cluster;
pub use def::Consistency;
pub use def::BatchType;
pub use def::CqlValue;
pub use def::Cql... |
use crate::instructions::Opcode;
use std::result::Result;
#[derive(Default)]
pub struct VM {
/// Array of `hardware` registers
pub registers: [i32; 32],
/// Program counter
pc: usize,
/// The bytecode of the program being run
pub program: Vec<u8>,
/// Remainder of modulo division ops
re... |
extern crate hyper;
extern crate rss;
extern crate chrono;
extern crate rand;
use std::io::{BufReader, Read, Write};
use std::fs::File;
use std::fmt::{Display, Formatter};
use std::fmt::Error as FmtError;
use std::result::Result;
use std::error::Error;
use self::chrono::*;
use self::rand::{thread_rng, Rng};
use sel... |
use std::rand;
fn main() {
println!("{}", (rand::random::<u32>() % 100) + 1);
}
|
use std::cell::UnsafeCell;
use std::ops::{Deref, DerefMut, Drop};
use abi;
#[repr(transparent)]
struct MutexInner(u32);
pub struct MutexGuard<'a, T: 'a> {
pfex_item: &'a MutexInner,
data: &'a mut T,
}
unsafe impl<T: Send> Send for Mutex<T> {}
unsafe impl<T: Send> Sync for Mutex<T> {}
pub struct Mutex<T> {
... |
use parking_lot::{Condvar, Mutex, MutexGuard, RawMutex, WaitTimeoutResult};
use std::{
ops::{Deref, DerefMut},
time::{Duration, Instant},
};
#[derive(Debug, Default)]
pub struct Monitor<T> {
mutex: Mutex<T>,
cv: Condvar,
}
impl<T> Monitor<T> {
pub fn new(t: T) -> Self {
Monitor {
... |
use crate::cell::Cell;
use std::cell::UnsafeCell;
#[derive(Copy, Clone)]
enum RefState {
Unshared,
Shared(usize),
Exclusive,
}
// implied since we are using UnsafeCell which is !Sync
// impl<T> !Sync for RefCell<T> {}
/// RefCell is a shareable mutable container that allows interior mutability.
///
/// R... |
use super::IDT_SIZE;
extern
{
static _asm_irq_handler_array: [u64, ..IDT_SIZE];
}
pub fn get_irq_handler(num: u16) -> u64
{
_asm_irq_handler_array[num]
}
|
use alewife;
use core::event;
use glutin;
use std::f32::consts::PI;
use na::{Point3, Vector2, Vector3, Matrix4, Isometry3, Perspective3, Translation3};
use na;
pub struct Camera {
event_queue: alewife::Subscriber<event::EventID, event::Event>,
eye: Point3<f32>,
pitch: f32,
yaw: f32,
speed: f32,
... |
use memory::WasmStack;
use arch::context::ThreadContext;
use arch::cpu::Local;
use nabi::{Result, Error};
use nil::mem::Bin;
/// The current state of a process.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum State {
/// The thread is currently executing.
Running,
/// This thread is not cu... |
use std::collections::HashSet;
fn main() {
let mut anyone_count = 0;
let mut everyone_count = 0;
let mut anyone = HashSet::new();
let mut everyone = HashSet::new();
let mut first_person = true;
for line in aoc::read_lines_as_vec("./day6.txt") {
if line.is_empty() {
anyone_c... |
#[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::HB16TIME {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R,... |
use std::io::{self, Write};
use super::bus::BusDevice;
pub struct QemuDebugConsole {}
impl QemuDebugConsole {
pub fn new() -> Self {
QemuDebugConsole {}
}
}
impl BusDevice for QemuDebugConsole {
fn write(&mut self, _offset: u64, data: &[u8]) {
io::stdout().write(data).unwra... |
#![crate_name = "uu_cp"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Jordy Dickinson <jordy.dickinson@gmail.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
extern crate getopts;
#[macro_use]
extern crate... |
use renderer::gl_vertex_format::{get_attribute_format, FVec3, VertexFormat};
use renderer::offset_of;
use std::mem::size_of;
use std::os::raw::c_void;
#[repr(C)]
pub struct Vertex {
position: FVec3,
color: FVec3,
}
impl Vertex {
pub fn new(x: f32, y: f32, z: f32, r: f32, g: f32, b: f32) -> Self {
... |
//! Generating a set of points for one measurement configuration
#![allow(clippy::result_large_err)]
use crate::{
field::FieldGeneratorImpl,
specification, substitution,
tag_pair::TagPair,
tag_set::{GeneratedTagSets, TagSet},
};
use influxdb2_client::models::WriteDataPoint;
use serde_json::json;
use s... |
use std::{fmt::Display, str::FromStr};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy, Default)]
pub enum MainResult {
/// fn main() -> () {()}
#[default]
Unit,
/// fn main() -> Result<(), Box<dy... |
use crate::config::Configuration;
use crate::utils::copy_and_sync_file;
use crate::Platform;
use crate::Result;
use crate::Runnable;
use anyhow::anyhow;
use cargo_metadata::Metadata;
use ignore::WalkBuilder;
use log::{debug, trace};
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
use std::... |
//! This example show the pattern "Strings and custom fail type" described in the book
extern crate core;
extern crate failure;
use core::fmt::{self, Display};
use failure::{Backtrace, Context, Fail, ResultExt};
fn main() {
let err = err1().unwrap_err();
// Print the error itself
println!("error: {}", err... |
use std::ffi::CString;
use std::fmt::Debug;
use wce_formats::binary_reader::BinaryReader;
use wce_formats::GameVersion;
pub mod unit;
pub mod ability;
pub mod item;
pub mod destructable;
pub mod buff;
pub mod doodad;
pub mod upgrade;
#[derive(Copy, Clone, PartialOrd, PartialEq, Debug)]
pub struct ObjectIdCode(pub [u... |
//! Processor state stored in the FLAGS, EFLAGS, or RFLAGS register.
use shared::PrivilegeLevel;
/// The RFLAGS register. All variants are backwards compatable so only one
/// bitflags struct needed.
bitflags! {
pub flags Flags: usize {
/// ID Flag (ID)
const FLAGS_ID = 1 << 21,
/// Virtua... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[cfg(feature = "UI_Core_AnimationMetrics")]
pub mod AnimationMetrics;
#[cfg(feature = "UI_Core_Preview")]
pub mod Preview;
#[link(name = "windows")]
extern "system" {}
pub type AcceleratorKeyEventArgs = *... |
extern crate hex;
use self::hex::ToHex;
struct State {
list: Vec<u8>,
position: usize,
skip_size: usize,
}
fn reverse_section<T : Clone>(list: &mut Vec<T>, start_index: usize, end_index: usize) {
if end_index != start_index {
if end_index > start_index {
list[start_index..end_index... |
use mqtt3::{MqttRead, MqttWrite};
use std::io::{self, Read, Write};
use std::net::Shutdown;
use std::time::Duration;
use netopt::{NetworkStream};
pub struct Connection {
stream: NetworkStream
}
impl Connection {
pub fn new(stream: NetworkStream) -> io::Result<Connection> {
Ok(Connection {
... |
use crate::concmap::*;
use crate::memory::*;
use crate::program::Program;
use crate::thread;
use std::sync::atomic::{AtomicU64, AtomicUsize, Ordering};
pub struct Cache {
r: ConcurrentMap<Box<[u32]>, Future<bool>>,
n_hits: AtomicU64,
n_consistent: AtomicUsize,
}
impl Cache {
#[inline]
pub fn new(... |
use libc::{tmpnam, L_tmpnam};
use std::os::raw::c_char;
use std::ffi::CStr;
use nix::unistd::{mkstemp, unlink};
use nix::sys::stat::fstat;
use nix::fcntl::readlink;
fn main() {
unsafe {
let mut tmp_file_name_ptr = [0u8; L_tmpnam as usize].as_mut_ptr() as *mut c_char;
tmpnam(tmp_file_nam... |
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(unused)]
#[cfg(target_os = "macos")]
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/file_finder/fts/bindings_macos.rs"
));
#[cfg(target_os = "linux")]
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
... |
use num::{traits::NumAssignRef, BigUint, CheckedMul};
// see Square roots by subtraction Frazer Jarvis
// http://www.afjarvis.staff.shef.ac.uk/maths/jarvisspec02.pdf
pub fn get_approximation(n: usize, precision: u32) -> BigUint {
let five = BigUint::from(5usize);
let ten = BigUint::from(10usize);
let forty... |
use std::fmt;
use rand::{Rng, SeedableRng};
use rand_xorshift::XorShiftRng;
/// A Dataset is basically an iterator, with some additional capabilities.
///
/// - `shuffle(buffer_size, seed)`: eagerly takes buffer_size items and returns shuffled
/// - `batch(batch_size, drop_remainder)`: an array of batch_size at a tim... |
use constants::EDITOR_MODES;
use crate::{constants, editor_config, editor_cursor, editor_visual, terminal_utility, input_utility, utility, input_process};
pub fn init_editor(editor_config: &mut editor_config::EditorConfig) {
terminal_utility::get_window_size(editor_config);
editor_visual::editor_refresh_scree... |
use super::{ConnectionSM, ConnectionSMResult};
use crate::{
error::{ProtoError, ProtoErrorKind, ProtoErrorResultExt},
message::{NowActivateMsg, NowCapabilitiesMsg, NowMessage},
sm::{ConnectionSMSharedData, ConnectionSMSharedDataRc, ConnectionState},
};
use log::info;
use std::{cell::RefCell, rc::Rc};
macro... |
use super::Pixel;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
/// A pixel with an RGB color representation.
pub struct RgbaPixel {
r: u8,
g: u8,
b: u8,
a: u8,
}
impl RgbaPixel {
/// Creates a new [`RgbaPixel`]
pub fn new(r: u8, g: u8, b: u8, a: u8) -> Self {
Self { r, g, b, a... |
use std::borrow::BorrowMut;
use std::cell::RefCell;
use std::collections::HashMap;
use std::env;
use std::ops::{Deref, DerefMut};
use std::process::Command;
use std::rc::Rc;
use std::sync::atomic::AtomicBool;
use std::sync::{Arc, Mutex};
use std::thread;
use std::thread::sleep;
use std::time::Duration;
use redis;
use ... |
use std::sync::Arc;
use datafusion::physical_plan::SendableRecordBatchStream;
use iox_query::{
exec::{Executor, ExecutorType},
frontend::reorg::ReorgPlanner,
QueryChunk,
};
use schema::sort::{adjust_sort_key_columns, compute_sort_key, SortKey};
use crate::{buffer_tree::table::TableName, query_adaptor::Que... |
#[doc = "Reader of register BUS_ERRORS0"]
pub type R = crate::R<u8, super::BUS_ERRORS0>;
#[doc = "Reader of field `bus_errors`"]
pub type BUS_ERRORS_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:7"]
#[inline(always)]
pub fn bus_errors(&self) -> BUS_ERRORS_R {
BUS_ERRORS_R::new((self.bits & 0xff) as... |
pub struct Solution;
impl Solution {
pub fn is_interleave(s1: String, s2: String, s3: String) -> bool {
let s1 = s1.into_bytes();
let s2 = s2.into_bytes();
let s3 = s3.into_bytes();
if s1.len() + s2.len() != s3.len() {
return false;
}
let (s1, s2) = if s1... |
// So far the implementations we have derived for our NewStruct object will require us to return the value of the fields
// themselves. When the fields implement Copy this will not be a particularly expensive operation, but when working with
// more complex fields we may not want to Clone the objects. This next implem... |
// 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. This file may not be copied, modified, or distributed
// except according to those terms.
//! Procedural macr... |
extern crate crypto;
extern crate rusqlite;
extern crate chrono;
mod database;
mod shared;
mod budget;
mod transaction;
mod can_access_budget;
mod budget_period;
mod api;
mod util;
mod config;
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use openssl::ssl::{SslAcceptor, SslFiletype, SslMethod};
use... |
#![allow(clippy::comparison_chain)]
#![allow(clippy::collapsible_if)]
use std::cmp::Reverse;
use std::cmp::{max, min};
use std::collections::{BTreeSet, HashMap, HashSet};
use std::fmt::Debug;
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000_000_007;
/// 2の逆元 mod ten97.割りたいときに使う
const in... |
use bulletproofs::r1cs::Variable;
use curve25519_dalek::scalar::Scalar;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub struct Value {
pub q: u64, // quantity
pub a: Scalar, // issuer
pub t: Scalar, // tag
}
/// Helper struct for ease of working with
/// 3-tuples of variables and assignments
#[derive(... |
use crate::types::*;
use neo4rs_macros::BoltStruct;
#[derive(Debug, PartialEq, Clone, BoltStruct)]
#[signature(0xB1, 0x11)]
pub struct Begin {
extra: BoltMap,
}
impl Begin {
pub fn new(extra: BoltMap) -> Begin {
Begin { extra }
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::version... |
#![deny(warnings)]
#[macro_use]
extern crate futures;
#[macro_use]
extern crate loom;
#[path = "../src/semaphore.rs"]
#[allow(warnings)]
mod semaphore;
use semaphore::*;
use futures::{future, Async, Future, Poll};
use loom::futures::block_on;
use loom::thread;
use std::sync::atomic::AtomicUsize;
use std::sync::ato... |
use sgx_types::{
sgx_status_t,
sgx_enclave_id_t,
};
extern {
pub fn run_sample(
eid: sgx_enclave_id_t,
retval: *mut sgx_status_t,
scratch_pad_pointer: *mut u8,
scratch_pad_size: *const u8,
) -> sgx_status_t;
}
|
struct Color {
red: u8,
green: u8,
blue: u8
}
fn main() {
let _a: Vec<i32> = Vec::new();
let mut b: Vec<i32> = vec![5, 4, 3, 2, 1, 0];
b.push(523);
println!("{:?}", b);
let mut e: Vec<i32> = Vec::with_capacity(10);
println!("length: {}, capacity: {}", e.len(), e.capacity());
for i in 0..10 {... |
#![feature(
plugin,
test,
const_slice_len,
never_type,
alloc_layout_extra,
try_from,
try_trait,
bind_by_move_pattern_guards,
fnbox,
copysign
)]
#![plugin(dynasm)]
extern crate test;
#[macro_use]
extern crate smallvec;
extern crate capstone;
extern crate either;
extern crate fail... |
use url::Url;
use vostok_core::request::Request;
#[derive(Debug)]
pub struct GeminiRequest {
url: Url,
}
impl Request for GeminiRequest {
fn path(&self) -> &str {
match self.url.path() {
"" => "/",
s => s,
}
}
}
impl GeminiRequest {
pub fn from_line(line: &str)... |
#[path = "spawn_3/with_atom_module.rs"]
mod with_atom_module;
// `without_atom_module_errors_badarg` in unit tests
|
#![cfg_attr(
all(not(debug_assertions), target_os = "windows"),
windows_subsystem = "windows"
)]
#[tauri::command]
fn say_hello(name: String) -> String {
let response = format!("Hello, {}!", name);
println!("{:?}", response);
response.into()
}
use tauri::Manager;
#[derive(Clone, serde::Serialize)]
str... |
// Copyright 2020-2021, The Tremor Team
//
// 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 agr... |
pub type IAction = *mut ::core::ffi::c_void;
pub type IActionCollection = *mut ::core::ffi::c_void;
pub type IBootTrigger = *mut ::core::ffi::c_void;
pub type IComHandlerAction = *mut ::core::ffi::c_void;
pub type IDailyTrigger = *mut ::core::ffi::c_void;
pub type IEmailAction = *mut ::core::ffi::c_void;
pub type IEnum... |
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use {
crate::common_operations::allowed_ops,
crate::target::{AvailableTargets, TargetOps},
clap::{App, Arg},
failure::Fail,
log::error,... |
use std::time::Instant;
use hardware::peripherals::time::Time;
pub struct SimulatedTime {
start: Instant,
}
impl SimulatedTime {
pub fn new() -> SimulatedTime {
SimulatedTime {
start: Instant::now(),
}
}
}
impl Time for SimulatedTime {
fn now(&self) -> u32{
let n... |
use crate::d6_39_id_generator::GenData;
// We always need generation data; e.g. a drop of an old generation of and object, must not drop it!
//
pub trait EcsStore<T> {
fn add(&mut self, g: GenData, t: T);
fn drop(&mut self, g: GenData);
fn get(&self, g: GenData) -> Option<&T>;
fn get_mut(&mut self, g: ... |
mod mock;
mod request;
mod responder;
mod response;
pub mod socks4;
pub use mock::Mock;
pub use request::Request;
pub use responder::Responder;
pub use response::Response;
/// Macro to define a mock endpoint using a more concise DSL.
#[macro_export]
macro_rules! mock {
(@response($response:expr) status: $status:... |
use map::{RoomNum, MAP};
use rand::{thread_rng, Rng};
use std::collections::HashSet;
use std::io;
use std::io::Write;
// Reads a line from stdin, trims it, and returns it as upper case.
pub fn read_sanitized_line() -> String {
read_line().trim().to_uppercase()
}
pub fn read_line() -> String {
let mut input = ... |
mod results;
pub use self::results::Results;
use self::results::*;
use super::Display;
use std::cmp::max;
use item::Equipment;
/// Combat state, ie. information retained between combat rounds.
pub struct Combat {
pub duration: i32,
pub results: Results,
}
pub trait Combatant: Display {
fn life(&self) ->... |
mod process;
use std::fs;
use std::io::Read;
use process::Process;
fn get_process_info(entry: &fs::DirEntry) -> Option<Process> {
let cmdfile = entry.path().join("cmdline");
let name = String::from(cmdfile.to_str().unwrap_or("no-name"));
if !cmdfile.exists() {
println!("Could not find cmdfile -... |
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use crate::switchboard::base::{SettingRequest, SettingRequestResponder, SettingType};
use failure::Error;
use futures::channel::mpsc::UnboundedSender;
pub... |
use super::*;
/// Win32 handle types implement this trait to simplify error handling.
/// # Safety
pub unsafe trait Handle: Sized + PartialEq {
fn is_invalid(&self) -> bool {
*self == unsafe { core::mem::zeroed() }
}
fn ok(self) -> Result<Self> {
if !self.is_invalid() {
Ok(self... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.