text stringlengths 8 4.13M |
|---|
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
use crate::intrinsics;
use crate::lisp_value::LispValue;
pub type Map = HashMap<String, Rc<LispValue>>;
#[derive(Debug)]
pub struct Env {
root: Option<Rc<Env>>,
parent: Option<Rc<Env>>,
env: RefCell<Map>,
}
impl Env {
pub fn new... |
// Copyright 2016 Mozilla Foundation
//
// 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... |
//! The Lioll project.
#![warn(missing_docs)]
use std::io;
use std::io::Read;
use std::iter::Peekable;
use std::string::FromUtf8Error;
/// Represents tokens.
#[derive(Debug, PartialEq)]
enum Token {
String(String),
Number(isize),
LBrack,
RBrack,
}
/// A lexer.
struct Lexer<R: Read + Sized> {
byte... |
// Copyright 2019 WHTCORPS INC Project Authors. Licensed under Apache-2.0.
use crate::causet_options::PrimaryCausetNetworkOptions;
use crate::errors::Result;
pub trait CausetHandleExt {
type CausetHandle: CausetHandle;
type PrimaryCausetNetworkOptions: PrimaryCausetNetworkOptions;
fn causet_handle(&sel... |
//
//! Copyright 2020 Alibaba Group Holding 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 ... |
use protobuf::EnumOrUnknown;
use protobuf::MessageFull;
use super::test_reflect_default_pb::*;
#[test]
fn test_regular() {
let m = TestReflectDefault::new();
let descriptor = TestReflectDefault::descriptor();
let i = descriptor.field_by_name("i").unwrap();
assert_eq!(10, i.get_singular_field_or_defa... |
use super::{
content::{Content, ContentBuilder, Format},
hierarchy::{Direction, Hierarchy, HierarchyBuilder, HierarchyParser, Instruction},
};
#[derive(Debug)]
pub struct Document<F: Format> {
content: Content<F>,
hierarchy: Hierarchy,
}
impl<F: Format> Document<F> {
// XXX May be better to have a... |
/*
* Copyright 2020 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... |
//! [](https:://github.com/alekspickle)
//!
//! # Minimalistic modern infinite terminal progress indicator
//!
//! This is slightly changed version of [rustbar](https://crates.io/crates/rustbar) crate, which is simple and minimalistic,
//! but i needed another infini... |
//!
//! # Fluvio SC - output processing
//!
//! Format SPU response based on output type
//!
use prettytable::Row;
use prettytable::row;
use prettytable::cell;
use crate::error::CliError;
use crate::common::OutputType;
use crate::common::{EncoderOutputHandler, TableOutputHandler};
use super::list_metadata::ScSpuMetad... |
struct Solution;
use util::*;
trait Postorder {
fn postorder(&self, max: &mut i32) -> (i32, i32);
}
impl Postorder for TreeLink {
fn postorder(&self, max: &mut i32) -> (i32, i32) {
if let Some(node) = self {
let node = node.borrow();
let (_, left_right) = node.left.postorder(ma... |
use std::{
marker::PhantomData,
sync::{Arc, RwLock},
time::Duration,
};
use mio_extras::channel::{self as mio_channel, Receiver};
use serde::Serialize;
use log::{error, warn};
use crate::{
discovery::discovery::DiscoveryCommand, serialization::CDRSerializerAdapter,
dds::qos::policy::Liveliness, structure::t... |
extern crate gcc;
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::PathBuf;
fn main() {
gcc::Config::new()
.file("src/main.c")
.file("src/data.c")
// gcc-crate defaults to PIC, which results in a .got (global offset
// table) section that doesn't get relocated pr... |
use serde::{Deserialize};
use crate::config::Trello as TrelloConfig;
use crate::notify;
pub struct Trello<'a> {
pub config: &'a TrelloConfig,
}
impl<'a> Trello<'a> {
pub fn new(config: &'a TrelloConfig ) -> Self {
Trello { config }
}
async fn add_url(&self, url: &str) -> reqwest::Result<()> {... |
mod iteration;
mod file_io;
fn main() {
println!("\n\nfile io\n");
file_io::open();
println!("iteration");
iteration::loops();
}
|
use std::rc::Rc;
use tokio::sync::mpsc::{Receiver, Sender};
use crate::{
custom_m3u8::{Segment, SegmentBytes},
stderr,
tzerror::TwitchzeroError,
};
pub struct OutputStreamSender {
pub reliable: bool,
pub tx: Sender<Rc<Vec<u8>>>,
}
#[allow(clippy::await_holding_refcell_ref)]
/// copies
/// from: ... |
pub type Error = usize;
pub const OK: usize = 0;
pub const ERR: usize = 1;
|
// Copyright 2019 CoreOS, Inc.
//
// 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 super::TaskControlBlock;
use alloc::collections::VecDeque;
use alloc::sync::Arc;
use spin::Mutex;
use lazy_static::*;
pub struct TaskManager {
ready_queue: VecDeque<Arc<TaskControlBlock>>,
}
/// A simple FIFO scheduler.
impl TaskManager {
pub fn new() -> Self {
Self { ready_queue: VecDeque::new(),... |
extern crate bitintr;
#[no_mangle]
pub fn rbit_u64(x: u64) -> u64 {
bitintr::arm::v7::rbit(x)
}
|
use std::convert::TryFrom;
use std::env;
use std::fs;
use std::net::Ipv4Addr;
use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
use structopt::StructOpt;
pub const DEFAULT_CONFIG_FILE: &str = "./config.yaml";
pub const DEFAULT_SCHEDULES_FOLDER: &str = "./schedules";
pub const DEFAULT_LOG_LEVEL: &st... |
use fs_extra;
use lal;
use loggerv;
use tempdir;
use crate::common::{
fs_extra::dir::{copy, CopyOptions},
loggerv::init_with_verbosity,
tempdir::TempDir,
};
use std::{
env, fs,
path::{Path, PathBuf},
sync::Once,
};
use lal::{BackendConfiguration, Config, LocalBackend};
pub mod build;
pub mo... |
#[allow(unused_imports)]
use serde_json::Value;
#[derive(Debug, Serialize, Deserialize)]
pub struct ClusterTimezoneSettingsExtended {
/// Timezone hierarchical name.
#[serde(rename = "path")]
pub path: Option<String>,
}
|
use engine::{Actor, Map};
use util::units::Direction;
pub struct World {
pub player: Actor,
pub actors: Vec<Actor>,
pub map: Map,
}
impl World {
pub fn new() -> World {
let map = Map::from_file("assets/maps/test.map");
World {
player: Actor::new("Player", map.starting_posi... |
use std::cell::Cell;
use std::sync::{Arc, Mutex};
use anyhow::{anyhow, Context, Result};
use dbus::arg::OwnedFd;
use dbus::blocking::Connection;
use dbus::Message;
use slog::{debug, error, info, Logger};
use night_kitchen::dbus::login_manager;
use night_kitchen::dbus::logind::{
OrgFreedesktopLogin1Manager, OrgFre... |
#[doc = "Register `IFS` writer"]
pub struct W(crate::W<IFS_SPEC>);
impl core::ops::Deref for W {
type Target = crate::W<IFS_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl core::ops::DerefMut for W {
#[inline(always)]
fn deref_mut(&mut self) -> &mut Self::Tar... |
use std::cmp::Ordering;
use std::collections::HashMap;
use std::collections::HashSet;
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
pub struct Coord {
pub x: usize,
pub y: usize,
}
impl Coord {
pub fn new(x: usize, y: usize) -> Self {
Coord { x, y }
}
pub fn get_is_next_to_coord(&self, other: &Coo... |
// https://leetcode.com/problems/smallest-rotation-with-highest-score/
// You are given an array nums. You can rotate it by a non-negative integer k so that the array
// becomes [nums[k], nums[k + 1], ... nums[nums.length - 1], nums[0], nums[1], ..., nums[k-1]].
// Afterward, any entries that are less than or equal to... |
mod ex1;
mod ex2; |
extern crate util;
use std::process;
use util::get_note;
pub fn run(book: String, index: usize) -> () {
match get_note(&book, index) {
Err(e) => {
println!("Unable to read note {} from book '{}': {}", index, book, e);
process::exit(1)
},
Ok(note) => println!("{}", n... |
// Copyright 2019-2020 Twitter, Inc.
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
use core::convert::TryFrom;
use core::str::FromStr;
use metrics::Statistic;
use serde_derive::{Deserialize, Serialize};
use strum::ParseError;
use strum_macros::{EnumIter, EnumString, I... |
use crate::theory_primitive::note::Note;
pub fn note_to_string(note: &Note) -> &'static str {
match note {
Note::AFlatFlat => "A𝄫",
Note::AFlat => "A♭",
Note::A => "A",
Note::ASharp => "A♯",
Note::ASharpSharp => "A𝄪",
Note::BFlatFlat => "B𝄫",
Note::BFlat =... |
use libc::*;
pub const DTLS1_COOKIE_LENGTH: c_uint = 256;
|
#[macro_use]
extern crate num_derive;
use num::FromPrimitive;
use common::InputReader;
// Negative values are allowed in intcode programs.
pub type Val = i64;
#[derive(Debug, Eq, FromPrimitive, PartialEq)]
enum Instruction {
Add = 1,
Mul = 2,
Input = 3,
Output = 4,
JumpT = 5,
JumpF = 6,
... |
use shared::types::*;
pub trait Visitor {
fn visit_abt<Inner: Accept>(&mut self, _abt: &mut ABT<Inner>) -> bool {
true
}
fn visit_term(&mut self, _term: &mut Term) -> bool {
true
}
fn visit_type(&mut self, _typ: &mut Type) -> bool {
true
}
fn post_abt<Inner: Accept>(... |
use crate::decode::Decode;
use crate::encode::{Encode, IsNull};
use crate::error::BoxDynError;
use crate::types::Type;
use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueFormat, PgValueRef, Postgres};
use chrono::{
DateTime, Duration, FixedOffset, Local, NaiveDate, NaiveDateTime, Offset, TimeZone, Utc... |
// Copyright (c) The debug-ignore Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0
extern crate debug_ignore;
use debug_ignore::DebugIgnore;
#[test]
fn test_transparent() {
assert_eq!(
serde_json::from_str::<DebugIgnore<_>>(r#""foo""#).unwrap(),
DebugIgnore("foo")
);
assert_eq!(... |
use reqwest::Url;
use std::time::Duration;
use clap::{Arg, App, ArgMatches};
use log::{info, warn, error, Level};
struct RequestArguments {
url: String,
timeout: u64,
}
fn main() {
let matches = parse_arguments();
let m_res = match fetch_parsed_arguments(&matches) {
Ok(res) => res,
Err... |
// This file is part of Substrate.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Softwa... |
pub fn rotate_char(c: char, i: u8) -> char {
if c.is_alphabetic() {
let basis = if c.is_uppercase() { 'A' } else { 'a' };
((((c as u8) - (basis as u8) + i) % 26) + (basis as u8)) as char
} else {
c
}
}
pub fn rotate(s: &str, i: u8) -> String {
s.chars().map(|c| rotate_char(c, i)... |
// error-pattern:error: type mismatch resolving `<u16 as conv::ValueFrom<i8>>::Err == conv::errors::NoError`
extern crate chomp;
use chomp::{Input, U8Result, parse_only};
use chomp::ascii::{signed, decimal};
// Should not be possible to use unsigned integers with signed
fn parser(i: Input<u8>) -> U8Result<u16> {
... |
// Adam Colton 2021
//! Defines structs to hold thermodynamic entities to be simulated.
use std::f64::consts::PI;
const WATER_SPECIFIC_HEAT: f64 = 4181.3f64; // J / kg K
const WATER_DIFFUSIVITY: f64 = 1.4e-7; // m^2 / second
const WATER_CONDUCTIVITY: f64 = 0.5918; // W / m * Kelvin
/// A thermodynamic entity that con... |
use std::error::Error;
use std::fmt;
use std::string::String;
#[derive(Debug)]
pub struct TokenizationError {
message: String
}
impl TokenizationError {
pub fn new<S: Into<String>>(message: S) -> TokenizationError {
TokenizationError{message: message.into()}
}
}
impl Error for TokenizationError {... |
use crate::devices::prelude::*;
use crate::devices::i2c::I2CDevice;
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
enum I2COp {
Read,
Write,
}
impl I2COp {
fn into_bit(self) -> bool {
match self {
I2COp::Read => true,
I2COp::Write => false,
}
}
fn from_bit(b... |
// Copyright (c) The Libra Core Contributors
// SPDX-License-Identifier: Apache-2.0
use super::dispatch::NativeReturnStatus;
use crate::value::Local;
use bitcoin_hashes::{hash160, sha256, Hash};
use std::{borrow::Borrow, collections::VecDeque};
use tiny_keccak::Keccak;
use types::byte_array::ByteArray;
const HASH_LEN... |
use crate::*;
/// Immutable `Arrav` iterator
///
/// This struct is created using [`Arrav::iter`].
#[derive(Debug, Copy, Clone)]
pub struct ArravIter<T, const N: usize>
where
T: Copy + Sentinel,
[T; N]: core::array::LengthAtMost32,
{
v: Arrav<T, N>,
at: usize,
}
impl<T, const N: usize> IntoIterator fo... |
use crate::{get_attr_meta, CompileError, IdentCtx, MacroAttr};
use proc_macro2::{Ident, TokenStream};
use quote::__private::ext::RepToTokensExt;
use quote::quote;
use syn::NestedMeta::Lit;
use syn::__private::TokenStream2;
use syn::{ExprPath, NestedMeta, Variant};
impl CompileError {
/// This error constructor is ... |
use std::fs::{metadata, File};
use std::io::{BufReader, BufWriter};
use std::path::PathBuf;
use num::BigUint;
use serde::Deserialize;
use structopt::StructOpt;
use walkdir::WalkDir;
use stabchain::group::group_library::DecoratedGroup;
use stabchain::group::Group;
use stabchain::perm::export::{ClassicalPermutation, Ex... |
use anyhow::Result;
use findshlibs::{SharedLibrary, TargetSharedLibrary};
use libloading::{Library, Symbol};
use std::ffi::c_void;
use std::path::{Path, PathBuf};
use std::process::Command;
pub struct UnwindMap {
entries: Vec<UnwindEntry>,
}
impl UnwindMap {
pub fn load() -> Self {
let mut entries = v... |
use crate::{Tree, Entity};
/// Iterator for iterating through the ancestors of an entity
pub struct ParentIterator<'a> {
pub(crate) tree: &'a Tree,
pub(crate) current: Option<Entity>,
}
impl<'a> Iterator for ParentIterator<'a> {
type Item = Entity;
fn next(&mut self) -> Option<Entity> {
if le... |
use span::{Span, PositionedSpan};
#[derive(Clone)]
pub struct Page {
positioned_spans: Vec<PositionedSpan>,
}
impl Page {
pub fn new() -> Self {
Self {
positioned_spans: vec![],
}
}
pub fn render_spans(&mut self, spans: &[Span], start_x: f32, start_y: f32) {
let m... |
extern crate minifb;
use minifb::Key;
use std::env;
use std::io::stdout;
use std::io::Write;
use std::process;
use chip8rs::Config;
mod chip8;
use chip8::Chip8;
fn main() {
let config = Config::new(env::args()).unwrap_or_else(|err| {
eprintln!("Problem parsing arguments: {}", err);
process::exit... |
use machine::state::State;
use machine::behavior::is::control::bnpb;
pub fn pbnpb(state: &mut State, x: u8, y: u8, z: u8) {
bnpb(state, x, y, z);
}
|
pub trait DisplayWidth {
fn display_width(&self) -> usize;
}
impl DisplayWidth for str {
fn display_width(&self) -> usize {
unicode_width::UnicodeWidthStr::width_cjk(self)
}
}
impl DisplayWidth for char {
fn display_width(&self) -> usize {
unicode_width::UnicodeWidthChar::width_cjk(*se... |
use vecmath::Vector3;
use anim::RayTraceAnimation;
use color::RayTraceColor;
use light::RayTraceLight;
use ray::RayTraceRay;
pub struct RayTraceSpotLight {
position: Vector3<f64>,
anim_pos: Option<Box<RayTraceAnimation<Vector3<f64>>>>,
color: RayTraceColor
}
impl RayTraceSpotLight {
pub fn new(position: Vector3<... |
use crate::{consts::*, time::ControlledTime, types::SongConfig};
use bevy::prelude::*;
/// Handles all of the game's audio.
pub struct AudioPlugin;
impl Plugin for AudioPlugin {
fn build(&self, app: &mut AppBuilder) {
app.on_state_update(APP_STATE_STAGE, AppState::Game, start_song.system());
}
}
fn s... |
use std::cell::{Ref, RefMut};
use std::mem::transmute;
// TODO: Parameterize output lifetime instead of making it always 'static. This would require GAT
pub unsafe fn extend_lifetime<T: ExtendableLife>(r: T) -> T::Out {
r.extend_lifetime()
}
pub unsafe trait ExtendableLife {
type Out;
unsafe fn extend_... |
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
use rand::Rng;
use rocket::http::Status;
use chrono::Utc;
use rocket_prometheus::PrometheusMetrics;
use rocket::response::status::BadRequest;
use rocket::response::status;
use log::{info, error};
use once_cell::sync::Lazy;
use rocket_prome... |
#![cfg(test)]
use std::ops::Deref;
use r2d2;
use r2d2_redis::RedisConnectionManager;
use redis;
use env_loader;
use stats::Stats;
use shortener::{short, long};
fn create_fake_stats() -> Stats {
Stats {
refer: "zlnk.de".to_string(),
browser: "Firefox".to_string(),
os: "Linux".to_string(),
... |
use cgmath::Vector3;
use components;
use specs::{Join, ReadStorage, System, WriteStorage};
// Translates physical forces into transforms
pub struct PhysicsSys;
impl<'a> System<'a> for PhysicsSys {
type SystemData = (ReadStorage<'a, components::Physics>, WriteStorage<'a, components::Transform>);
fn ... |
use postoffice::resp;
use postoffice::server::{Request,Response};
use json::JsonValue;
pub fn init(req:Request,body:&JsonValue) -> Response {
let object = JsonValue::new_object();
return resp::data(req,object,false);
}
|
// Copyright Parity Technologies (UK) Ltd.
//
// 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 ... |
struct Solution;
use std::collections::VecDeque;
use util::*;
struct Pair {
tree: TreeLink,
level: usize,
}
impl Solution {
fn level_order_bottom(root: TreeLink) -> Vec<Vec<i32>> {
let mut levels: Vec<Vec<i32>> = vec![];
let mut queue: VecDeque<Pair> = VecDeque::new();
if root.is_s... |
// Copyright (c) 2017 FaultyRAM
//
// 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 t... |
use postgres::Error as PGError;
use snafu::Snafu;
use std::env::VarError;
use std::io::Error as IOError;
use std::path::PathBuf;
#[derive(Debug, Snafu)]
#[snafu(visibility(pub(crate)))]
pub enum Error {
#[snafu(display("{}", message))]
EnvErrorConfig { source: VarError, message: String },
#[snafu(display("... |
cfg! {
id: 0,
blocks: [
block! {
id: 0,
offset: 0,
ops: [],
in_jumps: [],
out_jumps: [],
in_cont: [],
out_cont: [(1, "default")]
},
block! {
id: 1,
offset: 0,
ops: [
... |
use std::str;
use common::{AudioType, GArg};
use expression::Expr;
pub fn check_garg_name(i: &[u8]) -> Result<GArg, String> {
let identifier = str::from_utf8(i).unwrap().to_lowercase();
match identifier.as_str() {
"size" => Ok(GArg::Size),
"width" => Ok(GArg::Width),
"r" => Ok(GArg::R),... |
use super::Scheduler;
use crate::run::{Dispatch, Mutation, System, SystemData};
use crate::storage::AllStorages;
use alloc::borrow::Cow;
use alloc::boxed::Box;
use alloc::vec::Vec;
use core::any::TypeId;
use hashbrown::hash_map::Entry;
pub trait IntoWorkload {
fn into_workload(name: impl Into<Cow<'static, str>>, s... |
static TESTNUMBER: u32 = 325489;
pub fn day() -> String {
//// Right side
//println!("Right Side");
//check_number(9);
//check_number(10);
//check_number(11);
//check_number(12);
//// Top Side
//println!("Top Side");
//check_number(13);
//check_number(14);
//check_number(15... |
/**
* [376] Wiggle Subsequence
*
* A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with one element and a sequence with two non-equal elements are tri... |
use crate::{tl_types::TLType, utils::MyResult};
const BOOL_TRUE: i32 = -1_720_552_011;
const BOOL_FALSE: i32 = -1_132_882_121;
impl TLType for bool {
fn tl_read(input: &mut std::io::Read) -> MyResult<Self> {
let code = i32::tl_read(input)?;
match code {
BOOL_FALSE => Ok(false),
... |
//! The `measures.rs` file contains the `Data` struct, dump of all metrics calculated for a given
//! rho. It also contains the `Mean` trait, where is defined the `calculate_mean()` function.
//! Finally it's also here that can be found all the function that compute theoretical values & graphs
/// The `Data` struct is... |
use super::utils::linked_list::ListNode;
pub struct Solution {}
impl Solution {
pub fn is_palindrome(head: Option<Box<ListNode>>) -> bool {
let len = Self::_get_list_len(&head);
let right = len / 2;
let left = len - right - 1;
let mut stack = Vec::new();
let mut i = 0;
... |
//! @brief Common functions used by tests
use {
cli_program_template::prelude::{
get_account_for, load_account, load_wallet, KEYS_DB, PROG_KEY,
},
sol_template_shared::ACCOUNT_STATE_SPACE,
solana_client::rpc_client::RpcClient,
solana_sdk::{
commitment_config::CommitmentConfig,
... |
// Copyright 2014-2016 Johannes Köster.
// Licensed under the MIT license (http://opensource.org/licenses/MIT)
// This file may not be copied, modified, or distributed
// except according to those terms.
//! # Rust-bio, a bioinformatics library for Rust.
//! This library provides implementations of many algorithms and... |
use sp_std::prelude::*;
use sp_std::fmt::{Debug, Formatter};
use codec::{Encode, Decode};
use crate::entities::ContractMethod;
use sp_std::fmt;
#[derive(Eq, Encode, Decode, PartialEq, Clone)]
pub struct BlockEvents {
pub(crate) block_number: u32,
pub(crate) methods: Vec<ContractMethod>
}
impl Debug for BlockEvents ... |
// Copyright © {{ "now" | date: "%Y" }} {{authors}}
//
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
//! PROGRAM-SUMMARY
pub fn hello(number: i32) -> i32 {
println!("Hello");
number
}
fn main() {
hello(1);
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_hello() {
assert_... |
use std::collections::HashMap;
use structopt::StructOpt;
use aoc2019::StandardOptions;
use aoc2019::intcode::{Executor, read_program_from_file};
use aoc2019::grid::{Grid, Direction, Location, xy};
use anyhow::Result;
fn try_move(m: &Executor, dir: Direction) -> Option<(Executor, bool)> {
use Direction::*;
le... |
fn main() {
let mut s = String::from("hello! world!");
let index = index_first_word(&s);
let first_word = first_word(&s);
println!("Last Index of first word {}", index);
println!("First word {}", first_word);
s.clear(); // now index is no longer valid
// uncommenting below leads to compi... |
extern crate bible_reference_rs;
extern crate chrono;
extern crate futures;
extern crate hyper;
extern crate postgres;
extern crate serde;
extern crate url;
#[macro_use]
extern crate serde_json;
mod models;
use bible_reference_rs::*;
use futures::future::{Future, FutureResult};
use hyper::service::{NewService, Service... |
#![no_std]
#![no_main]
#![feature(llvm_asm)]
#![feature(global_asm)]
#![feature(panic_info_message)]
use core::{fmt::{self, Write}, panic::PanicInfo};
mod lang_items;
mod sbi;
use crate::sbi::sbi_call;
global_asm!(include_str!("entry.asm"));
#[no_mangle]
pub fn rust_main() -> ! {
extern "C" {
fn stext(... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::module::map_err;
use bcs_ext::BCSCodec;
use futures::future::TryFutureExt;
use futures::FutureExt;
use starcoin_abi_resolver::ABIResolver;
use starcoin_crypto::HashValue;
use starcoin_dev::playground::view_resource;
use s... |
//! I2C support
pub use crate::iomuxc::i2c::module;
use crate::ccm;
use crate::iomuxc::{daisy, i2c};
use core::marker::PhantomData;
use embedded_hal::blocking;
use imxrt1062_pac as pac;
use pac::lpi2c1::msr;
/// Unclocked I2C modules
///
/// The `Unclocked` struct represents all four unconfigured I2C peripherals.
//... |
use crate::Solution;
use std::{cell::RefCell, collections::HashMap};
use std::{convert::TryInto, rc::Rc};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
#[inline]
pub fn... |
pub mod endpoint;
pub mod parser;
mod tests; |
use crate::helpers::v2t;
#[derive(Clone, Copy)]
struct Range(u32, u32);
impl Range {
fn from(data: &str) -> Range {
let x = v2t(data
.split("-")
.map(&str::parse)
.map(Result::unwrap)
.collect()
);
Range(x.0, x.1)
}
fn contains(&sel... |
use bincode::Options;
use serde::*;
use serde::de::{DeserializeOwned, Visitor, Error as DeError, SeqAccess};
use serde::de::value::SeqAccessDeserializer;
use serde_bytes::ByteBuf;
use std::any::Any;
use std::sync::Arc;
use sylphie_core::prelude::*;
use sylphie_utils::scopes::*;
use sylphie_utils::strings::StringWrapper... |
//! extern_crate_num_traits
extern crate libc;
extern crate f128 as float128;
extern crate num_traits;
use long_double::{rust_long_double_ops, rust_cast2double, rust_cast2float, rust_cast2uint, rust_ld1, rust_ld2};
use self::float128::f128;
use self::libc::{c_double, c_float, c_uint};
pub fn test_long_double_ops() {... |
fn main() {
println!("Hello, cruel world!");
}
|
pub mod store;
pub mod service;
|
// Copyright 2019-2021 Thales Inc.
// This file is part of Thales.
// Thales is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Th... |
pub use crate::tds::stream::{QueryItem, ResultMetadata};
use crate::{
client::Connection,
tds::stream::{ReceivedToken, TokenStream},
};
use futures::{AsyncRead, AsyncWrite, TryStreamExt};
use std::fmt::Debug;
/// A result from a query execution, listing the number of affected rows.
///
/// If executing multipl... |
use nom;
use frame::*;
use protocol::*;
use protocol::basic::parse_properties;
use types::parsing::*;
named!(pub parse_channel<AMQPChannel>, map!(parse_id, From::from));
named!(pub parse_protocol_header, do_parse!(
tag!(metadata::NAME.as_bytes()) >>
tag!... |
use serenity::client::Context;
use serenity::framework::standard::{macros::command, CommandResult};
use serenity::model::prelude::Message;
use regex::Regex;
use lazy_static::lazy_static;
use systemstat::{saturating_sub_bytes, Platform, System};
use super::helpers::{get_version, send_text};
lazy_static! {
stati... |
use crate::shared::{
cq::backend::MessageType,
domain::{
backend::queues::{
ACCOUNT_BUYER_QUEUE, ACCOUNT_COURIER_QUEUE, ACCOUNT_EVENTS_QUEUE,
ACCOUNT_GENERAL_QUEUE, ACCOUNT_SELLER_QUEUE,
},
DomainConfig,
},
};
use std::collections::HashMap;
pub mod controller... |
use std::{iter::repeat, mem::replace};
use super::{CVec, OutputSet, MAX_CHANNELS};
#[derive(Copy, Clone)]
enum UndoAction {
Matching {
channels: [usize; 2],
},
Swap {
target_channel: usize,
source_channels: [usize; 2],
},
}
pub struct Subsume {
channels: usize,
output_... |
// Copyright 2020-2022 The NATS 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 required by applicable law or agreed to ... |
use super::*;
pub trait Game
{
fn build(app: &mut Application) -> Self;
} |
impl Solution {
pub fn gray_code(n: i32) -> Vec<i32> {
let mut res = Vec::new();
res.push(0);
res.push(1);
let mut bit = 1;
for _ in 1..n {
bit <<= 1;
let size = res.len();
for i in (0..size).rev() {
let it = res[i];
... |
use std::collections::HashMap;
impl Solution {
pub fn find_judge(n: i32, trust: Vec<Vec<i32>>) -> i32 {
let mut graph: HashMap<i32, Vec<i32>> = HashMap::new();
for i in 0..trust.len() {
let u = trust[i][0];
let v = trust[i][1];
graph.entry(u).or_insert(Vec::new()... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.