text stringlengths 3.09k 13.9k |
|---|
// Copyright 2018-present, the HuggingFace Inc. team
// Copyright 2018-present, The OpenAI Team Authors
// Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
// Copyright 2019 <NAME>
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the ... |
use std::cell::RefCell;
use std::rc::Rc;
use std::sync::mpsc;
use gtk::*;
use relm::{interval, Component, ContainerWidget, EventStream, Relm, Widget};
use relm_derive::{widget, Msg};
use super::card_view::{CardView, CardViewMsg};
use super::deck_view::{DeckView, DeckViewMsg};
use super::quiz::{QuizMsg, QuizView};
use... |
use crate::posit::Posit;
use std::fmt;
use std::cmp::{max, min};
#[derive(Clone, Copy, Default, PartialEq, Eq, Hash)]
pub struct Quire<const N: u8, const ES: u8>(pub u128);
impl<const N: u8, const ES: u8> Quire<N, ES> {
#[inline]
pub const fn new(i: u128) -> Self {
Self(i)
}
pub const SIGN_MA... |
/*
MIT License
Copyright (c) 2021 <NAME>
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, distrib... |
use num::Signed;
use std::{f32, f64};
use approx::{RelativeEq, UlpsEq};
use crate::scalar::ComplexField;
#[cfg(all(
any(target_arch = "nvptx", target_arch = "nvptx64"),
not(feature = "std"),
not(feature = "libm_force"),
feature = "cuda"
))]
use cuda_std::GpuFloat;
#[cfg(all(not(feature = "std"), not(... |
use crate::shared::{RemoteConnectionConfig, SealedKeyData, SgxInitRequest, SgxInitResponse};
use crate::state::StateSyncer;
use aesm_client::AesmClient;
use anomaly::format_err;
use enclave_runner::{
usercalls::{AsyncStream, UsercallExtension},
EnclaveBuilder,
};
use sgxs_loaders::isgx::Device;
use std::os::uni... |
use advent_lib::cases::{GenericPuzzleCase, PuzzleCase, PuzzleRunner};
use indoc::indoc;
use std::collections::HashMap;
use std::fmt;
use std::str::FromStr;
#[derive(Debug)]
pub struct Part2;
impl PuzzleRunner for Part2 {
type Input = (&'static str, usize);
type Output = usize;
fn name(&self) -> String {
... |
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GtwEvent {
///GtwEventType,事件类型
#[prost(int32, required, tag="1")]
pub event_type: i32,
///事件描述
#[prost(string, required, tag="2")]
pub desc: ::prost::alloc::string::String,
}
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Progra... |
use std::borrow::BorrowMut;
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
use std::str::SplitWhitespace;
use std::sync::Arc;
use crate::hittables::hittable::Hittable;
use crate::hittables::triangle::Triangle;
use crate::material::Material;
use crate::textures... |
use crate::engine::position::{MapPosition, SizeInTiles};
use itertools::Itertools;
use log::*;
use std::cmp::min;
#[derive(Default, Debug, Clone, Copy)]
pub struct ZonePosition {
pub x: i32,
pub y: i32,
}
impl ZonePosition {
pub fn new(x: i32, y: i32) -> Self {
ZonePosition { x, y }
}
pub... |
use std::sync::mpsc::{Receiver, Sender};
use std::sync::{mpsc, Arc, Mutex};
use std::thread;
use threadpool::ThreadPool;
/// Calculates the largest prime number in the provided tuple.
/// The first tuple parameter must be greater than the second tuple parameter.
/// If both of the parameters are equal, the primality o... |
use std::cell::{RefCell};
use std::task::{Context, Poll, Waker};
use std::rc::{Rc};
use crate::lattice::LatticeRepr;
use crate::lattice::pair::PairRepr;
use crate::hide::{Hide, Qualifier, Delta, Value};
use super::*;
mod private {
use super::*;
pub struct SwitchOpState<R: LatticeRepr> {
pub(super) w... |
use std::cell::RefCell;
use std::fmt;
use std::rc::{Rc, Weak};
use indexmap::IndexMap;
use som_core::ast::{ClassDef, MethodBody};
use crate::method::{Method, MethodKind};
use crate::value::Value;
use crate::{SOMRef, SOMWeakRef};
/// A reference that may be either weak or owned/strong.
#[derive(Debug, Clone)]
pub en... |
mod mounts;
use std::collections::HashSet;
use std::ffi::CString;
use std::hash::{Hash, Hasher};
use std::io::{self, ErrorKind};
use std::mem;
use std::thread::sleep;
use std::time::Duration;
use crate::scanner_rust::{Scanner, ScannerError};
const DISKSTATS_PATH: &str = "/proc/diskstats";
const SECTOR_SIZE: u64 = 5... |
use std::fmt;
use std::fs;
use std::io::{self, Write};
use std::path::{Component, Path, MAIN_SEPARATOR};
use std::process;
use std::result;
use derive_more::{Error, From};
use structopt::clap::crate_name;
use structopt::StructOpt;
use crate::cli::Args;
use crate::rename;
#[inline]
fn pluralize(value: usize) -> &'sta... |
use curve25519_dalek::ristretto::RistrettoPoint;
use curve25519_dalek::scalar::Scalar;
use rand_os::OsRng;
use core::ops::{Add, Mul, Sub};
fn base_coeficient<F>(size: usize, i: usize, xi: u32, get_xj: F) -> Scalar
where F: Fn(usize) -> u32 {
let sxi = Scalar::from(xi);
let mut num = Scalar::one();
... |
//! Structs which allow the Conductor's state to be persisted across
//! startups and shutdowns
use holochain_conductor_api::signal_subscription::SignalSubscription;
use holochain_conductor_api::{config::InterfaceDriver, InstalledAppInfo};
use holochain_types::prelude::*;
use serde::Deserialize;
use serde::Serialize;
... |
extern crate bincode;
extern crate proto;
extern crate mio;
extern crate rusqlite;
mod db;
use std::io;
use std::io::Read;
use std::time::Duration;
use std::thread;
use std::sync::mpsc;
use std::collections::HashMap;
use mio::net::{TcpListener, TcpStream};
use mio::{Poll, Token, Ready, PollOpt, Events};
const LISTE... |
use anyhow::Result;
use border::try_from;
use border_core::{record::TensorboardRecorder, shape, Agent, Shape, TrainerBuilder};
use border_py_gym_env::{
newtype_act_c, newtype_obs, PyGymEnvContinuousAct, PyVecGymEnv, PyVecGymEnvBuilder,
};
use border_tch_agent::{
replay_buffer::TchTensorBuffer,
sac::{EntCoef... |
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under both the MIT license found in the
* LICENSE-MIT file in the root directory of this source tree and the Apache
* License, Version 2.0 found in the LICENSE-APACHE file in the root directory
* of this source tree.
*/
//! P... |
/*
* Copyright 2019, <NAME>
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
//! The error module implements all AMQP 1.0 error types that is supported by dove. Conversion from many different error types are supported.
use crate::message::Message;
use crate::s... |
use hyper::service::{make_service_fn, service_fn};
use hyper::{
body::to_bytes, client::HttpConnector, Body, Client, Method, Request, Response, Server,
StatusCode,
};
use hyper_tls::HttpsConnector;
use serde_derive::{Deserialize, Serialize};
use serde_json::from_slice;
#[cfg(test)]
use mockito;
#[cfg(not(test... |
use std::cmp;
use std::collections::HashSet;
use parser::{
BaseType, EnumerationType, File, FileHash, Function, StructType, Type, TypeDef, TypeKind,
TypeOffset, UnionType, Unit, UnspecifiedType, Variable,
};
use crate::Options;
pub(crate) fn filter_units<'input, 'file>(
file: &'file File<'input>,
opt... |
use std::char;
use std::collections::HashMap;
use std::fmt::Write;
use std::iter::once;
use fancy_regex::Regex as FancyRegex;
use itertools::Itertools;
use lazy_static::lazy_static;
use crate::utils::{
direction::{Direction, Rotation},
intcode::CPU,
Vec2,
};
enum Tile {
Wall,
Robot(Direction),
}
... |
use std::io::{self, Read, Write, Seek, SeekFrom};
use std::fs::{self, File};
use std::path::{Path, PathBuf};
use std::ops::{Deref, DerefMut};
use std::error;
use std::fmt;
use std::env;
use std;
use super::imp;
use super::util;
/// A named temporary file.
///
/// This variant is *NOT* secure/reliable in the presence... |
// This mod is used to init a db version when the db version is absent at the first time.
// And check present db version is still compatible. Godwoken must run on a valid db.
// If godwoken with an advanced verion runs on an old db, this is the time we can run migrations.
use crate::{
error::Error,
read_only_d... |
//! Watch-related APIs
use std::{pin::Pin, time::Duration};
use crate::{
model::{Query, Revision, WatchFileResult, WatchRepoResult, Watchable},
services::{path, status_unwrap},
Client, Error, RepoClient,
};
use futures::{Stream, StreamExt};
use reqwest::{Method, Request, StatusCode};
const DEFAULT_TIMEOU... |
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Color {
pub red: f32,
pub green: f32,
pub blue: f32,
pub alpha: f32,
}
impl Color {
pub const WHITE: Self = Self::new(1.0, 1.0, 1.0, 1.0);
pub const BLACK: Self = Self::new(0.0, 0.0, 0.0, 1.0);
pub const TRANSPARENT_WHITE: Self = Self::ne... |
//! Pure Rust platform independent implementation designed for speed.
use core::mem;
use crate::char::{KernelFn, Wide};
mod packed;
use self::packed::{simd_eq, NonZeroPacked, Pack, Packed};
/// Returns the index of the first occurrence of a wide character in a slice,
/// or [`None`] if the character is not found.
... |
use nom::multi::count;
use nom::Err as NomErr;
use nom::IResult;
use nom::bytes::complete::tag;
use nom::error::ErrorKind;
use nom::combinator::map_res;
use nom::number::complete::{be_u16, be_u32};
use std::convert::TryFrom;
use types::Offset32;
/// The purpose of the TTC Header table is to locate the different Offset... |
use anyhow::Result;
use smithay::{
backend::{
renderer::{Frame, Renderer},
winit,
},
reexports::wayland_server::Display,
utils::{Rectangle, Transform},
wayland::{
seat::{FilterResult, ModifiersState, Seat, XkbConfig},
SERIAL_COUNTER,
},
};
use smithay_egui::EguiSt... |
/*
author: <NAME>
email: <EMAIL>
purpose: given a multi-sequence alignment, calculate the Tajima's D statistic in a sliding window.
arguments: input FASTA, output CSV, window size, window step size
*/
/****
TODOS
*****/
//practice using rust wrapper with python https://developers.redhat.com/blog/2017/11/16/speed-pyth... |
use std::collections::HashMap;
use std::pin::Pin;
use std::sync::{Arc, Weak};
use std::time::{Duration, Instant};
use futures::task::{Context, Poll};
use futures::{FutureExt, Stream, StreamExt};
use tokio_stream::wrappers::BroadcastStream;
use nimiq_block::Block;
use nimiq_hash::Blake2bHash;
use nimiq_network_interfa... |
use crate::config::Config;
use crate::CARGO_PKG_VERSION;
use fern::colors::{Color, ColoredLevelConfig};
use fern::Dispatch;
use log::{Level, Log, Metadata, Record};
use pagerduty_rs::eventsv2async::EventsV2;
use pagerduty_rs::types::{
AlertTrigger, AlertTriggerPayload, Change, ChangePayload, Event, Severity,
};
use... |
use super::Storage;
use crate::models;
use crate::result::{Error, Result};
use async_trait::async_trait;
use sqlx::migrate::Migrator;
use sqlx::postgres::PgPool;
use std::time::Duration;
pub type Pool = PgPool;
#[derive(Clone)]
pub struct PgStorage {
pool: Pool,
}
impl PgStorage {
pub fn new(pool: Pool) -> S... |
use git2::{Repository, Status};
use std::env;
use std::path::Path;
use tico::tico;
pub use ansi_term::Color;
use ansi_term::Color::{Blue, Cyan, Green, Red, Yellow, RGB};
mod themes;
pub use themes::Theme;
pub struct Prompt {
pub cwd_color: Color,
pub git_branch_color: Color,
pub git_status_clean_color: C... |
use embedded_hal::timer::{CountDown, Periodic};
use stm32f0xx_hal::rcc::{Clocks, Rcc};
use stm32f0xx_hal::time::Hertz;
use void::Void;
pub trait Updatable {
type Time;
fn update<T: Into<Self::Time>>(&mut self, timeout: T);
}
/// Interrupt events
pub enum Event {
/// Timer timed out / count down ended
... |
use cosmwasm_std::testing::{MockApi, MockQuerier, MockStorage, MOCK_CONTRACT_ADDR};
use cosmwasm_std::{
from_binary, from_slice, to_binary, Addr, Coin, ContractResult, Decimal, OwnedDeps, Querier,
QuerierResult, QueryRequest, SystemError, SystemResult, Uint128, WasmQuery,
};
use cosmwasm_storage::to_length_pref... |
/*
* MIT License
*
* Copyright (c) 2019 <NAME>
*
* 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, m... |
use nannou::prelude::*;
use core::time::Duration;
use nannou::color::Alpha;
use enum_iterator::IntoEnumIterator;
const NUMBER_OF_SQUARE: usize = 10;
const SQUARE_SIZE: f32 = 100.0;
const WINDOW_SIZE: f32 = SQUARE_SIZE * NUMBER_OF_SQUARE as f32;
const COLOR_DELTA: f32 = 0.0;
const COLOR_NUMBER: usize = 12;
const BACKGR... |
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0
use move_binary_format::{
access::ModuleAccess,
binary_views::BinaryIndexedView,
file_format::{AbilitySet, FunctionDefinition, SignatureToken, Visibility},
CompiledModule,
};
use move_core_types::{ident_str, identifier::Ide... |
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may... |
//! Tests that rely on interleaving two method calls on the governance canister
//! (in particular, when one method is suspended when it calls out to the ledger
//! canister).
use futures::channel::mpsc;
use futures::future::FutureExt;
use futures::StreamExt;
use std::pin::Pin;
use std::sync::atomic;
use std::sync::ato... |
/*
* scaledjobs.keda.sh
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1
*
* Generated by: https://openapi-generator.tech
*/
/// ScaledJobJobTargetRefTemplateSpecVolumes : Volume represents a named volume ... |
/// Contains the available backing traits for persisting Scheduled Jobs.
pub mod backing;
use crate::store::backing::Backing;
use crate::ScheduledJob;
use ahash::RandomState;
use backing::Error as BackingError;
use chrono::Utc;
use cron::error::Error as CronError;
use cron::Schedule;
use metrics::increment_counter;
us... |
//! 缓存实现
//!
//! 目前的实现暂时是对整个缓冲层加锁,但不会在拿锁和解锁之间读写块设备
//! 执行 `put` 方法的时候,当有数据需要写回的时候,返回 Some<(Key, Value)>,否则返回 None
//!
//! todo: 这里涉及到一个体系结构领域很经典的问题:缓存一致性,后面考虑对这部分实现进行优化,实现高性能的缓存一致性模型
use alloc::vec::Vec;
/// 各种缓存替换算法需要实现的 trait
///
/// N: 缓存项的数量
pub trait Cache<const N: usize> {
type Key;
type Value;
/// ... |
use crate::result::Result;
use anyhow::ensure;
use byteorder::{BigEndian, ReadBytesExt};
use downloader::{Download, Downloader};
use flate2::read::GzDecoder;
use http::StatusCode;
use ndarray::{ArcArray, ArcArray1, Ix4};
use std::{
fs::{self, File},
path::Path,
};
/// The kind of Mnist.
#[derive(Clone, Copy, D... |
use ctrlc;
use sdl2;
use sdl2::{GameControllerSubsystem, JoystickSubsystem};
use std::cmp::min;
use std::sync::Arc;
use std::sync::mpsc::channel;
use std::sync::atomic::{AtomicBool, Ordering};
use timer::Timer;
use chrono::Duration;
use process_memory::Memory;
mod error;
mod pico8_connection;
mod constants;
mod gamepa... |
//! Executor module
use crate::deterministic::runtime::reactor::DeterministicReactor;
use crate::deterministic::runtime::task::{Task, TaskId};
use crossbeam_queue::ArrayQueue;
use std::collections::BTreeMap;
use std::sync::Arc;
use std::task::{Context, Poll, Wake, Waker};
/// A deterministic, single-threaded executor... |
use std::fmt::Display;
use super::{
error::{ParseError, TakeError},
position::LineCol,
};
pub trait Parser {
fn next(&mut self) -> Option<char>;
fn peek(&mut self) -> Option<char>;
fn pos(&self) -> LineCol;
fn take<P: Parse>(&mut self) -> Result<P, TakeError> {
P::take(self)
}
... |
//! Provides the Text Component and relevant types for using it. The Text
//! Component simply visualizes any given text. This can either be a single
//! centered text, or split up into a left and right text, which is suitable for
//! a situation where you have a label and a value.
use std::io::Write;
use serde_json::... |
use {Backend, QueueFamily};
use {native, conversions};
use device::PhysicalDevice;
use std::cell::RefCell;
use std::rc::Rc;
use hal::{self, format, image};
use hal::{Backbuffer, CommandQueue, SwapchainConfig};
use hal::format::{ChannelType, SurfaceType};
use hal::window::Extent2d;
use metal::{self, MTLPixelFormat, M... |
use bevy::prelude::*;
use bevy_advanced_input::{
input_id::InputID,
plugin::InputBindingPlugin,
user_input::{InputAxisType, MouseAxisType, UserInputHandle, UserInputSet},
};
#[derive(PartialEq, Eq, Hash, Clone, Copy)] //* Step 1: create input states for your game
enum InputType {
Editor,
MainMenu,... |
#[macro_use]
extern crate three_em;
use std::cell::Cell;
use three_em::runtime::smartweave::ContractInfo;
use criterion::black_box;
use criterion::criterion_group;
use criterion::criterion_main;
use criterion::Criterion;
use deno_core::serde_json;
use deno_core::serde_json::json;
use std::time::Duration;
use three_em... |
use crate::parser::Parser;
use crate::parser::*;
use bytes::buf::BufMutExt;
use bytes::{Buf, BytesMut};
use std::collections::HashMap;
use std::sync::Arc;
use tokio::io::*;
use tokio::net::TcpStream;
use tokio::sync::{oneshot, Mutex};
type MessageHandler = Box<dyn FnMut(&[u8]) -> std::result::Result<(), ()> + Sync + S... |
extern crate serde_json;
extern crate voronator;
use std::f64;
use std::fs::File;
use voronator::delaunator::*;
use voronator::VoronoiDiagram;
#[test]
fn basic() {
let points = load_fixture("tests/fixtures/ukraine.json");
validate(&points);
}
#[test]
fn square() {
let points: Vec<Point> = vec![(0., 0.), ... |
///! This module provides tools for constructing boolean expressions using
///! NIDs as logical operations.
use {nid::NID, vid::VID};
use std::slice::Iter;
///! A sequence of operations.
///! Currently, RPN is the only format, but I made this an enum
///! to provide a little future-proofing.
#[derive(Serialize, Deseri... |
use std::{env, fs::File, process::exit, sync::Mutex};
//use libc;
use lazy_static::lazy_static;
use regex::Regex;
use rustyline::{
completion::FilenameCompleter, error::ReadlineError, highlight::MatchingBracketHighlighter, hint::HistoryHinter,
validate::MatchingBracketValidator, Config, Editor,
};
use colore... |
use crate::error::ApiError;
use num_traits::cast::ToPrimitive;
use serde::{Deserialize, Serialize};
use sqlx;
use sqlx::postgres::PgPool;
use std::convert::TryFrom;
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FermentableId {
pub id: i32,
}
#[derive(Debug, Deserialize)]
#[serde(rena... |
use crate::Connection;
use bytes::BytesMut;
use dytp_protocol::delim::Delim;
use failure::Error;
use futures::try_ready;
use std::io::Write;
use std::net::{TcpStream, ToSocketAddrs};
use std::time::{Duration, Instant};
use tokio::prelude::*;
type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub struct ... |
use std::{ fmt, ops };
use std::vec::Vec;
use std::collections::HashMap;
use std::borrow::Borrow;
use std::io::Write;
use num;
use mio::*;
use utils::*;
#[allow(dead_code)]
pub const OPCODE_CONTINUATION: u8 = 0x0;
#[allow(dead_code)]
pub const OPCODE_TEXT: u8 = 0x1;
#[allow(dead_code)]
pub const OPCODE_BINARY: u8 = ... |
// Functions for putting stuff into the correct places on the sdl buffer
use crate::panels::RenderPanel;
use crate::splits::Split;
use sdl2::pixels::Color;
use sdl2::rect::{Point, Rect};
use sdl2::render::{Canvas, Texture, TextureQuery};
use sdl2::video::Window;
use std::convert::TryInto;
// Puts split name textures a... |
#![recursion_limit = "2048"]
#[macro_use]
extern crate stdweb;
extern crate yarsge_core;
use std::cell::RefCell;
use std::rc::Rc;
use stdweb::{
traits::*,
unstable::TryInto,
web::{
self,
event::{ChangeEvent, ProgressLoadEvent},
html_element::InputElement,
Element, FileLis... |
use std::{io::Write, process::Command};
use anyhow::{anyhow, bail, Context, Result};
use libcryptsetup_rs::CryptDevice;
use secrecy::{ExposeSecret, Secret};
fn get_clevis_token(dev: &mut CryptDevice) -> Result<u32> {
let mut clevis_token = None;
let mut handle = dev.token_handle();
for i in 0..10 {
... |
/// A library to measure the wall-clock time of Rust expressions.
mod error;
// TODO: If / When possible, replace this with derived De/Serialize impls.
#[cfg(feature = "enable_serde")] mod serialize;
pub use error::{MeasureErr, MeasureResult};
pub use chrono::{Duration, Utc};
use std::fmt;
use std::ops;
const NS_P... |
use ark_ff::BigInteger;
use ark_std::{format, vec::Vec};
use crate::{Error, Field};
use super::{Composer, Variable};
impl<F: Field> Composer<F> {
/// here we enforce range constraint by quads (2-bit unit), so `num_bits` must be even.
/// The quads are orgnized in the big-endian order
pub fn enforce_range... |
// Copyright 2020 The Vega 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 agreed to in ... |
use std::fs;
use std::io;
use std::io::{Error, ErrorKind, Write};
use std::path::Path;
use clap::{crate_authors, crate_description, crate_name, crate_version, Arg, App};
use flexi_logger::{Duplicate,Logger};
use log::info;
trait Command {
fn execute(&self) -> Result<(), Error>;
fn can_be_undo(&self) -> bool;... |
#[macro_use] extern crate log;
extern crate sdl2;
extern crate gl_core_struct as gl;
extern crate window;
extern crate window_gl;
extern crate resources;
extern crate input;
extern crate input_sdl;
use sdl2::{video, Sdl};
use gl::{Glw, Gl};
use std::{mem, str};
use std::ffi;
use std::os::raw::c_char;
use resources::Re... |
/*
* Copyright 2021 Fluence Labs Limited
*
* 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 a... |
use std::convert::{
TryFrom,
TryInto,
};
use graphql_parser::schema::{
Field,
Type,
};
use crate::{
as_static_python::AsStaticPython,
conflict_resolution::ConflictResolution,
errors::CodeGenError,
identity_predicate_type::IdentityPredicateType,
predicate_type::PredicateType,
};
//... |
use bytes::Buf;
use uuid::Uuid;
use crate::errors::*;
use error_chain::{bail, ensure};
pub trait PacketBufferRead {
/// Reads an [`i8`] from the underlying buffer.
fn read_i8(&mut self) -> Result<i8>;
/// Reads an [`u8`] from the underlying buffer.
fn read_u8(&mut self) -> Result<u8>;
/// Reads ... |
//! Utilities for working with Protobuf paths.
use std::collections::HashMap;
use std::iter;
/// Maps a fully-qualified Protobuf path to a value using path matchers.
#[derive(Debug, Default)]
pub(crate) struct PathMap<T> {
matchers: HashMap<String, T>,
}
impl<T> PathMap<T> {
/// Inserts a new matcher and ass... |
//! Sequence decoder
use super::{
vint64::{self, zigzag},
Decodable, Event,
};
use crate::{error::Error, field::WireType, message::Element};
/// Sequence decoder
pub struct Decoder {
/// Wire type contained in this sequence
wire_type: WireType,
/// Total length of the sequence
length: usize,
... |
use std::collections::{HashMap, HashSet};
pub fn gcd(mut a: i64, mut b: i64) -> i64 {
while b != 0 {
let tmp = a;
a = b;
b = tmp % b;
}
a
}
pub fn parse_points(input_string: &str) -> Vec<(usize, usize)> {
input_string
.lines()
.enumerate()
.flat_map(|(ro... |
// Copyright 2019 Google LLC
//
// 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 in ... |
use self::traits::*;
use super::*;
type MonitorReceiver = crossbeam::channel::Receiver<MonitorMessage>;
// The factory for creating the system monitor.
pub struct SystemMonitorFactory {
sender: MonitorSender,
receiver: MonitorReceiver,
}
impl SystemMonitorFactory {
#[allow(clippy::new_ret_no_self)]
pu... |
//! Items mainly locked by Morytania.
use super::ExprMap;
use crate::{
bool_expr::{BoolExpr, BoolExprBuilder},
vars::Region,
};
fn expr() -> BoolExpr<Region> {
BoolExpr::new(Region::Morytania)
}
/// Add requirements for the following items:
/// - [Barrows equipment](https://oldschool.runescape.wiki/w/Bar... |
use alloc::borrow::ToOwned;
use alloc::string::String;
bitflags::bitflags! {
pub struct FlagsECX: u32 {
const SSE3 = 1 << 0;
const PCLMUL = 1 << 1;
const DTES64 = 1 << 2;
const MONITOR = 1 << 3;
const DS_CPL = 1 << 4;
const VMX ... |
//! Prints "Hello, World" in the OpenOCD console
//#![deny(unsafe_code)]
//#![deny(warnings)]
#![feature(unsize)]
#![feature(const_unsafe_cell_new)]
#![feature(const_fn)]
#![feature(proc_macro)]
#![no_std]
extern crate bsp;
extern crate cortex_m_rtfm as rtfm;
extern crate cortex_m_semihosting as semihosting;
extern cr... |
/*
Copyright 2020 Adobe
All Rights Reserved.
NOTICE: Adobe permits you to use, modify, and distribute this file in
accordance with the terms of the Adobe license agreement accompanying
it.
*/
pub mod plain;
pub mod secure;
use crate::cache::Cache;
use crate::cops::{agent, BadRequest, Request as CRequest, Response as ... |
use crate::config;
use printpdf::{Mm, Pt, Px};
impl From<config::Color> for printpdf::Color {
fn from(c: config::Color) -> Self {
printpdf::Color::Rgb(printpdf::Rgb {
r: c.r,
g: c.g,
b: c.b,
icc_profile: None,
})
}
}
/// gets the index of a certa... |
#![allow(clippy::vec_init_then_push)]
mod data_types;
mod greetings;
mod guessing_game;
mod math;
mod my_macros;
mod story;
mod vehicles;
use byteorder::{BigEndian, ReadBytesExt};
use greetings::english::greet;
use math::*;
use std::io;
use std::{thread, time};
use story::read_story;
use tokio::sync::oneshot;
use veh... |
extern crate regex;
use regex::Regex;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
use std::process::exit;
use structopt::StructOpt;
#[derive(StructOpt)]
struct Cli {
#[structopt(parse(from_os_str))]
path: std::path::PathBuf,
}
// This function reads the lines from a file into a v... |
use proc_macro2::TokenStream;
use quote::ToTokens;
use syn::{
punctuated::Punctuated,
token::Or,
visit_mut::{self, VisitMut},
*,
};
use crate::utils::{proj_ident, VecExt};
/// The attribute name.
const NAME: &str = "project";
pub(super) fn attribute(input: TokenStream) -> TokenStream {
parse(inpu... |
// disable some warnings for debug build
#![cfg_attr(debug_assertions, allow(dead_code, unused_imports, unused_mut, unused_variables, unreachable_code))]
use std::io::{BufReader, Read};
use std::io::BufRead;
use std::str::FromStr;
use std::io::Write;
use std::thread;
use std::env;
extern crate chrono;
#[macro_use]
ex... |
//! Adapters for connecting structured log records from the [slog] crate into the [tracing](https://github.com/tokio-rs/tracing) ecosystem.
//!
//! Use when a library uses `slog` but your application uses `tracing`.
//!
//! Heavily inspired by [tracing-log](https://github.com/tokio-rs/tracing/tree/5fdbcbf61da27ec3e6006... |
use std::fs::{self, File};
use std::io::Read;
use std::path::Path;
use anyhow::{anyhow, bail, Context, Result};
use base64::{decode, encode};
const FILE_SIZE_LIMIT: usize = 128 * 1024;
pub struct ConcreteFilesystem {}
impl ConcreteFilesystem {
pub fn new() -> Self {
Self {}
}
}
impl Default for Con... |
mod arq;
mod buffer;
mod history;
mod time;
use std::{
ops::RangeInclusive,
time::{Duration, Instant},
};
use arq::AutomaticRepeatRequestAlgorithm;
use crate::{
connection::ConnectionSettings,
packet::*,
protocol::{
encryption::{Decryption, DecryptionError},
output::Output,
... |
//! An implementation of the Sobol low discrepancy sequence.
use super::hash_u32;
use super::hash_gen::{exec_hash_slice, HashOp};
// The following `include` provides `MAX_DIMENSION` and `VECTORS`.
// See the build.rs file for how this included file is generated.
include!(concat!(env!("OUT_DIR"), "/vectors.inc"));
/... |
//! This example demonstrates using the raw Rust wrappers around the LibraryLink C API to
//! write a function which looks much like a classic C function using LibraryLink and
//! WSTP would.
//!
//! This also includes an example of mixing the low-level LibraryLink bindings with the
//! higher-level bindings provided b... |
use std::{
borrow::Borrow,
cell::RefCell,
mem::MaybeUninit,
};
//#[cfg(not(feature = "gl"))]
use gfx_hal::adapter::DeviceType;
use gfx_hal::{
adapter::{
Adapter,
PhysicalDevice,
},
command::{
Primary,
Submittable,
},
pso::PipelineStage,
Device,
Graphics,
Instance,
QueueFamily,
QueueGroup,
Submiss... |
use super::{object, Error, FileTags, Object, ObjectType, Result};
use crate::bytecode::Instruction;
use byteorder::{LittleEndian, ReadBytesExt};
use num_traits::{FromPrimitive, ToPrimitive};
use std::io::Read;
use std::rc::Rc;
fn read_string(rdr: &mut dyn Read) -> Result<Object> {
let len = rdr.read_u64::<LittleE... |
use termion::raw::IntoRawMode;
use termion::async_stdin;
use termion::terminal_size;
use termion::color;
use std::io::{Read, Write, stdout};
use std::thread;
use std::time::Duration;
use std::fs::File;
use std::io::{BufRead, BufReader};
use clap::{Arg, App};
use unicode_segmentation::UnicodeSegmentation;
pub struct Wo... |
use crate::values::*;
use heck::SnakeCase;
use lucet_idl::{
pretty_writer::PrettyWriter, BindingDirection, Function, Module, RustFunc, RustName,
RustTypeName,
};
use proptest::prelude::*;
#[derive(Debug, Clone)]
pub struct FuncCallPredicate {
func_name: String,
func_call_args: Vec<String>,
func_cal... |
//! Attributes-related helpers.
use syn::{spanned::Spanned, Expr, Lit, Meta, NestedMeta, Path, Type};
/// Extension for `syn::Meta` type.
pub trait MetaExt {
/// Returns `true` if the meta has the repr `C` or `transparent`.
fn has_unsized_repr(&self) -> bool;
/// Returns `true` if the meta has the word at... |
extern crate bincode;
#[macro_use]
extern crate log;
extern crate serde;
#[macro_use]
extern crate serde_derive;
extern crate simple_logger;
#[macro_use]
extern crate solana_sdk;
mod dashboard;
mod game;
mod logger;
mod program_command;
mod program_state;
mod result;
mod simple_serde;
use program_command::Command;
us... |
extern crate proc_macro;
use std::collections::HashMap;
use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::{quote, quote_spanned};
use syn::spanned::Spanned;
use syn::{parse_macro_input, parse_quote, Data, DeriveInput, Field, Fields, GenericArgument, Ident, Lit, LitStr, Meta, NestedMeta, PathArguments, Ty... |
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::str::FromStr;
use std::sync::Arc;
use std::task::{Poll, Context};
use std::time::Duration;
use async_std::task;
use db::rocks::RocksDB;
use libp2p::identity::Keypair;
use std::io::{Cursor};
use libp2p::{PeerId};
use libp2p::gossipsu... |
use std::collections::HashSet;
#[derive(Debug, PartialEq)]
pub struct LanguageChunk(pub usize, pub String);
//Alphabets cheme is a vec consisting of triplets of u32s, where first value is unicode range start, the second unicode range end, and the thirdone id of the alphabet for which the range is defined. These tripl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.