text stringlengths 8 4.13M |
|---|
/// Abstract Syntax for F-terms and F-types
use std::fmt;
// The trees themselves
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum FType {
Var(String),
Arr(Box<FType>, Box<FType>),
Forall(String, Box<FType>),
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum FTermChurch {
Var(String),
Lam(String, B... |
use {
crate::model::*,
cm_rust::{
self, CapabilityPath, ComponentDecl, ExposeDecl, ExposeDirectoryDecl,
ExposeLegacyServiceDecl, ExposeServiceDecl, OfferDecl, OfferDirectoryDecl,
OfferLegacyServiceDecl, OfferServiceDecl, OfferTarget, StorageDecl, UseDecl,
UseDirectoryDecl, UseLeg... |
use log::*;
use num_derive::FromPrimitive;
use serde_derive::{Deserialize, Serialize};
use morgan_interface::account::KeyedAccount;
use morgan_interface::instruction_processor_utils::DecodeError;
use morgan_interface::pubkey::Pubkey;
use morgan_helper::logHelper::*;
#[derive(Serialize, Debug, PartialEq, FromPrimitive)... |
const EXAMPLE: &str = include_str!(r"../../resources/day13-example.txt");
const INPUT: &str = include_str!(r"../../resources/day13-input.txt");
fn part1(_input: &str) -> u64 {
0
}
fn part2(_input: &str) -> u64 {
0
}
fn main() {
rustaoc2022::run_matrix(part1, part2, EXAMPLE, INPUT);
}
#[cfg(test)]
mod te... |
use neon::prelude::*;
use neon::register_module;
use num_cpus;
fn thread_count(mut cx: FunctionContext) -> JsResult<JsNumber> {
Ok(cx.number(num_cpus::get() as f64))
}
fn thread_count_cb(mut cx: FunctionContext) -> JsResult<JsUndefined> {
let prefix = cx.argument::<JsString>(0)?.value();
let f = cx.argume... |
use std::collections::BTreeSet;
pub type NumType = u32;
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct Range {
min: NumType,
max: NumType
}
impl Range {
pub fn new(min: NumType, max: NumType) -> Range {
Range { min: min, max: max }
}
}
pub struct RangeSet {
avai... |
pub use VkSurfaceTransformFlagsKHR::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkSurfaceTransformFlagsKHR {
VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 0x00000001,
VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 0x00000002,
VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 0x00000004,
VK_SURFAC... |
table! {
clients (id) {
id -> Nullable<Int4>,
email -> Varchar,
first_name -> Nullable<Varchar>,
last_name -> Nullable<Varchar>,
}
}
table! {
users (id) {
id -> Nullable<Int4>,
email -> Varchar,
first_name -> Nullable<Varchar>,
last_name -> Nu... |
use std::collections::VecDeque;
use std::convert::TryFrom;
use std::io;
use crate::error::Error;
/// Used to read input for the program.
///
/// Mainly used to allow easier testing.
pub trait ProgInput {
fn read(&mut self) -> Result<String, Error>;
}
/// Used to write output from the program.
///
/// Mainly used... |
use ggez::graphics::Rect;
use specs::World;
pub fn add_camera_resource(world: &mut World, camera: Rect) {
world.add_resource::<Camera>(Camera(camera));
}
pub struct Camera(pub Rect);
|
use core::{Color, ColorComponent, FresnelIndex, RayIntersection, LightIntersection};
use defs::FloatType;
use tools::CompareWithTolerance;
#[derive(Debug, Copy, Clone)]
struct FresnelData {
pub n: FresnelIndex,
pub n_inverse: FresnelIndex,
pub n_avg: FloatType,
pub n_imaginary: FresnelIndex,
pub n... |
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
use std::collections::HashSet;
use std::iter::FromIterator;
fn main() {
let file = File::open("input").expect("Failed to read file input");
let mut buf_reader = BufReader::new(file);
let mut contents = String::new();
buf_reader.read_to_strin... |
use criterion::{criterion_group, criterion_main, Criterion};
use day05::{part1, part2};
fn part1_benchmark(c: &mut Criterion) {
let input = include_str!("../../input/2018/day5.txt").trim();
c.bench_function("part1", move |b| b.iter(|| part1(&input)));
}
fn part2_benchmark(c: &mut Criterion) {
let input = ... |
fn main() {
unreachable!();
}
|
extern crate winrt_notification;
use winrt_notification::{
Duration,
Sound,
Toast,
};
fn main() {
Toast::new(Toast::POWERSHELL_APP_ID)
.title("Look at this flip!")
.text1("(╯°□°)╯︵ ┻━┻")
.sound(Some(Sound::SMS))
.duration(Duration::Short)
.show()
.expect(... |
mod board;
mod ai;
use ai::AI;
pub use board::Board;
mod humanplayer;
mod pipeai;
pub use pipeai::PipeAI;
pub use humanplayer::HumanPlayer;
use board::Player;
use std::time::Instant;
use std::collections::HashMap;
/*#[derive(StructOpt)]
struct Cli {
#[structopt(parse(from_os_str))]
o_ai_path... |
use iron::prelude::*;
use iron::status;
use iron::typemap::Key;
use persistent::Read;
use std::sync::Arc;
use crate::store::StatsStore;
#[cfg(not(debug_assertions))]
const DASHBOARD_SOURCE: &str = include_str!("../web/src/index.html");
#[cfg(not(debug_assertions))]
const DASHBOARD_JS_SOURCE: &str = include_str!("../w... |
pub mod dto;
pub mod image_controller;
pub mod status_controller;
|
/// Devices
pub mod device;
/// Global descriptor table
pub mod gdt;
// /// Interrupt descriptor table
// pub mod idt;
// /// Interrupt instructions
// pub mod interrupt;
// /// Paging
// pub mod paging;
// /// Initialization and start function
// pub mod start;
// /// Stop function
// pub mod stop; |
//! Display attributes
/// Display rotation.
///
/// Note that 90º and 270º rotations are not supported by
// [`TerminalMode`](../mode/terminal/struct.TerminalMode.html).
#[derive(Clone, Copy)]
pub enum DisplayRotation {
/// No rotation, normal display
Rotate0,
/// Rotate by 90 degress clockwise
Rotate... |
use fuzzcheck::DefaultMutator;
#[derive(Clone, DefaultMutator)]
pub struct X(bool);
#[derive(Clone, DefaultMutator)]
pub struct Y {
x: bool,
}
#[cfg(test)]
mod test {
use fuzzcheck::Mutator;
use super::*;
#[test]
#[no_coverage]
fn test_compile() {
let _m = X::default_mutator();
... |
use std::error::Error;
use std::thread;
use std::time::Duration;
use rainbow_hat_rs::lights::Lights;
use rainbow_hat_rs::touch::Buttons;
fn main() -> Result<(), Box<dyn Error>> {
let mut lights = Lights::new()?;
let mut buttons = Buttons::new()?;
// Turn on the light when a touch is pressed.
loop... |
//! Server-side synchronous Postgres connection, as limited as we need.
//! To use, create PostgresBackend and run() it, passing the Handler
//! implementation determining how to process the queries. Currently its API
//! is rather narrow, but we can extend it once required.
use crate::pq_proto::{BeMessage, FeMessage,... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qtoolbutton.h
// dst-file: /src/widgets/qtoolbutton.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block be... |
// 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.
mod segments;
mod transform;
use crate::point::Point;
use segments::PathSegments;
use transform::Transform;
#[derive(Clone, Copy, Debug, PartialEq)]
pub... |
use chrono::{DateTime, NaiveDateTime, Utc};
pub mod map_lat_long;
pub mod map_weather;
pub mod digit_map;
pub fn countdown(timestamp: String) -> TimeFrame {
let scheduled_naive = NaiveDateTime::parse_from_str(timestamp.as_str(), "%Y-%m-%dT%H:%M:%SZ").unwrap();
let scheduled = DateTime::<Utc>::from_utc(schedul... |
#[macro_use]
pub mod shared;
pub mod blake2b;
pub mod blake2s;
|
use futures::*;
use std::io;
use tokio_core;
use tokio_io::{AsyncRead, AsyncWrite};
pub type PlaintextSocket = tokio_core::net::TcpStream;
/// Abstracts a plaintext socket vs. a TLS decorated one.
#[derive(Debug)]
pub enum Connection {
Plain(PlaintextSocket),
}
/// A connection handshake.
///
/// Resolves to a c... |
use std::io;
use std::fs;
use std::path::Path;
pub fn get_string<T: AsRef<Path>>(path: T) -> io::Result<String> {
match fs::read_to_string(path) {
Err(e) => Err(e),
Ok(ref content) => {
let trimmed = content.trim();
if trimmed.starts_with('\0') {
Err(io::Err... |
//! Native loader
use crate::message_processor::SymbolCache;
use bincode::deserialize;
#[cfg(unix)]
use libloading::os::unix::*;
#[cfg(windows)]
use libloading::os::windows::*;
use log::*;
use morgan_interface::account::KeyedAccount;
use morgan_interface::instruction::InstructionError;
use morgan_interface::instruction... |
use crate::{
protocol::{parts::AmRsCore, ServerUsage},
HdbError, HdbResult,
};
use std::collections::VecDeque;
#[cfg(feature = "async")]
use super::fetch::async_fetch_a_lob_chunk;
use crate::conn::AmConnCore;
#[cfg(feature = "async")]
use tokio::io::ReadBuf;
#[cfg(feature = "sync")]
use super::fetch::sync_fet... |
//! The device struct and implementation
use pyo3::prelude::*;
use pyo3::wrap_pyfunction;
use crate::bindings::*;
use crate::error_enum_or_value;
use crate::types::HydraHarpError::*;
use crate::types::{
CTCStatus, EdgeSelection, HydraHarpError, MeasurementControl, MeasurementMode, ReferenceSource,
};
use crate::me... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// 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 ... |
pub mod entity;
pub mod orm;
pub mod repository;
|
#![feature(llvm_asm)]
extern "C" fn foo() { }
fn main() {
let x: usize;
unsafe {
llvm_asm!("movq $1, $0" : "=r"(x) : "r"(foo));
}
assert!(x != 0);
}
|
use tokio::sync::{Mutex, MutexGuard};
use crate::actor::Actor;
use crate::data::ContextData;
use std::{collections::HashMap, sync::Arc};
#[derive(Clone)]
pub struct AppContext(Arc<Mutex<Context>>);
impl AppContext {
pub fn init() -> AppContext {
AppContext(Arc::new(Mutex::new(Context::new())))
}
... |
pub mod large;
pub mod small;
use num_bigint::BigInt;
use liblumen_alloc::erts::exception::InternalResult;
use liblumen_alloc::erts::term::prelude::*;
use liblumen_alloc::Process;
use super::{sign, try_split_at};
fn decode<'a>(process: &Process, bytes: &'a [u8], len: usize) -> InternalResult<(Term, &'a [u8])> {
... |
// Copyright 2023 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
use std::io::{self, Cursor, Read, Seek, SeekFrom};
use std::num::ParseIntError;
use std::result::Result as StdResult;
use {RealTime, Run, Segment, Time, TimeSpan};
use base64::{self, STANDARD};
use byteorder::{ReadBytesExt, BE};
use imagelib::{png, ColorType, ImageBuffer, Rgba};
use super::xml_util::{self, text};
use s... |
use crate::geometry::MeasuredSize;
#[derive(Copy, Clone, Debug)]
pub enum MeasureConstraint {
AtMost(u32),
Exactly(u32),
Unspecified,
}
impl MeasureConstraint {
pub fn shrink(self, by: u32) -> MeasureConstraint {
match self {
MeasureConstraint::AtMost(size) => MeasureConstraint::At... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qmutex.h
// dst-file: /src/core/qmutex.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= mai... |
//! Self-contained dependency graph for a set of packages.
use std::collections::{BTreeMap, HashSet};
use std::error::Error;
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::sync::Arc;
use deck_core::{Manifest, ManifestId, OutputId};
type Result<T> = std::result::Result<T, ClosureError>;
/// Self-c... |
extern crate cfnetwork;
use cfnetwork::*;
fn main() {
unsafe {
println!("{:?}", CFHostGetTypeID());
println!("{:?}", CFHTTPAuthenticationGetTypeID());
println!("{:?}", CFHTTPMessageGetTypeID());
println!("{:?}", CFNetServiceGetTypeID());
println!("{:?}", CFNetServiceMonitor... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u8,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u8,
}
impl super::DEVCTL {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w... |
#[cfg(target_os = "linux")]
use honggfuzz::fuzz;
#[cfg(target_os = "linux")]
fn main() {
loop {
fuzz!(|data: &[u8]| {
if data.len() != 3 {
return;
}
if data[0] != b'h' {
return;
}
if data[1] != b'e' {
... |
extern crate gotham;
extern crate handlebars_gotham as hbs;
extern crate hyper;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate maplit;
extern crate mime;
use gotham::state::State;
use gotham::http::response::create_response;
use gotham::handler::{NewHandl... |
use super::input::Input;
use crate::{runner::RunResult, values::InputGeneration};
use candy_vm::heap::{Heap, SymbolTable};
use itertools::Itertools;
use rand::{rngs::ThreadRng, seq::SliceRandom, Rng};
use rustc_hash::FxHashMap;
use std::{cell::RefCell, rc::Rc};
pub type Score = f64;
pub struct InputPool {
heap: R... |
#[macro_use]
extern crate lazy_static;
extern crate itertools;
extern crate regex;
use itertools::Itertools;
use regex::Regex;
#[derive(Clone)]
struct Claim {
id: i32,
offset_left: i32,
offset_top: i32,
width: i32,
height: i32,
}
impl Claim {
fn parse(raw_claim: &str) -> Claim {
lazy_... |
use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let s: u32 = rd.get();
let t: u32 = rd.get();
let mut ans = 0_u32;
for a in 0..=s {
for b in 0..=s {
for c in 0..=s {
if a + b +... |
use std::collections::{HashMap, HashSet};
use crate::{
parser::types::{Field, Selection, SelectionSet},
validation::visitor::{Visitor, VisitorContext},
Positioned,
};
#[derive(Default)]
pub struct OverlappingFieldsCanBeMerged;
impl<'a> Visitor<'a> for OverlappingFieldsCanBeMerged {
fn enter_selection... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - OTG_FS host configuration register (OTG_FS_HCFG)"]
pub otg_fs_hcfg: OTG_FS_HCFG,
#[doc = "0x04 - OTG_FS Host frame interval register"]
pub otg_fs_hfir: OTG_FS_HFIR,
#[doc = "0x08 - OTG_FS host frame number/frame time re... |
use std::collections::BTreeMap;
#[derive(Debug)]
pub(crate) struct RunnerSpec {
cases: Vec<CaseSpec>,
include: Option<Vec<String>>,
default_bin: Option<crate::schema::Bin>,
timeout: Option<std::time::Duration>,
env: crate::schema::Env,
}
impl RunnerSpec {
pub(crate) fn new() -> Self {
... |
// Copyright 2013 The Servo 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>, at ... |
#![feature(drain_filter)]
extern crate futures;
extern crate tokio_core;
extern crate tokio_io;
extern crate bincode;
extern crate rustc_serialize;
mod udp;
use tokio_core::reactor::Core;
use futures::*;
use futures::sync::mpsc;
use std::thread;
use std::net::SocketAddr;
fn main() {
let target_addr_str = "127.0... |
extern crate regex;
use regex::Regex;
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let file = File::open(filename).expect("Could not read file");
let mut... |
#[doc(hidden)]
pub use crate::{
adapter::Adapter,
client::StdoutWriter,
events::{self, Event, EventBody},
line_reader::{FileLineReader, LineReader},
requests::{self, Command, Request},
responses::{self, Response, ResponseBody},
reverse_requests::{ReverseCommand, ReverseRequest},
server::... |
mod vector;
pub use vector::Vector;
/// Functions to generate waves from some continuously rising value
pub mod gen {
/// Generate a saw wave with given phase, length and amplitude value at state.
/// If abs is true, output ranges from 0 to amplitude.
/// If abs is false, output ranges from -amplitude/2 to... |
#[doc = "Reader of register ICR"]
pub type R = crate::R<u32, super::ICR>;
#[doc = "Writer for register ICR"]
pub type W = crate::W<u32, super::ICR>;
#[doc = "Register ICR `reset()`'s with value 0"]
impl crate::ResetValue for super::ICR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
/* origin: FreeBSD /usr/src/lib/msun/src/s_log1p.c */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freel... |
use fonttools_cli::{open_font, read_args, save_font};
fn main() {
let matches = read_args(
"ttf-fix-checksum",
"Ensures TTF files have correct checksum",
);
let infont = open_font(&matches);
save_font(infont, &matches);
}
|
use crate::error;
use crate::plan::ir::Field;
use arrow::datatypes::DataType;
use datafusion::common::{DFSchemaRef, Result};
use datafusion::logical_expr::{Expr, LogicalPlan, LogicalPlanBuilder};
use datafusion_util::AsExpr;
use generated_types::influxdata::iox::querier::v1::influx_ql_metadata::TagKeyColumn;
use influx... |
pub fn lambda(handler: fn(&str) -> std::result::Result<String, String>) {
// Initialise one-time resources here
// If initialisation error, POST to /runtime/init/error
// Get new invocation events and pass to handler
let aws_lambda_runtime_api = std::env::var("AWS_LAMBDA_RUNTIME_API").unwrap();
loo... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type HostMessageReceivedCallback = *mut ::core::ffi::c_void;
pub type IsolatedWindowsEnvironment = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct... |
use actix::prelude::*;
use crate::WorkerState;
use crate::messages::StatusUpdate;
pub struct Executor {
worker_state: Addr<WorkerState>
}
impl Executor {
pub fn new(worker_state: Addr<WorkerState>) -> Executor {
Executor {
worker_state
}
}
}
impl Actor for Executor {
type... |
//! Macros for defining plugin functions.
/// Define file importer
#[macro_export]
macro_rules! plugkit_api_file_import {
( $x:ident ) => {
#[no_mangle]
pub extern "C" fn plugkit_v1_file_importer_is_supported(c: *mut Context, p: *const libc::c_char) -> bool {
use std::ffi::CStr;
... |
use std::collections::HashMap;
use std::net::{SocketAddr, UdpSocket};
use std::sync::{Arc, mpsc, Mutex};
use std::thread;
use std::time::{Duration, Instant};
use crate::network::MAX_PACKET_SIZE;
pub struct NetworkAbuser {
running: Mutex<bool>,
socket: UdpSocket,
sender: Mutex<mpsc::Sender<bool>>,
se... |
use crate::ast;
use crate::macros;
use crate::parsing;
use crate::shared;
use std::fmt;
/// This file has been generated from `assets\tokens.yaml`
/// DO NOT modify by hand!
/// The `abstract` keyword.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Abstract {
/// Associated token.
pub token: ast::Tok... |
use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let t: usize = rd.get();
for _ in 0..t {
let n: usize = rd.get();
let lr: Vec<(usize, usize)> = (0..n)
.map(|_| {
let l: usize = rd.get()... |
// 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 carnelian::{
set_node_color, AnimationMode, App, AppAssistant, Color, Coord, Point, Rect, Size,
ViewAssistant, ViewAssistantContext, ViewAssist... |
//! Types used by the worker-host protocol.
use serde::{self, Deserializer, Serializer};
use serde_bytes;
use serde_derive::{Deserialize, Serialize};
use crate::{
common::{
crypto::{
hash::Hash,
signature::{PublicKey, Signature},
},
roothash::{Block, ComputeResultsHe... |
use std::cmp::{Eq, PartialOrd, Ord, Ordering};
#[derive(PartialEq, Eq, Debug)]
pub struct Orbit {
pub base: String,
pub orbiter: String,
}
impl Ord for Orbit {
fn cmp(&self, other: &Self) -> Ordering {
self.base.cmp(&other.base)
}
}
impl PartialOrd for Orbit {
fn partial_cmp(&self, other: &Self) -> Option<Ord... |
use std::time::Instant;
use crate::core::engine::EngineInit;
use winit::event::Event;
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Dimensions {
pub width: u32,
pub height: u32,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct InitialWindowInfo {
pub initial_dimensions: Dimensions,
pub tit... |
use anyhow::Result;
use pathfinder_common::trie::TrieNode;
use pathfinder_common::{
BlockHash, BlockNumber, BlockTimestamp, ByteCodeOffset, CallParam, CallResultValue, CasmHash,
ClassCommitment, ClassCommitmentLeafHash, ClassHash, ConstructorParam, ContractAddress,
ContractAddressSalt, ContractNonce, Contra... |
use proconio::input;
macro_rules! chmax {
($a: expr, $b: expr) => {
$a = $a.max($b);
};
}
fn main() {
input! {
n: usize,
m: usize,
a: [i64; n],
};
let inf = std::i64::MAX;
let mut dp = vec![-inf; m + 1];
dp[0] = 0;
for i in 0..n {
let mut next =... |
//! Storage imports.
use std::convert::TryInto;
use oasis_contract_sdk_types::storage::StoreKind;
use oasis_runtime_sdk::{context::Context, storage::Store};
use super::{memory::Region, OasisV1};
use crate::{
abi::{gas, ExecutionContext},
store, Config, Error,
};
impl<Cfg: Config> OasisV1<Cfg> {
/// Link ... |
use std::collections::HashMap;
use std::sync::Arc;
use crate::mysql::protocol;
use crate::mysql::{MySql, MySqlValue};
use crate::row::{ColumnIndex, Row};
use serde::de::DeserializeOwned;
#[derive(Debug)]
pub struct MySqlRow<'c> {
pub(super) row: protocol::Row<'c>,
pub(super) names: Arc<HashMap<Box<str>, u16>>... |
use juniper::graphql_object;
struct ObjA;
#[graphql_object]
impl ObjA {
fn id(&self) -> &str {
"funA"
}
#[graphql(name = "id")]
fn id2(&self) -> &str {
"funB"
}
}
fn main() {}
|
use aoc;
use std::collections::HashMap;
type OpPrecedence = HashMap<char, usize>;
type RPN = Vec<char>;
// https://en.wikipedia.org/wiki/Shunting-yard_algorithm
fn parse2(expr : &String, opm: &OpPrecedence) -> RPN {
let mut rpn : Vec<char> = vec!();
let mut op : Vec<char> = vec!();
for t in expr.chars().... |
use crate::{linalg::Vct, Deserialize, Flt, Serialize};
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct BBox {
pub min: Vct,
pub max: Vct,
}
impl BBox {
pub fn hit(&self, origin: &Vct, direct: &Vct) -> Option<(Flt, Flt)> {
let inv_direct = Vct::new(1.0 / direct.x, 1.0 / direct.y... |
use std::fs::File;
use std::io::prelude::Write;
use std::process::Command;
use std::thread;
use std::time;
use crate::mqtt::AsyncClient;
use crate::nodes::announce_blackbox_online;
use crate::settings::SettingsMosquitto;
use crate::INTERFACE_MQTT_USERNAME;
pub static REGISTERED_TOPIC: &str = "registered";
pub static... |
// 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 {
failure::{Error, ResultExt},
fidl::endpoints,
fidl_fuchsia_io::DirectoryMarker,
fidl_fuchsia_sys2 as fsys, fidl_fuchsia_test_breakpoi... |
use crate::context::UpstreamContext;
use core::cell::UnsafeCell;
/// A leaf component representing IRQ logic.
///
/// Being an interrupt, it has no sense of *inbound* messages, but
/// can producer `::OutboundMessage`s to its containing parent
/// `Component` or `Kernel`.
pub trait Interrupt: Sized {
/// The type ... |
//#[path = "./lib.rs"]
//mod lib;
//use lib::*;
fn main() {
//let ptr = RcCell::new(123);
//let foo = ptr.borrow();
//println!("{}", foo);
}
|
use atomsh::{CWD, REPORT, PROMPT, INCOMPLETE_PROMPT, Error, Environment, Value, parse, PRELUDE_FILENAME, HISTORY_FILENAME};
use rustyline::{
error::ReadlineError,
Editor, Helper, Modifiers, KeyEvent, Cmd
};
use std::{borrow::Cow::{self, Borrowed, Owned}, env::current_dir, fs::read_to_string, sync::{Arc, Mutex}... |
//! Internal data types for use within PICL
use std::collections::{HashMap, HashSet};
use std::fmt;
use super::float::LF64;
use super::list::List;
/// A LispList is a list of LispVals
pub type LispList = List<LispVal>;
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub enum LispVal {
// Literals
Nil,
Bool... |
use exitfailure::ExitFailure;
use failure::ResultExt;
use log::{info, warn};
use structopt::StructOpt;
#[derive(StructOpt)]
struct Cli {
pattern: String,
#[structopt(parse(from_os_str))]
path: std::path::PathBuf,
}
#[test]
fn find_a_match() {
let mut result = Vec::new();
cli_grep::find_matches("l... |
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate rocket;
mod config;
mod models;
mod routes;
mod views;
use jfs::Store;
use models::file_stores::FileStores;
fn main() {
let file_store = FileStores {
articles: Store::new("articles").unwrap(),
shops: Store::new("shops").unwrap... |
// table.rs
// defining structs and implementations for tables, rows and maybe columns
use serde::{Serialize, Deserialize};
#[derive(Debug, Serialize, Deserialize, PartialEq)]
pub struct Table {
pub num_rows: u32,
pub pages: u32,
pub columns: Vec<String>,
pub rows: Vec<Vec<u8>>
}
#[derive(Debug... |
use std::{
fs,
path,
io::{
Read,
Write
},
};
use sgx_types::*;
use sgx_urts::SgxEnclave;
static ENCLAVE_TOKEN: &'static str = "enclave.token";
static ENCLAVE_FILE: &'static str = "enclave.signed.so";
lazy_static! { // NOTE Gives us enc. as global but now can't destroy it!
pub stati... |
//! The dram module contains a dram structure and implementation for dram access.
use crate::bus::*;
/// Default dram size (128MiB).
pub const DRAM_SIZE: u64 = 1024 * 1024 * 128;
/// The dynamic random access dram (DRAM).
#[derive(Debug)]
pub struct Dram {
pub dram: Vec<u8>,
}
impl Dram {
/// Create a new `... |
mod dhcp;
mod repository;
mod util;
use crate::dhcp::{DhcpOptions, DhcpPacket, DhcpServer, MessageType};
use anyhow::{anyhow, Context};
use log::{debug, error};
use std::env;
use std::net::UdpSocket;
use std::sync::Arc;
use std::thread;
const BOOTREQUEST: u8 = 1;
#[allow(dead_code)]
const BOOTREPLY: u8 = 2;
fn main(... |
mod udpserv;
pub use udpserv::*;
mod udpsock;
pub use udpsock::*;
mod cache;
pub use cache::*;
mod udpxmgr;
pub use udpxmgr::*;
mod ustub;
pub use ustub::*;
use os_socketaddr::OsSocketAddr;
use std::io;
use std::net::SocketAddr;
use std::os::unix::io::RawFd;
#[link(name = "recvmsg", kind = "static")]
extern "C" {
... |
use math::primes;
use std::cmp;
use std::collections::HashMap;
pub fn demo(n: u64) {
println!("{:?}", lcm(n));
}
fn lcm(n: u64) -> u64 {
let mut common: HashMap<u64, u64> = HashMap::new();
for i in 2..n {
let mut i_primes: HashMap<u64, u64> = HashMap::new();
for prime in primes::prime_fac... |
//! Internal search functions.
use arrayvec::ArrayVec;
use reason_othello::game::GameState;
/// TODO: document
pub fn window(state: GameState, alpha: i8, beta: i8) -> i8 {
window_fastest_first(state, state.board.count_empties(), alpha, beta)
}
/// Window search, using "fastest first" move ordering which first
//... |
#![allow(non_camel_case_types, dead_code, unused)]
// Functions here are copied from the `IOKit-sys` (https://crates.io/crates/iokit-sys) crate
// and rewritten to use `core_foundation` types.
use core_foundation::base::{mach_port_t, CFAllocatorRef};
use core_foundation::dictionary::{CFDictionaryRef, CFMutableDiction... |
use std::any::Any;
use std::sync::Arc;
use tokio::net::TcpListener;
use tokio_util::sync::CancellationToken;
use tonic::{body::BoxBody, transport::NamedService, Code};
use tonic_health::server::HealthReporter;
use trace_http::ctx::TraceHeaderParser;
use crate::server_type::{RpcError, ServerType};
/// Returns the nam... |
use super::{
PositionIterInternal, PyBytes, PyBytesRef, PyInt, PyListRef, PySlice, PyStr, PyStrRef, PyTuple,
PyTupleRef, PyType, PyTypeRef,
};
use crate::{
atomic_func,
buffer::FormatSpec,
bytesinner::bytes_to_hex,
class::PyClassImpl,
common::{
borrow::{BorrowedValue, BorrowedValueMu... |
// Copyright 2018 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.
pub use wlan_common as common;
pub mod ap;
pub mod auth;
pub mod buffer;
pub mod client;
pub mod device;
pub mod error;
pub mod timer;
mod rates_writer;
... |
use crate::impl_vk_handle;
use crate::prelude::*;
use utilities::prelude::*;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
pub struct SamplerBuilder {
create_info: VkSamplerCreateInfo,
}
impl SamplerBuilder {
pub fn min_mag_filter(mut self, min_filter: VkFilter, mag_filter: VkFilter) -> Self {... |
use super::constants;
use super::Card;
#[derive(Debug, Clone)]
pub struct Hand {
id: u32,
values: Vec<Card>,
}
impl Hand {
pub fn new(id: u32, values: Vec<Card>) -> Hand {
Hand {
id,
values: values.to_vec(),
}
}
pub fn get_owner(&self) -> String {
i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.