text stringlengths 8 4.13M |
|---|
fn extract_value<'a>(a: &'a liquid::value::Value, key: &str) -> Option<&'a liquid::value::Value> {
let key = liquid::value::Scalar::new(key.to_owned());
a.get(&key)
}
pub fn extract_scalar<'a>(
a: &'a liquid::value::Value,
key: &str,
) -> Option<&'a liquid::value::Scalar> {
extract_value(a, key).an... |
use crate::debruijn::{DbCtx, Idx, Shift};
use crate::prop::Prop;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Proof {
pub prop: Prop,
pub kind: ProofKind,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ProofKind {
/// variable in de Bruijn index
Var(Idx),
/// `\x => t`
Abs(Box<Proof>),... |
use mysql::from_row;
use mysql::error::Error::MySqlError;
use serde_json::Value;
use common::utils::*;
use common::lazy_static::{SQL_POOL, RECORDS_COUNT_PER_PAGE};
pub fn create_message(message: &Value) -> Option<String> {
let create_time = gen_datetime().to_string();
let comment_id = message["comment_id"].a... |
//! BookCrossing data extraction.
//!
//! The BookCrossing CSV files are corrupt, so this command extracts them and fixes
//! up the character sets to make them well-formed CSV.
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
use zip::ZipArchive;
use crate::prelude::*;
#[derive(Args, Debug)]
pub struc... |
use super::log::{self, Log, LogLevel, LogMetadata, LogRecord, SetLoggerError};
struct Logger {
log_level: LogLevel,
}
impl Log for Logger {
fn enabled(&self, metadata: &LogMetadata) -> bool {
metadata.level() <= self.log_level
}
fn log(&self, record: &LogRecord) {
if self.enabled(rec... |
use std::io::BufReader;
use std::io::Read;
use quick_xml::Reader;
use quick_xml::events::Event;
pub fn parse<R: Read>(buf: BufReader<R>) {
let mut parser = Reader::from_reader(buf);
let mut event_buf = Vec::new();
loop {
match parser.read_event(&mut event_buf) {
Ok(Event::Start(ref e)) ... |
use std::collections::{HashMap, HashSet};
use std::fmt;
use std::str::FromStr;
use proc_macro2::{Span, TokenStream};
use quote::quote;
// TODO: support recursive glob like `/admin/sidekiq/{path*}`
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct PathPattern {
components: Vec<ComponentMatcher>,
binding... |
use azure_core::AddAsHeader;
use http::request::Builder;
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct ConditionAppendPosition(u64);
impl ConditionAppendPosition {
pub fn new(max_size: u64) -> Self {
Self(max_size)
}
}
impl From<u64> for ConditionAppendPosition {
fn fro... |
fn main() {
println!("Hello, world!");
another_function();
second_function(5);
third_function(5, 6);
let y = {
let x = 3;
x + 1
};
println!("{}", y);
let x = fourth_function();
println!("{}", x);
let z = plus_one(5);
println!("{}", z);
}
fn another_fun... |
use io::RegEnum;
const SDMMC_BASE: u32 = 0x10006000;
#[derive(Clone, Copy)]
#[allow(non_camel_case_types)]
#[allow(dead_code)]
enum Reg {
CMD = 0x00,
PORTSEL = 0x02,
CMDARG0 = 0x04,
CMDARG1 = 0x06,
STOP = 0x08,
BLKCOUNT = 0x0A,
RESP0 = 0x0C,
RESP1 = 0x0E,
RESP2 = 0x10,
RESP3 =... |
use super::Context;
use crate::db::paginate_dsl::{PaginateDsl, Pagination};
use crate::models;
use chrono::prelude::*;
use diesel::prelude::*;
use juniper::{graphql_object, FieldResult};
#[allow(clippy::module_name_repetitions)]
pub struct RootQuery;
#[graphql_object(context = Context)]
impl RootQuery {
fn apiVer... |
use maud::{html, Markup, Render};
pub struct LinkButton {
inner: Markup,
href: String,
button_type: ButtonType,
additional_classes: Option<String>,
}
impl LinkButton {
pub fn primary(inner: Markup, href: impl Into<String>) -> Self {
Self {
inner,
href: href.into(),
... |
use elements::Txid;
use futures::lock::Mutex;
use serde::{Deserialize, Serialize};
use crate::{
storage::Storage,
wallet::{current, sign_loan::update_open_loans, LoanDetails},
Error, Wallet,
};
use baru::loan::Borrower1;
/// Represents a backup-able loan
#[derive(Clone, Deserialize, Serialize, Debug)]
pub... |
//! Useful serialization and deserialization functions.
use std::fmt::{self, Formatter};
use std::time::{Duration, Instant};
use chrono::NaiveDate;
use serde::de::{self, Deserializer, Unexpected, Visitor};
use serde::Deserialize;
pub(crate) fn deserialize_instant_seconds<'de, D>(deserializer: D) -> Result<Instant, D... |
#[doc = "Register `HTCR` reader"]
pub type R = crate::R<HTCR_SPEC>;
#[doc = "Register `HTCR` writer"]
pub type W = crate::W<HTCR_SPEC>;
#[doc = "Field `HTCFG` reader - health test configuration"]
pub type HTCFG_R = crate::FieldReader<u32>;
#[doc = "Field `HTCFG` writer - health test configuration"]
pub type HTCFG_W<'a,... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::{models, API_VERSION};
#[non_exhaustive]
#[derive(Debug, thiserror :: Error)]
#[allow(non_camel_case_types)]
pub enum Error {
#[error(transparent)]
PolicyTrackedResources_ListQueryResul... |
#[doc = "Reader of register CLOCK_CTL"]
pub type R = crate::R<u32, super::CLOCK_CTL>;
#[doc = "Writer for register CLOCK_CTL"]
pub type W = crate::W<u32, super::CLOCK_CTL>;
#[doc = "Register CLOCK_CTL `reset()`'s with value 0"]
impl crate::ResetValue for super::CLOCK_CTL {
type Type = u32;
#[inline(always)]
... |
#![allow(non_snake_case)]
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate log;
extern crate ndarray;
#[macro_use]
extern crate proptest;
extern crate protobuf;
extern crate simplelog;
extern crate tensorflow;
extern crate tfdeploy;
error_chain! {
foreign_links {
Io(::std::io::Error);
... |
#![feature(lang_items)]
#![feature(panic_implementation)]
#![feature(const_fn)]
#![feature(ptr_internals)]
#![feature(repr_transparent)]
#![feature(duration_extras)]
#![feature(asm)]
#![feature(integer_atomics)]
#![feature(alloc)]
#![feature(naked_functions)]
#![feature(allocator_internals)]
#![feature(allocator_api)]
... |
use thiserror::Error;
/// An error
#[derive(Error, Debug)]
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),
#[cfg(feature = "pcap-file")]
#[error(transparent)]
Pcap(#[from] pcap_parser::PcapError),
#[cfg(feature = "live-capture")]
#[error(transparent)]
Live(#[from] p... |
#[doc = "Register `C2IMR1` reader"]
pub type R = crate::R<C2IMR1_SPEC>;
#[doc = "Register `C2IMR1` writer"]
pub type W = crate::W<C2IMR1_SPEC>;
#[doc = "Field `RTCSTAMPTAMPLSECSSIM` reader - RTCSTAMPTAMPLSECSSIM"]
pub type RTCSTAMPTAMPLSECSSIM_R = crate::BitReader;
#[doc = "Field `RTCSTAMPTAMPLSECSSIM` writer - RTCSTAM... |
// 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.
use super::{
evaluation_table::EvaluationTableFragment, BoundaryConstraintGroup, ConstraintEvaluationTable,
PeriodicValueTable, St... |
//! Placeholder that enables running Netherrack as a standalone executable.
//!
//! Actual logic is in the library itself so that, for example, an embedded server can be created.
//!
//! All you would need to do is set the logger!
extern crate netherrack;
pub use netherrack::*;
#[macro_use]
extern crate log;
/// St... |
//use sha2::Digest;
//use chrono::{prelude::*};
use serde::Deserialize;
use serde::ser::{Serialize, Serializer, SerializeStruct};
//use serde_json::json;
#[derive(Debug, Clone, Deserialize)]
pub struct Transaction {
pub sender: String,
pub receiver: String,
pub amount: u64,
}
impl Serialize for Transactio... |
#![forbid(unsafe_code)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde_derive;
pub mod api_client;
pub mod database;
pub mod encryption;
pub mod history;
pub mod import;
pub mod ordering;
pub mod settings;
pub mod sync;
|
use ast::BinaryOp;
use ast::VarType;
use ast::VarType::*;
use ast::Expression;
use ast::AstExpressionNode;
use ast_helper::is_pointer;
pub fn type_contains(parent: &VarType, child: &VarType) -> bool {
parent == child || (*parent == Int && *child == Char)
}
pub fn is_pointer_comparison(l: &VarType, r: &VarType, ... |
#[doc = "Register `SR` reader"]
pub type R = crate::R<SR_SPEC>;
#[doc = "Register `SR` writer"]
pub type W = crate::W<SR_SPEC>;
#[doc = "Field `EOP` reader - End of operation"]
pub type EOP_R = crate::BitReader<EOPW_A>;
#[doc = "End of operation\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub en... |
pub mod openjtalk;
pub mod gcp;
|
use crate::functions::SassFunction;
use crate::parser::SourcePos;
use crate::sass::{CallArgs, FormalArgs, SassString, Value};
use crate::selectors::Selectors;
/// Every sass file is a sequence of sass items.
/// Scoping items contains further sequences of items.
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd)]
pub e... |
// Copyright (c) 2016, <daggerbot@gmail.com>
// This software is available under the terms of the zlib license.
// See COPYING.md for more information.
use std::rc::Rc;
use aurum::linear::Vec2;
use ::Coord;
use device::{Device, DeviceBridge, DevicePriv};
use error::Result;
use id::{Id, IdLock};
use imp::... |
use super::{check_dtype, HasPandasColumn, PandasColumn, PandasColumnObject};
use crate::errors::ConnectorXPythonError;
use anyhow::anyhow;
use fehler::throws;
use ndarray::{ArrayViewMut1, ArrayViewMut2, Axis, Ix2};
use numpy::{PyArray, PyArray1};
use pyo3::{types::PyTuple, FromPyObject, PyAny, PyResult};
use std::any::... |
#![allow(clippy::module_inception)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::ptr_arg)]
#![allow(clippy::large_enum_variant)]
#![doc = "generated by AutoRust 0.1.0"]
#[cfg(feature = "package-2020-09-01")]
pub mod package_2020_09_01;
#[cfg(all(feature = "package-2020-09-01", not(feature = "no-default-versio... |
use std::{
error::Error,
ffi::{c_void, CStr},
fmt::Display,
};
use snes_spc_sys::*;
#[derive(Debug)]
pub struct SNESSpc {
inner_spc: *mut snes_spc_t,
}
#[derive(Debug)]
pub enum SNESSpcError {
NotSpcFile,
CorruptSpcFile,
SPCEmulationError,
}
impl Error for SNESSpcError {
fn descripti... |
#[doc = "Register `GTZC1_MPCBB2_CR` reader"]
pub type R = crate::R<GTZC1_MPCBB2_CR_SPEC>;
#[doc = "Register `GTZC1_MPCBB2_CR` writer"]
pub type W = crate::W<GTZC1_MPCBB2_CR_SPEC>;
#[doc = "Field `GLOCK` reader - lock the control register of the MPCBB until next reset This bit is cleared by default and once set, it can ... |
use crate::domain::model::{IPostRepository, IUserRepository, Post};
use crate::error::ServiceError;
use std::sync::Arc;
#[derive(Clone)]
pub struct PostService<PR, UR>
where
PR: IPostRepository,
UR: IUserRepository,
{
post_repository: Arc<PR>,
user_repository: Arc<UR>,
}
impl<PR, UR> PostService<PR, U... |
use std::{env, str};
use std::fs::File;
use memmap::Mmap;
use oxidized_mtbl::{Reader, Error};
fn main() -> Result<(), Error> {
let path = env::args().nth(1).unwrap();
let key = env::args().nth(2).unwrap();
let file = File::open(path).unwrap();
let mmap = unsafe { Mmap::map(&file).unwrap() };
let ... |
#[macro_use]
extern crate futures;
extern crate tokio;
mod config;
mod cookie;
mod ntp;
mod nts_ke;
use clap::App;
use clap::Arg;
use clap::SubCommand;
use crate::ntp::server::start_ntp_server;
use crate::nts_ke::server::start_nts_ke_server;
fn app() -> App<'static, 'static> {
App::new("cf-nts")
.about(... |
#![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 Resource {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(d... |
mod midi;
mod osc;
use event::ControlEvent;
use std::sync::mpsc;
pub use self::midi::*;
pub use self::osc::*;
use types::Float;
pub trait Receiver {
fn receive_and_send(&mut self, mpsc::Sender<ControlEvent>);
}
pub const CONCERT_A: Float = 440.0;
pub struct PitchConvert {
table: Vec<Float>,
}
impl PitchCo... |
use crate::errors::{ConnectorXOutError, OutResult};
use crate::source_router::{SourceConn, SourceType};
#[cfg(feature = "src_bigquery")]
use crate::sources::bigquery::BigQueryDialect;
#[cfg(feature = "src_mssql")]
use crate::sources::mssql::{mssql_config, FloatN, IntN, MsSQLTypeSystem};
#[cfg(feature = "src_mysql")]
us... |
/*!
```rudra-poc
[target]
crate = "http"
version = "0.1.19"
[report]
issue_url = "hyperium/http#353 and hyperium/http#354"
issue_date = 2019-11-16
rustsec_url = "https://github.com/RustSec/advisory-db/pull/218"
rustsec_id = "RUSTSEC-2019-0034"
[[bugs]]
analyzer = "Manual"
bug_class = "Other"
bug_count = 2
rudra_repor... |
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// 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>,... |
#[doc = "Register `BDTBUPR` reader"]
pub type R = crate::R<BDTBUPR_SPEC>;
#[doc = "Register `BDTBUPR` writer"]
pub type W = crate::W<BDTBUPR_SPEC>;
#[doc = "Field `TIMxCR` reader - HRTIM_TIMxCR register update enable"]
pub type TIMX_CR_R = crate::BitReader<TIMX_CR_A>;
#[doc = "HRTIM_TIMxCR register update enable\n\nVal... |
use failure::{Context, Fail};
#[derive(Debug)]
pub struct DocumentError(Context<DocumentErrorKind>);
impl DocumentError {
pub fn kind(&self) -> &DocumentErrorKind {
self.0.get_context()
}
}
impl Fail for DocumentError {
fn name(&self) -> Option<&str> {
self.0.name()
}
fn cause(&se... |
mod ast;
pub use ast::*;
#[cfg(test)]
mod ast_test;
|
mod algorithms;
mod constructors;
mod conversion;
mod formatting;
mod primitive_methods;
mod scheme_expression;
use crate::runtime::Symbol;
pub use constructors::ListBuilder;
#[derive(Clone, PartialEq)]
pub struct Object {
content: TaggedValue,
}
impl Object {
pub fn new(content: TaggedValue) -> Self {
... |
/**
* 列挙型はOption型とResutl型がある
* rustには例外がないので、その代わりにこれらを使う
* option型は値があれば返し、なければnilというときにつかう
* result型は計算が失敗するかもしれないときに使われる型
*/
enum Option<T> {
// 値がないか
None,
// ある
Some(T),
}
enum Result<T, E> {
// 計算が成功したか
Ok(T),
// 失敗してもエラーが出たか
Err(E),
} |
// q0033_search_in_rotated_sorted_array
struct Solution;
impl Solution {
pub fn search(nums: Vec<i32>, target: i32) -> i32 {
let nlen = nums.len();
if nlen == 0 {
return -1;
}
if nums[0] == target {
return 0;
} else {
if nlen == 1 {
... |
#[tokio::main]
async fn main1() -> Result<(), Box<dyn std::error::Error>> {
let url = "http://openccpm.com/redmine/projects.json";
println!("call {}", url );
let res = reqwest::get( url ).await? ;
let body = res.text().await? ;
println!("response is \n{}", body );
Ok(())
}
#[tokio::main]
async... |
use std::sync::Arc;
use std::ops::Drop;
use std::ptr;
use std::cmp::PartialEq;
use std::fmt;
use counter::{Counter, CounterRange, COUNTER_VALID_RANGE};
pub trait BufRange {
fn range(&self) -> CounterRange;
}
pub struct Buffer<H: BufRange, T> {
inner: Arc<Inner<H, T>>,
ptr: *mut T,
mask: usize,
}
#[... |
use specs::prelude::*;
use cgmath::Vector2;
#[derive(Component)]
pub struct FieldOfView {
pub degrees: Vector2<f64>,
}
impl FieldOfView {
pub fn new(degrees: Vector2<f64>) -> Self {
Self { degrees }
}
}
|
struct Rectangle {
width: f64,
height: f64
}
impl Rectangle {
fn get_area(&self) -> f64 {
return self.width * self.height;
}
fn scale(&mut self,scale_by: f64) {
self.width = self.width * scale_by;
self.height = self.height * scale_by;
}
fn new(height: f64, width: f... |
use crate::pb;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use sqlx::Row;
use std::{collections::HashMap, convert::From, convert::Into};
#[derive(sqlx::FromRow, Serialize, Deserialize, Debug)]
pub struct Maine {
pub id: i64,
pub uid: i64,
pub content: String,
pub comments: i32,
... |
/**
* Fungible Token implementation with JSON serialization.
* NOTES:
* - The maximum balance value is limited by U128 (2**128 - 1).
* - JSON calls should pass U128 as a base-10 string. E.g. "100".
* - The contract optimizes the inner trie structure by hashing account IDs. It will prevent some
* abuse of deep tri... |
fn main() {
// Attempt to get the first word of a sentence
// without using slices
let mut s1 = String::from("Andrew has a cow.");
let mut s2 = String::from("Andrew_has_a_cow.");
let space_pos1 = get_space_pos(&s1);
let space_pos2 = get_space_pos(&s2);
println!("Length of the first word in ... |
use arch::context::{context_switch, Context};
use arch::memory;
use common::event::MouseEvent;
use common::time::{self, Duration};
use core::{cmp, mem, ptr, slice};
use graphics::display::VBEMODEINFO;
use super::{Packet, Pipe, Setup};
use super::desc::*;
pub trait Hci {
fn msg(&mut self, address: u8, endpoint:... |
#[doc = "Reader of register BUS_PRIORITY"]
pub type R = crate::R<u32, super::BUS_PRIORITY>;
#[doc = "Writer for register BUS_PRIORITY"]
pub type W = crate::W<u32, super::BUS_PRIORITY>;
#[doc = "Register BUS_PRIORITY `reset()`'s with value 0"]
impl crate::ResetValue for super::BUS_PRIORITY {
type Type = u32;
#[i... |
use log::*;
struct MyLogger {
max_log_level: LogLevel,
}
impl Log for MyLogger {
fn enabled(&self, metadata: &LogMetadata) -> bool {
metadata.level() <= self.max_log_level
}
fn log(&self, record: &LogRecord) {
if self.enabled(record.metadata()) {
println!("{} - {}", record... |
// Copyright 2019-2023 @polkadot/wasm-crypto authors & contributors
// SPDX-License-Identifier: Apache-2.0
use secp256k1::{ecdsa::{RecoverableSignature, RecoveryId}, Message, PublicKey, SecretKey, SECP256K1};
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn ext_secp_pub_compress(pubkey: &[u8]) -> Vec<u8> {
match... |
#[doc = "Reader of register VOLTAGE_SELECT"]
pub type R = crate::R<u32, super::VOLTAGE_SELECT>;
#[doc = "Writer for register VOLTAGE_SELECT"]
pub type W = crate::W<u32, super::VOLTAGE_SELECT>;
#[doc = "Register VOLTAGE_SELECT `reset()`'s with value 0"]
impl crate::ResetValue for super::VOLTAGE_SELECT {
type Type = ... |
$NetBSD: patch-gfx_wr_swgl_build.rs,v 1.3 2021/08/29 09:36:16 taca Exp $
Work around an internal compiler error on i386 when optimization is enabled:
cargo:warning=In file included from src/gl.cc:2637:0:
cargo:warning=src/rasterize.h: In function 'void draw_quad_spans(int, Point2D*, uint32_t, glsl::Interpolants*,... |
//! Implements common functionality to be consumed by tests.
use std::sync::{Arc, Mutex};
use svm_codec::api::builder::{CallBuilder, SpawnBuilder, TemplateBuilder};
use svm_codec::template;
use svm_layout::{FixedLayout, Layout};
use svm_storage::{
account::{AccountKVStore, AccountStorage},
kv::{FakeKV, Statef... |
// https://www.codewars.com/kata/backwards-read-primes
use std::collections::HashSet;
fn backwards_prime(start: u64, stop: u64) -> Vec<u64> {
println!("{} {}", start, stop);
let mut res = Vec::new();
let mut memoize = HashSet::new();
for x in start.max(11)..stop+1 {
if memoize.contains(&x) {
res.p... |
use std::sync::Arc;
use rosu_v2::model::GameMode;
use crate::{
util::{constants::GENERAL_ISSUE, MessageExt},
BotResult, CommandData, Context, MessageBuilder,
};
#[command]
#[authority()]
#[short_desc("Untrack all users in a channel")]
#[long_desc(
"Stop notifying a channel about new plays in any user's t... |
pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
Io(std::io::Error),
}
impl From<std::io::Error> for Error {
fn from(error: std::io::Error) -> Self {
Error::Io(error)
}
}
impl From<String> for Error {
fn from(error: String) -> Self {
Error::Io(std::io::Error::new(... |
use super::image::Image;
use super::canvas::Canvas;
use crate::inputs::event::EventManager;
use web_sys::{window, Window as WebSysWindow, Document};
/// A struct representing the tab in the web browser.
/// It provide event handling.
pub struct Window {
document: Document,
pub window: WebSysWindow,
events:... |
use std::rc::Rc;
use std::collections::HashMap;
use std::cell::RefCell;
use Value;
use intern::Symbol;
pub type Env = Rc<RefCell<Environment>>;
#[derive(Debug)]
pub struct Environment {
parent: Option<Env>,
bindings: HashMap<Symbol, Value>,
}
impl Environment {
pub fn new() -> Environment {
Envir... |
use crate::schema::registrations;
use crate::{db_conn, Error};
use common::{
chrono::{DateTime, Duration, Utc},
ipnetwork::IpNetwork,
rsip::{self, prelude::*},
};
use diesel::{
deserialize::FromSql,
pg::Pg,
prelude::*,
serialize::{Output, ToSql},
sql_types::Text,
};
use models::transport... |
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput};
use futures::executor::block_on;
use rand::prelude::*;
use std::env;
use std::num::{NonZeroU64, NonZeroUsize};
use subspace_archiving::archiver::Archiver;
use subspace_core_primitives::crypto::kzg;
use subspace_core_primitives::crypto::... |
use async_std::io::copy;
use async_std::net::{TcpStream, UdpSocket};
use async_std::prelude::FutureExt;
use async_std::task;
use async_std::task::JoinHandle;
use config::rule::{Action, ProxyRules};
use config::{Address, Config, ServerConfig};
use futures::io::Error;
use hermesdns::DnsNetworkClient;
use ssclient::{resol... |
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::path::Path;
use std::process::exit;
mod webmain;
#[derive(Serialize, Deserialize)]
struct Config {
address: String,
media_path: String,
}
gflags::define! {
-c, --config: &Path
}
fn main() -> std::io::Result<()> {
gflags::parse();
le... |
use crate::{multi_window::{MultiWindow, NewWindowRequest}, tracked_window::{DisplayCreationError, TrackedWindow, TrackedWindowContainer, TrackedWindowControl}};
use egui_glow::EguiGlow;
use glutin::{PossiblyCurrent, event_loop::ControlFlow};
use crate::windows::MyWindows;
pub struct PopupWindow {
pub input: St... |
mod bus;
mod clint;
mod cpu;
mod memory;
mod plic;
mod trap;
mod uart;
use std::env;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use crate::cpu::*;
use crate::trap::*;
fn main() -> io::Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() != 2 {
panic!("Usage: rvemu-... |
mod matrix;
mod qb;
mod vox;
pub use matrix::*;
pub use vox::*;
use bevy::prelude::{Plugin as BevyPlugin, *};
use qb::QubicleBinaryLoader;
#[derive(Default)]
pub struct Plugin;
impl BevyPlugin for Plugin {
fn build(&self, app: &mut AppBuilder) {
app.add_asset::<Matrix>()
.add_asset_loader::<... |
pub mod sr {
pub mod strt {
pub fn get() -> u32 {
unsafe {
(core::ptr::read_volatile(0x40012400u32 as *const u32) >> 4) & 0x1
}
}
pub fn set(val: u32) {
unsafe {
let mut reg = core::ptr::read_volatile(0x40012400u32 as *cons... |
//! This module provides functionality to automatically check that given solution is feasible
//! which means that there is no constraint violations.
#[cfg(test)]
#[path = "../../tests/unit/checker/checker_test.rs"]
mod checker_test;
use crate::format::problem::*;
use crate::format::solution::*;
use crate::format::Lo... |
use std::path::Path;
use std::fs::read_to_string;
use unwrap::unwrap;
use serde_json::Value;
use crate::align;
#[derive(Debug)]
pub struct ReferenceMetadata {
pub group_on: usize,
pub headers: Vec<String>,
pub columns: Vec<Vec<String>>,
pub sequence_name_idx: usize,
pub sequence_idx: usize
}
// Parses a .... |
extern crate pdf;
use std::env::args;
use std::time::SystemTime;
use std::fs;
use std::io::Write;
use std::rc::Rc;
use pdf::file::File;
use pdf::object::*;
use pdf::error::PdfError;
fn main() -> Result<(), PdfError> {
let path = args().nth(1).expect("no file given");
println!("read: {}", path);
let now =... |
use std::collections::HashSet;
use std::io;
#[derive(Default)]
struct HandHeld {
pc: usize,
acc: isize,
}
#[derive(PartialEq)]
enum ExitReason {
Inf,
End,
}
impl HandHeld {
fn run(&mut self, code: &Vec<&str>) -> io::Result<ExitReason> {
let mut prev_pcs = HashSet::new();
loop {
... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::{models, API_VERSION};
#[non_exhaustive]
#[derive(Debug, thiserror :: Error)]
#[allow(non_camel_case_types)]
pub enum Error {
#[error(transparent)]
MarketplaceAgreements_Get(#[from] mar... |
use super::*;
pub struct Output {
parent: Rc<Window>,
window: Window,
ctx: Rc<Context>,
}
impl Output {
pub fn new(parent: Rc<Window>, ctx: Rc<Context>) -> Self {
let (h, w) = parent.get_max_yx();
let window = parent
.subwin(h - 1, w, 0, 0)
.expect("create outpu... |
impl Solution {
pub fn xor_game(nums: Vec<i32>) -> bool {
if nums.len() % 2 == 0 {
return true;
}
let mut res = 0;
for num in nums.iter(){
res ^= num;
}
res == 0
}
} |
use crate::{buffer::fragment_buffer::FragmentSpan, Fragment};
use sauron::{html::attributes::*, Node};
/// A tree of fragments where a fragment can contain other fragments
/// when those fragments are inside in this fragment
/// The main purpose of this struct is for tagging fragments
/// such as rect and circles to h... |
use std::env::args;
use std::collections::HashMap;
fn main() {
let mut map = HashMap::new();
map.insert(0, "Hello");
map.insert(1, "World");
let result = match map.get(&0) {
Some(v) => v,
_ => "Nothing",
};
println!("{:?}", result);
println!("{:?}", map.get(&0).unwrap_or... |
use std::collections::HashSet;
use std::io;
use std::str;
struct DanceMove {
cmd: u8,
op1: u8,
op2: u8,
}
impl DanceMove {
fn new(cmd: u8, op1: u8, op2: u8) -> DanceMove {
DanceMove { cmd, op1, op2 }
}
}
fn swap(programs: &mut [u8; 16], indices: &mut [u8; 16], p1: usize, p2: usize) {
... |
use fnv::FnvHashMap as HashMap;
/// A stackable image layer.
///
/// Layers contain a list of passes which are used to render a final image which
/// is then composited onto a render target. They are especially useful for
/// postprocessing, e.g. applying a fullscreen night vision effect, drawing a
/// HUD (heads-up ... |
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
include!("vez.rs");
use std::ffi::{CStr, CString};
use std::mem::MaybeUninit;
use std::ops::BitOr;
use std::os::raw::c_char;
//Helper function to convert a slice of Strings to a Vec of CStrings
fn to_c_string_array(in_array: ... |
#![allow(dead_code)]
use crossterm::{
execute,
terminal::{Clear, ClearType},
};
use std::io::{stdin, stdout, Write};
//Function to clean the terminal screen
pub fn clear_screen() {
if cfg!(windows) {
execute!(stdout(), Clear(ClearType::All));
} else {
print!("{esc}[2J{esc}[1;1H", esc =... |
use id::*;
use qdf::*;
/// Holds information about space region.
#[derive(Debug, Clone)]
pub struct Space<S>
where
S: State,
{
id: ID,
state: S,
}
impl<S> Space<S>
where
S: State,
{
#[inline]
pub(crate) fn new(id: ID, state: S) -> Self {
Self { id, state }
}
/// Gets space id.... |
use crate::{util, Args, BotResult, Error};
use twilight_model::{
application::interaction::ApplicationCommand,
channel::Message,
id::{
marker::{ChannelMarker, GuildMarker, InteractionMarker, MessageMarker},
Id,
},
user::User,
};
pub enum CommandData<'m> {
Message {
msg:... |
#[doc = "Reader of register PID4"]
pub type R = crate::R<u32, super::PID4>;
#[doc = "Reader of field `PER_ID_4`"]
pub type PER_ID_4_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:7 - Peripheral ID 4"]
#[inline(always)]
pub fn per_id_4(&self) -> PER_ID_4_R {
PER_ID_4_R::new((self.bits & 0xff) as u8)
... |
mod nvidia;
use ec_gpu::{GpuEngine, GpuField};
static COMMON_SRC: &str = include_str!("cl/common.cl");
static FIELD_SRC: &str = include_str!("cl/field.cl");
static FIELD2_SRC: &str = include_str!("cl/field2.cl");
static EC_SRC: &str = include_str!("cl/ec.cl");
/// Generates the source for the elliptic curve and grou... |
use fltk::{app::*, button::*, enums::*, frame::*, misc::*, prelude::*, valuator::*, window::*};
use std::thread;
use std::time::Duration;
const WIDGET_HEIGHT: i32 = 25;
const WIDGET_PADDING: i32 = 10;
const WIDGET_WIDTH: i32 = 180;
const WIDGET_LABEL_WIDTH: i32 = 110;
const DURATION_DEFAULT: f64 = 15.0;
const DURATIO... |
// 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 ir::StringInterner;
use ir::TypeConstraintFlags;
use crate::mangle::Mangle as _;
use crate::textual;
pub(crate) fn convert_ty(ty: ... |
use std::{
fs::File,
io::Write,
ops::DerefMut,
path::PathBuf,
sync::{Arc, Mutex},
};
use teloxide::types::Message;
/** Message store. */
#[async_trait::async_trait]
pub trait Store: Clone {
type Error;
async fn store(&self, msg: Message) -> Result<(), Self::Error>;
}
/** Store messages t... |
mod core;
mod data;
mod geo;
mod rendering;
mod simulation;
mod sources;
mod text;
mod util;
use crate::core::flight_radar;
use shader_version::OpenGL;
fn main() {
let mut flight_radar = flight_radar::FlightRadar::create(
flight_radar::BuildOptions {
gl_version: OpenGL::V4_5,
use_c... |
// Steps in Prime
// CodeWars challenge
// Program will accept two integers and should calculate the primes within
// the integers and from those primes identify a consecutive pair that
// shares the specified "step" between them.
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
let ... |
use assembly::MachineType;
use assembly::Instruction::*;
use assembly::Instruction;
use assembly::Operand;
use assembly::Operand::*;
use assembly::RegisterVal;
use assembly::RegisterVal::*;
pub const WORD_SIZE: i32 = 4;
/// Get the size of the machine type
pub fn get_mtype_size(t: MachineType) -> i32 {
match t {... |
///// chapter 4 "structuring data and matching patterns"
///// program section:
//
fn main() {
let zuxus = ["zuxu"; 3];
println!("{:?}", zuxus);
}
///// output should be:
/*
*/// end of output
|
use std::convert::TryFrom;
use std::ops::{Deref, DerefMut};
use crate::Element;
/// Maps to `Vec<Element>` where items are heterogeneous
#[derive(Debug)]
pub struct List(pub Vec<Element>);
impl From<List> for Element {
fn from(l: List) -> Self {
Element::List(l.0)
}
}
impl Deref for List {
type ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.