text stringlengths 8 4.13M |
|---|
extern crate proconio;
use proconio::input;
fn main() {
input! {
n: i64,
a: i64,
b: i64,
}
let tak = "Takahashi";
let aok = "Aoki";
if a >= n {
println!("{}", tak);
return;
}
if a == b {
println!("{}", if n % (a + 1) != 0 { tak } else { aok });
... |
#[doc = "Reader of register BMTRGR"]
pub type R = crate::R<u32, super::BMTRGR>;
#[doc = "Writer for register BMTRGR"]
pub type W = crate::W<u32, super::BMTRGR>;
#[doc = "Register BMTRGR `reset()`'s with value 0"]
impl crate::ResetValue for super::BMTRGR {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use super::*;
pub struct RootedSlotIterator<'a> {
next_slots: Vec<u64>,
blocktree: &'a super::Blocktree,
}
impl<'a> RootedSlotIterator<'a> {
pub fn new(start_slot: u64, blocktree: &'a super::Blocktree) -> Result<Self> {
if blocktree.is_root(start_slot) {
Ok(Self {
next_... |
use std::io::Write;
use crate::tftp::shared::{
Deserializable, Serializable, TFTPPacket, TFTPParseError, OP_DATA, OP_LEN,
};
use super::byteorder::{ByteOrder, NetworkEndian, WriteBytesExt};
const BLK_NUM_LEN: usize = 2;
const DATA_MAX_LEN: usize = 512;
#[derive(Debug, Eq, PartialEq)]
pub struct DataPacket {
... |
#[macro_use]
extern crate error_chain;
extern crate glib_sys as glib_ffi;
extern crate gtk_sys as ffi;
extern crate glib;
extern crate gtk;
extern crate sourceview;
extern crate syntex_syntax;
extern crate syntex_pos;
mod echain;
mod gui;
mod visitor;
mod tree_column_set_data_func_ext;
mod ast_model_extensions;
fn ma... |
//! The `block_tree` module provides functions for parallel verification of the
//! Proof of History ledger as well as iterative read, append write, and random
//! access read to a persistent file-based ledger.
use crate::entryInfo::Entry;
use crate::expunge::{self, Session};
use crate::packet::{Blob, SharedBlob, BLOB_... |
use projecteuler::binomial;
fn main() {
dbg!(solve(2));
dbg!(solve(20));
}
fn solve(n: usize) -> usize {
binomial::binomial_coefficient(2 * n, n)
}
|
use std::fs::read_to_string;
fn read_param(prog: &Vec<i32>, base: i32, pos: usize, i: usize) -> i32 {
match prog[pos] / 10_i32.pow(i as u32 + 1) % 10 {
0 => prog[prog[pos + i] as usize],
1 => prog[pos + i],
2 => prog[(base + prog[pos + i]) as usize],
_ => panic!("invalid parameter mode"),
}
}
fn ... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtGui/qpen.h
// dst-file: /src/gui/qpen.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= main bloc... |
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
import std.map.hashmap;
import std.option;
import std._vec;
import util.common.span;
import util.common.spanned;
import util.common.ty_mach;
import util.common.filename;
import util.typestate_ann.ts_ann;
type ident = str;
type path_ = rec(vec[ident] idents, vec[@ty] types);
type path = spanned[path_];
type crate_nu... |
use super::request_handler::RequestHandler;
use bytesize::ByteSize;
use std::time::Duration;
/// Configuration for the server.
pub struct Config<R: RequestHandler> {
/// Handler for push and request.
pub request_handler: R,
/// Maximum size of the payload part of a loqui frame.
pub max_payload_size: By... |
fn main() {
println!("--output--");
for (i, arg) in std::env::args().enumerate() {
println!("{:>4}: {:?}", format!("[{}]", i), arg);
}
}
|
use rotor_http;
|
fn main(){
proconio::input!{n:u64,k:u64};
let m = n % k;
println!("{}",m.min(k-m))
} |
use crate::{RAMCORE_SYMBOL, RAMMARKET, SELF};
use eosio::*;
use eosio_cdt::*;
use lazy_static::lazy_static;
/// Defines new global state parameters.
/// <https://github.com/EOSIO/eosio.contracts/blob/v1.9.0-rc3/contracts/eosio.system/include/eosio.system/eosio.system.hpp#L120-L145>
#[derive(Table, Read, Write, NumByte... |
use std::{cell::RefCell, rc::Rc};
pub struct LinkedList<T: Clone + Default> {
head: Option<Rc<RefCell<Node<T>>>>,
tail: Option<Rc<RefCell<Node<T>>>>,
}
#[derive(Clone)]
pub struct Node<T: Clone + Default> {
pub value: T,
next_node: Option<Rc<RefCell<Node<T>>>>,
prev_node: Option<Rc<RefCell<Node<T>>... |
use std::str::FromStr;
use std::string::ToString;
use std::sync::Arc;
mod original;
pub use original::*;
mod mobility;
pub use mobility::*;
mod flood;
pub use flood::*;
mod random;
pub use random::*;
pub mod maxn;
mod solo;
pub use solo::*;
use crate::game::Game;
use super::env::{GameRequest, MoveResponse};
const M... |
#![deny(unreachable_code)]
// ^^^^^^^^^^^^^^^^NOTE lint level defined here
pub mod remote_note_1_mod;
|
#![feature(box_raw)]
#![feature(associated_consts)]
use std::ops::Deref;
use std::vec::Vec;
use std::collections::HashMap;
struct Heap {
ptrs: HashMap<usize, bool>
}
struct GcBox<T> {
value: *mut T
}
impl <T> GcBox<T> {
fn new(value: T) -> GcBox<T> {
GcBox{value: Box::into_raw(Box::new(value)... |
#[macro_use] extern crate lazy_static;
extern crate regex;
use regex::Regex;
use std::collections::HashMap;
use BalanceResult::*;
#[derive(Eq, PartialEq, Debug)]
pub enum BalanceResult<'a> {
Balanced(usize),
Unbalanced(&'a str, usize),
}
pub struct ProgramAnalyzer {
programs: HashMap<String, (usize, Vec... |
#![warn(clippy::all)]
#![warn(missing_docs)]
//! [](https://travis-ci.org/danieleades/harbourmaster)
//! [](https://docs.rs/harbourmaster/)
//!
//! Harbourmaster is a library of high... |
// Copyright (c) 2020, KTH Royal Institute of Technology.
// SPDX-License-Identifier: AGPL-3.0-only
//! Example Arc-Script code which should be translated into
//! something which resembles this file. NB: `--` are Arc-Script comments.
//!
//! ```txt
//! type MyData = { i:i32, f:f32 };
//!
//! task MyOperator() (In(MyD... |
extern crate dtlib;
extern crate clap;
use clap::*;
use dtlib::*;
fn main() {
let yaml = load_yaml!("opts.yml");
let matches = App::from_yaml(yaml)
.author(crate_authors!())
.version(crate_version!())
.get_matches();
if let Some(matches) = matches.subcommand_matches("uid") {
... |
pub mod simulator;
pub mod surface;
pub mod common;
mod tracer;
|
#[derive(Debug)]
enum IpAddrKind {
V4,
V6,
}
#[derive(Debug)]
struct IpAddr {
kind: IpAddrKind,
address: String,
}
fn main() {
let four = IpAddrKind::V4;
println!("{:?}", four);
let loopback = IpAddr {
kind: IpAddrKind::V6,
address: String::from("::1"),
};
println!("{:?}", loopback... |
use crate::{HdbError, HdbResult};
// Read n bytes, return as Vec<u8>
pub(crate) async fn parse_bytes<R: std::marker::Unpin + tokio::io::AsyncReadExt>(
len: usize,
rdr: &mut R,
) -> HdbResult<Vec<u8>> {
let mut vec: Vec<u8> = std::iter::repeat(255_u8).take(len).collect();
{
let rf: &mut [u8] = &... |
#[macro_use]
mod common;
use common::util::*;
static UTIL_NAME: &'static str = "head";
static INPUT: &'static str = "lorem_ipsum.txt";
#[test]
fn test_stdin_default() {
let (at, mut ucmd) = testing(UTIL_NAME);
let result = ucmd.run_piped_stdin(at.read(INPUT));
assert_eq!(result.stdout, at.read("lorem_i... |
// This file is part of linux-epoll. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-epoll/master/COPYRIGHT. No part of linux-epoll, including this file, may be copied, modified, propagated, or distri... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtGui/qguiapplication.h
// dst-file: /src/gui/qguiapplication.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block be... |
/*************************************************************************
* ph0llux:24efd740f491bae39a06ceb74c1f642f8d93b8e4aebdf03f95e32031b4f7ceea
*************************************************************************/
// - external
use base64::{encode};
use hex::ToHex as HexToHex;
pub trait ToBase64 {
/// met... |
use std::ops::{Add, Div, Range};
use std::cmp::max;
use num::{Integer, NumCast};
trait Midpoint<T> {
fn midpoint(&self) -> T;
}
impl<T> Midpoint<T> for Range<T>
where T: Add<Output = T> + Div<Output = T> + Copy + Integer + NumCast {
fn midpoint(&self) -> T {
return (self.start + self.end) / NumCast:... |
use winnow::combinator::alt;
use winnow::combinator::fail;
use winnow::combinator::peek;
use winnow::token::any;
use crate::parser::array::array;
use crate::parser::datetime::date_time;
use crate::parser::inline_table::inline_table;
use crate::parser::numbers::{float, integer};
use crate::parser::prelude::*;
use crate... |
use std::path::PathBuf;
#[ derive (Debug, Deserialize, Serialize) ]
pub struct FileDataRecord {
pub path: PathBuf,
pub size: u64,
#[ serde (skip_serializing_if = "Option::is_none") ]
pub content_hash: Option <String>,
#[ serde (skip_serializing_if = "Option::is_none") ]
pub content_hash_time: Opti... |
#![ allow( non_snake_case ) ]
use std::fs;
use serial_test::*;
use lt_blockchain::blockchain::{ digest, system };
//
#[ test ]
#[ ignore ]
fn new()
{
/*
issue : https://github.com/Learn-Together-Pro/Blockchain/issues/33
To run test enter :
cargo test system_test::new -- --ignored
When test will... |
#[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 {
0
}
}
#[doc = "Write proxy for field `CRXBFF`"]
pub struct CRXBF... |
use std::{thread, time::Duration};
use opencv::{
core,
highgui,
imgproc,
prelude::*,
types,
videoio,
};
fn make_veci32(i: i32) -> types::VectorOfi32 {
let mut result = types::VectorOfi32::with_capacity(1);
result.push(i);
return result;
}
fn make_vecf32(v0: f32, v1: f32) -> types:... |
///! This module defines an error type which distinguishes between runtime and system exceptions.
///!
///! Errors which are part of the normal execution of an Erlang program are represented by the
///! `RuntimeException` type, while errors which are not recoverable from Erlang code are
/// represented ! by the `System... |
use std::marker::PhantomData;
use std::ops::Deref;
use super::body::Skeleton;
use super::error::{k4a_result, Error};
#[derive(Debug)]
pub struct Frame<'d> {
frame_handle: libk4a_sys::k4abt_frame_t,
_phantom: PhantomData<&'d ()>,
}
impl<'d> Frame<'d> {
/// # Safety
///
/// Ensure `frame_handle` is... |
use logging::data_types::TypeInfo;
use logging::{ self, LogStream };
use variable::Variable;
use std::io;
use serde::Serialize;
use std::fmt::Display;
pub fn create_log_for<'a, T>(var: &mut Variable<'a, T>, name: &str) -> io::Result<()>
where T: PartialEq + TypeInfo + Serialize + Display + Copy + 'a {
let path = ... |
#[macro_use]
mod card;
mod actor;
use actor::{Actor, JawWorm};
use card::{CardTemplate, CardType, Effect, Target, CARDS};
use mcts::tree_policy::*;
use mcts::*;
use rand::rngs::SmallRng;
use rand::Rng;
use rand::{FromEntropy, SeedableRng, XorShiftRng};
use std::mem;
#[derive(Clone, PartialEq)]
pub struct Card {
id... |
pub mod block_source;
pub mod broadcaster;
pub mod fee_estimator;
|
// digit_index * 2 > input_length so the only Patterns for digit_index are 0 for input[0..digit_index] and 1 for input[digit_index..input_length]
// So the sum for digit_index is the sum of input[digit_index..input_length]
// The sum for digit_index+1 is just the (sum for digit_index) - input[digit_index] (starting fro... |
//! Make a block out of parsed RLE code.
use std::ops::Range;
use crate::{Block, Hashlife};
use crate::leaf::{Leaf, LEAF_SIZE, LEAF_Y_SHIFT, LEAF_X_SHIFT};
use crate::util::make_2x2;
use super::parse::{RLE, RLEEncode, RLEToken, State};
fn expand_rle<A:Clone>(rle: &RLEEncode<A>) -> Vec<A> {
use std::iter;
rle... |
use crate::ast;
use crate::{Parse, Spanned, ToTokens};
/// A `yield [expr]` expression to return a value from a generator.
///
/// # Examples
///
/// ```rust
/// use rune::{testing, ast};
///
/// testing::roundtrip::<ast::ExprYield>("yield");
/// testing::roundtrip::<ast::ExprYield>("yield 42");
/// testing::roundtrip... |
//! System Configuration service.
//!
//! This module contains basic methods to retrieve the console's system configuration.
#![doc(alias = "configuration")]
use crate::error::ResultCode;
/// Console region.
#[doc(alias = "CFG_Region")]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[repr(u32)]
pub enum Region {
/... |
// Copyright 2021 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... |
// TODO: module docs
pub extern crate rendy_command as command;
pub extern crate rendy_memory as memory;
pub extern crate rendy_resource as resource;
extern crate winit;
#[macro_use]
extern crate derivative;
#[cfg(feature = "hal")]
pub extern crate gfx_hal as hal;
#[cfg(feature = "ash")]
pub extern crate ash;
mod... |
use crate::*;
use ark_crypto_primitives::{Error, CRH as CRHTrait};
use ark_ff::{BigInteger, PrimeField};
use arkworks_gadgets::poseidon::{circom::CircomCRH, sbox::PoseidonSbox, PoseidonParameters, Rounds, CRH};
use sp_std::{marker::PhantomData, vec::Vec};
#[derive(Default, Clone, Copy)]
pub struct PoseidonRounds3x5;
#... |
use crate::lttp::{
AppState,
GameState,
};
use anyhow::{
anyhow,
Context,
Result,
};
use std::{
convert::TryFrom,
sync::Arc,
};
use tracing::{
debug,
info,
};
#[tracing::instrument(skip(app_state), err)]
pub async fn poll_status(app_state: Arc<AppState>, device: &str) -> Result<()>... |
use super::*;
pub async fn do_write(fd: FileDesc, buf: &[u8]) -> Result<usize> {
debug!("write: fd: {}", fd);
let file_ref = current!().file(fd)?;
file_ref.write(buf).await
}
pub async fn do_writev(fd: FileDesc, bufs: &[&[u8]]) -> Result<usize> {
debug!("writev: fd: {}", fd);
let file_ref = curren... |
#[doc = "Reader of register APB_FZ1"]
pub type R = crate::R<u32, super::APB_FZ1>;
#[doc = "Writer for register APB_FZ1"]
pub type W = crate::W<u32, super::APB_FZ1>;
#[doc = "Register APB_FZ1 `reset()`'s with value 0"]
impl crate::ResetValue for super::APB_FZ1 {
type Type = u32;
#[inline(always)]
fn reset_va... |
mod adventofcode;
use adventofcode::load_file;
#[cfg(test)]
mod tests {
use spreadsheet_sum;
#[test]
fn test1() {
let input = r#"5 9 2 8
9 4 7 3
3 8 6 5"#;
assert_eq!(spreadsheet_sum(&input), 9);
}
}
fn spreadsheet_sum(input: &str) -> i32 {
let mut sum = 0;
for line in in... |
pub mod dir;
pub mod error;
|
use bytes::Buf;
use iovec::IoVec;
/// A `Buf` wrapping a static byte slice.
#[derive(Debug)]
pub(crate) struct StaticBuf(pub(crate) &'static [u8]);
impl Buf for StaticBuf {
#[inline]
fn remaining(&self) -> usize {
self.0.len()
}
#[inline]
fn bytes(&self) -> &[u8] {
self.0
}
... |
extern crate json;
use std::io;
fn main() {
// Explicit type declaration
let s_ref: &str = "ba";
// Type inference
let mut s = String::from("hi there");
// Print to stdout
println!("Hello, world! {} {}", s_ref, s);
// Format to string
let x: &str = format!("This is me {}", "really");... |
#[doc = "Reader of register EV_PENDING"]
pub type R = crate::R<u8, super::EV_PENDING>;
#[doc = "Writer for register EV_PENDING"]
pub type W = crate::W<u8, super::EV_PENDING>;
#[doc = "Register EV_PENDING `reset()`'s with value 0"]
impl crate::ResetValue for super::EV_PENDING {
type Type = u8;
#[inline(always)]
... |
use crate::error::SymbolError;
/// # symbol - Interned, Unicode symbolic atoms (aka identifiers)
///
/// symbol - Interned, Unicode symbolic atoms (aka identifiers)
/// A subset of symbols called identifiers can be denoted in text without single-quotes.
/// An identifier is a sequence of ASCII letters, digits, or the
... |
use crate::auth;
use crate::diesel::QueryDsl;
use crate::diesel::RunQueryDsl;
use crate::handlers::types::*;
use crate::helpers::aws;
use crate::model::{Space, SpaceUser, User};
use crate::schema::spaces::dsl::*;
#[allow(unused_imports)]
use crate::schema::spaces_channel::dsl::space_id as channel_space_id;
use crate::s... |
//! The ecs module defines the Ecs struct which is the main entry point of tuber-ecs
use std::any::{Any, TypeId};
use std::cell::{Ref, RefCell, RefMut};
use std::collections::{HashMap, HashSet};
use crate::bitset::BitSet;
use crate::query::{ComponentTypeId, Query, QueryIterator, QueryIteratorByIds};
use crate::Entity... |
//! Miscellaneous system related functionality.
//!
//! Other than the extern portion of this module, this is basically a really poorly done
//! https://github.com/nix-rust/nix clone. Use that instead :)
#![allow(unsafe_code)]
use libc;
use std::fs;
use std::ffi::{CString, CStr};
use std::ptr;
use std::env;
// XXX: I'... |
use std::fs::File;
use std::process;
use gif::SetParameter;
use png::ColorType::{Grayscale, GrayscaleAlpha, RGB, RGBA};
use crate::cmd_options::CmdOptions;
pub struct OutputInfo {
pub width: u32,
pub height: u32,
}
pub fn create_canvas(file: &File, options: &CmdOptions) -> Vec<Vec<(u8, u8, u8)>> {
let (... |
pub struct Solution;
#[derive(Debug, PartialEq, Eq)]
pub struct TreeNode {
pub val: i32,
pub left: Tree,
pub right: Tree,
}
use std::cell::RefCell;
use std::rc::Rc;
type Tree = Option<Rc<RefCell<TreeNode>>>;
impl Solution {
pub fn zigzag_level_order(root: Tree) -> Vec<Vec<i32>> {
let mut res... |
use huffman::*;
use binary_writer::*;
use std::io::{Read, Write, Bytes, BufReader};
use std::fs::File;
pub fn read_freq_table<R: Read>(input: &mut Bytes<R>) -> [u64; 256] {
let mut freq_table = [0; 256];
while let Some(Ok(x)) = input.next() {
freq_table[x as usize] += 1;
}
freq_table
}
fn dfs... |
// =========
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use std::process::exit;
const MOD: usize = 1000000007;
pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);
impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
pub fn new(r: R, w: W) -> IO<R, W> {
IO(r, std::io::B... |
use std::io::prelude::*;
fn main() {
println!("Starting server...");
let server = std::net::TcpListener::bind("127.0.0.1:8080").unwrap();
println!("Server is up {:?}", server);
loop {
match server.accept() {
Ok((mut stream, origin)) => {
let mut buffer = [0; 1024];
... |
macro_rules! syntax_error {
($($arg:tt)*) => (
return Err(BadSyntax(format!("{}: {}", $($arg)*)))
)
}
pub mod interpreter;
pub mod value;
pub mod error;
mod data;
mod base;
mod reader;
mod env;
mod machine;
use scheme::error::LispError;
pub const UNDERSCORE: &str = "_";
pub const ELLIPSIS: &str = "..... |
#![warn(clippy::all)]
#![warn(clippy::pedantic)]
use factorial::Factorial;
fn main() {
run();
}
#[allow(clippy::cast_possible_truncation)]
#[allow(clippy::similar_names)]
fn run() {
let start = std::time::Instant::now();
// code goes here
let digits = nth_lexicographic_permutation(999_999, &mut vec![0, 1, 2... |
use std::cmp;
use petgraph::{Graph, Directed};
use petgraph::visit::GetAdjacencyMatrix;
use super::graph::{Node, Edge};
use super::cycle_removal::remove_cycle;
use super::ranking::{RankingModule, LongetPathRanking};
use super::crossing_reduction::crossing_reduction;
use super::position_assignment::brandes::brandes;
use... |
use core::{Model, Material, RayIntersection, Ray, RayIntersectionError};
use defs::{Point3, Vector3, FloatType};
use tools::{CompareWithTolerance};
use na;
use na::{Unit};
use std;
use uuid::{Uuid};
pub struct SolidSphere {
material: Material,
origo: Point3,
radius: FloatType,
identifier: Uuid
}
impl ... |
extern crate nom;
use std::collections::HashSet;
pub mod abssyn;
use self::abssyn::*;
pub mod substitution;
use self::substitution::*;
pub mod parser;
use self::parser::*;
#[derive(Clone, Debug, PartialEq, Eq)]
enum FContextElem {
HasType(String, FType),
TyVar(String),
}
fn typeinfer(ctx: &[FContextElem],... |
use crate::models::apod::Apod;
use crate::services::DB;
use chrono::NaiveDate;
use sqlx::postgres::PgQueryResult;
#[derive(Debug, sqlx::FromRow)]
pub struct DBApod {
pub id: i32,
pub publish_date: NaiveDate,
pub explanation: String,
pub title: String,
pub hdurl: String,
pub copyright: Option<St... |
//! Osu skin directory parser module
// TODO add support for hd textures (scaling shouldn't be an issue, just finding them and loading
// them which shouldn't be hard but I'm just lazy
use graphics::{
draw_state::{self, DrawState},
image::Image,
math, Graphics,
};
use texture::{CreateTexture, Format, Imag... |
fn accept(s: &str) {
println!("{}", s);
}
fn main() {
let l_j: &str = "Linux Journal";
let magazine: &'static str = "magazine";
let my_str = format!("Hello {} {}!", l_j, magazine);
println!("my_str L:{} C:{}", my_str.len(), my_str.capacity());
for c in my_str.chars() {
print!("{} ", c)... |
// 1649. Create Sorted Array through Instructions
// https://leetcode.com/problems/create-sorted-array-through-instructions/
pub struct Solution;
const MODULO: i32 = 1_000_000_007;
#[cfg(disable)]
impl Solution {
pub fn create_sorted_array(instructions: Vec<i32>) -> i32 {
let mut res = Vec::with_capacity... |
use std::cell::RefCell;
#[allow(unused_imports)]
use std::ops::DerefMut;
use winnow::combinator::cut_err;
use winnow::combinator::delimited;
use winnow::combinator::peek;
use winnow::token::take;
// https://github.com/rust-lang/rust/issues/41358
use crate::parser::key::key;
use crate::parser::prelude::*;
use crate::p... |
//! Operator and utilities to source data from the underlying Timely
//! logging streams.
use std::collections::HashMap;
use std::time::Duration;
use timely::communication::message::RefOrMut;
use timely::dataflow::channels::pact::Pipeline;
use timely::dataflow::operators::capture::Replay;
use timely::dataflow::operat... |
#![deny(warnings)]
extern crate futures;
extern crate tokio_mock_task;
extern crate tokio_sync;
use tokio_mock_task::*;
use tokio_sync::semaphore::{Permit, Semaphore};
macro_rules! assert_ready {
($e:expr) => {{
match $e {
Ok(futures::Async::Ready(v)) => v,
Ok(_) => panic!("not re... |
use quote::{quote, quote_spanned};
use syn::{parse_macro_input, spanned::Spanned, Data, DeriveInput};
#[proc_macro_derive(ToProtobuf, attributes(protobuf))]
pub fn derive_to_protobuf(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let input = parse_macro_input!(input as DeriveInput);
derive_to_pr... |
// #[allow(dead_code)]
// #[derive(Debug)]
// enum Direction {
// Up(Point),
// Down(Point),
// Left(Point),
// Right(Point),
// }
// #[derive(Debug)]
// enum Keys {
// UpKey(String),
// DownKey(String),
// LeftKey(String),
// RightKey(String),
// }
// impl Direction {
// fn match_... |
use super::{PyBoundMethod, PyStr, PyType, PyTypeRef};
use crate::{
class::PyClassImpl,
common::lock::PyMutex,
types::{Constructor, GetDescriptor, Initializer, Representable},
AsObject, Context, Py, PyObjectRef, PyPayload, PyRef, PyResult, VirtualMachine,
};
/// classmethod(function) -> method
///
/// C... |
mod encoder;
mod decoder;
mod header;
mod huffman;
mod table;
#[cfg(test)]
mod test;
pub use self::decoder::{Decoder, DecoderError, NeedMore};
pub use self::encoder::{Encode, EncodeState, Encoder, EncoderError};
pub use self::header::Header;
|
use core::JsRuntime;
use core::ModuleSpecifier;
use core::RuntimeOptions;
use futures;
use std::path::Path;
fn main() {
let mut runtime = JsRuntime::new(RuntimeOptions {
module_loader: Some(std::rc::Rc::new(core::FsModuleLoader)),
..Default::default()
});
let js_path = Path::new(env!("CARGO_MANIFEST_DIR... |
use alloc::string::String;
use crate::numeric_traits::*;
use crate::options::FormatSizeOptions;
use crate::ISizeFormatter;
pub fn format_size_i(input: impl ToF64, options: impl AsRef<FormatSizeOptions>) -> String {
format!("{}", ISizeFormatter::new(input, options))
}
pub fn format_size(input: impl ToF64 + Unsign... |
use crate::lexer::*;
use crate::parsers::expression::argument::indexing_argument_list;
use crate::parsers::expression::method::method_invocation_without_parenthesis;
use crate::parsers::expression::operator_expression;
use crate::parsers::expression::primary_expression;
use crate::parsers::expression::variable::variabl... |
// 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.
/// These modules provide access to the component storage.
pub mod stash;
mod keys;
mod serde;
|
mod nix;
mod package;
mod sources;
use color_eyre::eyre;
use eyre::{Report, Result};
use tracing::instrument;
use std::path::{Path, PathBuf};
/*
for reading json AST
https://astexplorer.net
*/
const PATH_TO_EXAMPLE_TOML: &str = "./data/example_config.toml";
#[instrument]
#[tokio::main]
async fn main() -> R... |
use byteorder::{LittleEndian, ByteOrder};
use std::fmt;
pub struct Instr(pub Op, pub Mode, pub Cycles);
impl Instr {
pub fn from(code: &[u8]) -> Instr {
let opcode = code[0];
let oper = &code[1..];
match opcode {
0x00 => Instr(Op::Brk, Mode::Impl, Cycles::A(7)),
0x01... |
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// 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 ... |
extern crate rustpusher_cpu;
#[macro_use]
extern crate libretro_backend;
use rustpusher_cpu::*;
use libretro_backend::*;
pub struct RPCore {
cpu: Cpu,
palette: [(u8, u8, u8, u8); 256],
video_buffer: [u8; BANK * 4],
audio_buffer: Vec<(i16, i16)>,
game_data: Option<GameData>,
}
impl RPCore {
fn... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qtabbar.h
// dst-file: /src/widgets/qtabbar.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
/... |
pub mod cpu;
pub mod gui;
pub mod ines;
pub mod png;
pub mod ppu;
mod apu;
mod gamepad;
mod kevtris;
mod mapper;
mod record;
|
use crate::types::*;
use neo4rs_macros::BoltStruct;
#[derive(Debug, PartialEq, Clone, BoltStruct)]
#[signature(0xB1, 0x7F)]
pub struct Failure {
metadata: BoltMap,
}
impl Failure {
pub fn get<T: std::convert::TryFrom<BoltType>>(&self, key: &str) -> Option<T> {
self.metadata.get(key)
}
}
#[cfg(tes... |
pub fn nth(n: u32) -> u32 {
let mut primes = Vec::new();
let mut num = 2;
while primes.len() <= n as usize {
if is_prime(num, &primes) {
primes.push(num)
}
num += 1
}
primes.pop().unwrap()
}
fn is_prime(n: u32, primes: &[u32]) -> bool {
for i in primes {
... |
/**
* Copyright © 2019
* Sami Shalayel <sami.shalayel@tutamail.com>,
* Carl Schwan <carl@carlschwan.eu>,
* Daniel Freiermuth <d_freiermu14@cs.uni-kl.de>
*
* This work is free. You can redistribute it and/or modify it under the
* terms of the Do What The Fuck You Want To Public License, Version 2,
* as published... |
fn main() {
#macro([#trivial[], 1*2*4*2*1]);
assert(#trivial[] == 16);
}
|
//extern crate token;
#[test]
fn it_adds_two() {
assert_eq!(4, 4);
}
|
type Kilometers = i32;
fn main() {
let x: i32 = 5;
let y: Kilometers = 5;
println!("x + y = {}", x + y);
let _bs: Box<dyn std::fmt::Display> = Box::new(String::from("there"));
}
type Thunk = Box<dyn Fn() + Send + 'static>;
fn takes_long_type(f: Thunk) {
()
}
fn returns_long_type() -> Thunk {
... |
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
//
#![warn(missing_docs)]
//! # glTFVariantMeld
//!
//! ### Introduction
//!
//! This library exists to do one single thing: meld multiple glTF assets, each representing a
//! different *variant* of some basic model, into a single, compact format... |
use crate::error::GenericResult;
use crate::error::GenericError;
use crate::error::ErrorKind;
use super::map;
use super::state;
use std::convert::TryFrom;
use std::io::Write;
static UPDATE_RATES: f64 = 0.05;
/// Create or load the map
pub async fn get_map(conn: std::sync::Arc<aci::Connection>, options: &crate::args... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.