text stringlengths 8 4.13M |
|---|
use std::arch::x86_64::*;
use core::mem::transmute;
fn main() {
let input = include_bytes!("explore.in");
let mut input_vec: [__m256i; 2] = unsafe { core::mem::zeroed() };
let mut prev_ov = 0;
let mut whitespace = 0;
let mut structurals = 0;
let mut ptr = input.as_ptr();
for _ in 0..64 {
... |
use std::cell::RefCell;
use std::rc::Rc;
pub enum ParseResult {
Parsed,
Help,
Exit,
Error(String),
}
pub enum Action<'a> {
Flag(Box<IFlagAction + 'a>),
Single(Box<IArgAction + 'a>),
Push(Box<IArgsAction + 'a>),
Many(Box<IArgsAction + 'a>),
}
pub trait TypedAction<T> {
fn bind<'x>... |
use std::collections::HashMap;
use handlebars::Handlebars;
use serde::Serialize;
/// Indicates whether the user agent should send or receive user credentials
/// (cookies, basic http auth, etc.) from the other domain in the case of
/// cross-origin requests.
#[derive(Serialize)]
#[serde(rename_all = "kebab-case")]
pu... |
use super::input::Input;
use crate::coverage::Coverage;
use candy_frontend::hir::Id;
use candy_vm::{
self,
channel::Packet,
execution_controller::{CountingExecutionController, ExecutionController},
fiber::{EndedReason, Fiber, FiberId, InstructionPointer, Panic, VmEnded},
heap::{
DisplayWithS... |
use std::fmt;
use std::iter::FromIterator;
use nom::branch::Alt;
use nom::error::{ContextError, ErrorKind, FromExternalError, ParseError};
use nom::sequence::Tuple;
use nom::{Err, IResult, Parser};
pub struct DynamicAlt<P>(Vec<P>);
impl<P> From<Vec<P>> for DynamicAlt<P> {
fn from(v: Vec<P>) -> Self {
Sel... |
extern crate serde;
#[macro_use]
extern crate serde_derive;
use std::io::prelude::*;
use std::io::BufReader;
use std::path::Path;
use std::fs::File;
use std::vec::Vec;
use std::error::Error;
use rand::thread_rng;;
use rand::seq::SliceRandom;
use rusty_machine;
use rusty_machine::linalg::Matrix;
use rusty_machine::lina... |
#![feature(associated_consts)]
#[macro_use]
extern crate log;
extern crate rand;
use rand::SeedableRng;
extern crate time;
use std::io;
use std::io::prelude::*;
mod go;
mod mcts;
mod gtp;
use log::{LogRecord, LogLevel, LogLevelFilter, LogMetadata};
struct SimpleLogger;
impl log::Log for SimpleLogger {
fn enable... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {
#[cfg(feature = "Win32_System_Com")]
pub fn CreateXmlReader(riid: *const ::windows_sys::core::GUID, ppvobject: *mut *mut ::core::ffi::c_void, pmalloc: su... |
use std::fmt;
#[derive(Debug)]
pub struct AppError {
pub kind: String,
pub message: String,
}
impl fmt::Display for AppError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"AppError {{ kind: {}, message: {} }}",
self.kind, self.message
... |
mod my {
// Публичная структура с публичным полем обобщённого типа `T`
pub struct WhiteBox<T> {
pub contents: T,
}
// Публичная структура с приватным полем обобщённого типа `T`
#[allow(dead_code)]
pub struct BlackBox<T> {
contents: T,
}
impl<T> BlackBox<T> {
// ... |
use prelude::*;
//use rand::prelude::{Rng, ThreadRng};
//use std::collections::HashMap;
//use std::rc::Rc;
//use std::cell::RefCell;
use super::click_ana::ClickAnaState;
use super::keyed_state::*;
use super::single_state::{Leaf};
//use super::mk_key::{ MakeKey, key_type_from_row };
#[derive(Debug,Clone)]
enum Memoiza... |
// 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::cmp;
use std::convert::{TryFrom, TryInto};
use std::ops::{Add, Sub};
use vec::Vec2;
/// Rectangle structure.
#[derive(Clone, Copy, Debug, Eq, Has... |
extern crate futures;
use std::sync::mpsc::channel;
use futures::future::ok;
use futures::prelude::*;
#[test]
fn lots() {
fn doit(n: usize) -> Box<Future<Item=(), Error=()> + Send> {
if n == 0 {
Box::new(ok(()))
} else {
Box::new(ok(n - 1).and_then(doit))
}
}
... |
fn main() {
let mut v: Vec<i32> = Vec::new();
v.push(1);
v.push(2);
v.push(3);
let x = vec![1, 2, 3];
let z = match x.get(2) {
Some(xz) => *xz,
None => 0,
};
println!("{}", z);
println!("{}", v[1]);
let mut nnn = vec![1, 2, 3];
//直接奔溃
//let nnn1 = &nnn[1... |
#[cfg(test)]
extern crate quickcheck;
#[cfg(test)]
#[macro_use(quickcheck)]
extern crate quickcheck_macros;
mod error;
mod ket;
pub mod gate;
pub mod quantum_computer;
pub mod registers;
|
// Use external crate for WASM integration
extern crate wasm_bindgen;
// Import from the prelude directory
use wasm_bindgen::prelude::*;
// Use the WASM package to be able to call the JavaScript alert method from rust
#[wasm_bindgen]
extern {
fn alert(s: &str);
}
// Setup the button click method to use the JavaS... |
//! Implements the model for headers, as specified in the
//! [STOMP Protocol Specification,Version 1.2](https://stomp.github.io/stomp-specification-1.2.html).
#[macro_use]
mod macros;
use crate::common::functions::decode_str;
use crate::error::StompParseError;
use either::Either;
use paste::paste;
use std::convert::Tr... |
// Copyright 2022 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 agre... |
use core::cmp;
use core::ops;
use core::slice;
use anyhow::anyhow;
use super::{BigInteger, OpaqueTerm, Term, Tuple};
/// A marker trait for index types
pub trait TupleIndex: Into<usize> {}
/// A marker trait for internal index types to help in specialization
pub trait NonPrimitiveIndex: Sized {}
macro_rules! bad_in... |
extern crate disjoint_sets;
#[macro_use] extern crate scan_rules;
use std::io;
struct Program {
id: usize,
connections: Vec<usize>,
}
fn read_program() -> Result<Option<Program>, scan_rules::ScanError> {
let mut line = String::new();
match io::stdin().read_line(&mut line) {
Err(e) => Err(scan... |
//! Minecraft World support for the Coruscant engine.
//!
//! Documentation content is available under CC BY-NC-SA 3.0 unless otherwise noted.
pub mod level_dat;
pub mod entity;
|
use clippy_utils::diagnostics::span_lint_and_then;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::{
def::Res, def_id::DefId, Item, ItemKind, PolyTraitRef, PrimTy, TraitBoundModifier, Ty, TyKind, UseKind,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_tool_lint, impl_lint_pass... |
// 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 ... |
// This code is editable and runnable!
fn main() {
let greetings = ["Hello", "Hola", "こんにちは", "您好"];
for greeting in greetings.iter() {
println!("{}", greeting);
}
}
|
use core::cmp::Ordering;
use gc::{Gc, GcCell, Trace, Finalize, custom_trace};
use gc_derive::{Trace, Finalize};
use guvm_rs::{Value, BuiltInAsyncFunction, BuiltInSynchronousFunction, Closure};
use gc_immutable_collections::{Array, Map};
mod float;
use float::PavoFloat;
mod fun;
use fun::{Fun, SynchronousFun, Asynch... |
#[macro_use]
extern crate clap;
use std::io::{BufReader, BufWriter};
use std::io::prelude::*;
use std::fs::File;
use std::string::String;
#[allow(non_snake_case)]
fn process_fastq(infile:&str, outfile:&str, sfile:&str, con_a:usize, read_len:usize) -> () {
let f = File::open(infile).expect("Unable to open input fil... |
pub mod translator;
|
pub struct Point {
x: i32,
y: i32,
}
impl Point {
pub fn new(x: i32, y: i32) -> Point {
Point { x, y }
}
pub fn find_distance_to(&self, point: &Point) -> i32 {
use std::cmp;
cmp::max(i32::abs(self.x - point.x), i32::abs(self.y - point.y))
}
}
pub fn min_time_to_visit_... |
extern crate libc;
pub mod anoncreds;
pub mod signus;
pub mod ledger;
pub mod pool;
pub mod wallet;
use self::libc::{c_char};
#[repr(i32)]
pub enum ErrorCode {
Success = 0,
// Common errors
// Caller passed invalid pool ledger handle
CommonInvalidPoolLedgerHandle = 100,
// Caller passed invali... |
use super::facts::Mapping;
use super::{Atom, Error, Message, PendingRequests};
use std::any::Any;
use std::collections::HashMap;
use std::io::{self, Read, Write};
use std::marker::PhantomData;
use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream, ToSocketAddrs};
use std::sync::{mpsc, Arc, Mutex};
use std::threa... |
//! `Timespec` and related types, which are used by multiple public API
//! modules.
use crate::backend::c;
/// `struct timespec`
#[cfg(not(fix_y2038))]
pub type Timespec = c::timespec;
/// `struct timespec`
#[cfg(fix_y2038)]
#[derive(Debug, Clone, Copy)]
#[repr(C)]
pub struct Timespec {
/// Seconds.
pub tv_... |
pub mod tensor;
pub mod tensor_ops;
pub mod traits;
pub mod structs; |
use std;
use std::cmp::max;
use combat;
use game;
use game_item;
use hero;
use map;
use monster;
use texts;
pub use cursive::{Cursive, CursiveExt};
//use cursive::theme;
use cursive::event::Key;
//use cursive::menu::MenuTree;
use cursive::traits::*;
use cursive::views::{DummyView, Dialog, LinearLayout, SelectView, Sc... |
use std::sync::mpsc::{channel, sync_channel};
use std::sync::Mutex;
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use std::error::Error;
use std::string::FromUtf8Error;
pub struct InMemoryData {
payload: Vec<u8>,
}
impl InMemoryData {
pub fn from(payload: &[u8]) -> InMemoryData
{
... |
use std::collections::HashMap;
use std::fmt;
use std::fmt::Debug;
use std::fmt::Error;
use std::fmt::Formatter;
pub trait Fn {
fn eval(&self, Vec<&Value>) -> Value;
}
#[derive(Debug)]
struct AddFn {}
impl Fn for AddFn {
fn eval(&self, values: Vec<&Value>) -> Value {
let a = values[0].get_float();
... |
//! Code generation for [GraphQL scalar][1].
//!
//! [1]: https://spec.graphql.org/October2021#sec-Scalars
use proc_macro2::{Literal, TokenStream};
use quote::{format_ident, quote, ToTokens, TokenStreamExt};
use syn::{
ext::IdentExt as _,
parse::{Parse, ParseStream},
parse_quote,
spanned::Spanned as _,... |
use cvar::{INode, IVisit};
pub use soldank_shared::cvars::*;
#[derive(Default)]
pub struct Config {
pub server: ServerInfo,
pub net: NetConfig,
pub phys: Physics,
}
impl IVisit for Config {
fn visit(&mut self, f: &mut dyn FnMut(&mut dyn INode)) {
f(&mut cvar::List("server", &mut self.server));... |
use input_i_scanner::InputIScanner;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.scan::<$t>() as $t
};
(($($t: ty),... |
use crate::{FileTypeIdentifier, SegmentEntry, SegmentIdBytes, SequencedWalOp};
use byteorder::{BigEndian, ReadBytesExt};
use crc32fast::Hasher;
use generated_types::influxdata::iox::wal::v1::WalOpBatch as ProtoWalOpBatch;
use prost::Message;
use snafu::prelude::*;
use snap::read::FrameDecoder;
use std::{
fs::File,
... |
#![no_std]
#![no_main]
#![feature(format_args_nl)]
use core::{fmt::Write, panic::PanicInfo};
use ferr_os::{
drivers::io::{
self,
vgat_out::{VgatChar, VgatOut, DEFAULT_VGA_TEXT_BUFF_HEIGHT, DEFAULT_VGA_TEXT_BUFF_WIDTH},
},
osattrs,
runtime::{Core},
println,
};
#[no_mangle]
pub exter... |
mod error;
use gstreamer::prelude::*;
use gstreamer::*;
fn main() -> Result<(), error::Error> {
/* Initialize GStreamer */
init()?;
/* Create the elements */
let source = ElementFactory::make("uridecodebin")
.name("source")
.build()?;
let convert = ElementFactory::make("audioconve... |
pub use super::raytracing::*; |
//! Implement virtual machine to run instructions.
//!
//! See also:
//! <https://github.com/ProgVal/pythonvm-rust/blob/master/src/processor/mod.rs>
#[cfg(feature = "rustpython-compiler")]
mod compile;
mod context;
mod interpreter;
mod method;
mod setting;
pub mod thread;
mod vm_new;
mod vm_object;
mod vm_ops;
use ... |
//
// Sysinfo
//
// Copyright (c) 2017 Guillaume Gomez
//
use ::DiskExt;
use ::utils;
use libc::statfs;
use std::mem;
use std::fmt::{Debug, Error, Formatter};
use std::path::{Path, PathBuf};
use std::ffi::{OsStr, OsString};
/// Enum containing the different handled disks types.
#[derive(Debug, PartialEq, Clone, Co... |
use crate::attribute::Attribute;
/// Enum returned from Handler implementations to instruct the parser to
/// continue parsing or cancel parsing.
#[derive(PartialEq)]
pub enum HandlerResult {
Continue, // continue (decode the element's data)
Cancel, // stop parsing
}
/// The Handler trait defines a callba... |
use crate::prelude::*;
use std::sync::{Arc, Mutex};
use std::time::Duration;
pub struct SingleSubmit<'a, F, T>
where
F: FnOnce(&Arc<CommandBuffer>) -> VerboseResult<T>,
{
command_buffer: &'a Arc<CommandBuffer>,
queue: &'a Arc<Mutex<Queue>>,
f: F,
timeout: Option<Duration>,
}
impl<'a, F, T> Singl... |
pub mod artists;
pub mod events;
pub mod organization_invites;
pub mod organizations;
pub mod regions;
pub mod ticket_types;
pub mod tickets;
pub mod users;
pub mod venues;
|
#![feature(plugin)]
#![feature(field_init_shorthand)]
#![plugin(rocket_codegen)]
extern crate rocket;
extern crate rocket_contrib;
extern crate mpd;
extern crate lazy_static;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
// steps:
// 1. show currently playing on start page
// 2. show playlist
// 3.... |
/*
* 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... |
use proconio::input;
use binary_search_range::BinarySearchRange;
fn main() {
input! {
n: usize,
m: usize,
d: u64,
a: [u64; n],
mut b: [u64; m],
};
// A - b <= d
// b >= A - d
// -d <= A - b
// b <= A + d
b.sort();
let mut ans = 0;
for x in ... |
use std::fmt;
use crate::cell::Cell;
#[derive(Clone)]
pub struct Row {
pub cells: Vec<Cell>,
}
impl fmt::Display for Row {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut row = String::new();
for cell in self.cells.iter() {
row.push_str(&cell.to_string());
... |
use base64;
use rand::prelude::*;
use reqwest::Client;
use serde_json::{from_str, json, Map, Value};
use urlencoding;
// twitter access
// token: 703880420-JgOPobTDO6U7aPJaFdwBImxTowBhiTXTZiBT3V12
// secret: 1F8XJN65rF1OfKYu0K4qUv71wSIDk1DX2xpzsuKJYKtis
#[derive(Debug)]
pub struct TweetInfo {
user_id:... |
// Copyright (C) 2019 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use super::*;
/// Parsing errors that can be returned from [`Session::parse`].
///
/// [`Session::parse`]: struct.Session.html#method.parse
#[derive(Debu... |
extern crate olin;
use log::{error, info};
use olin::Resource;
use std::io::Write;
pub extern "C" fn test() -> Result<(), i32> {
info!("testing for issue 39: https://github.com/Xe/olin/issues/39");
const ZERO_LEN: usize = 16;
let zeroes = [0u8; ZERO_LEN];
let mut fout: Resource = Resource::open("null... |
use crate::slice_index::SliceIndex;
use crate::FlannError;
use crate::Indexable;
use crate::Parameters;
pub struct VecIndex<T: Indexable + 'static> {
storage: Vec<Vec<T>>,
slice_index: Option<SliceIndex<'static, T>>,
}
impl<T: Indexable> Drop for VecIndex<T> {
fn drop(&mut self) {
// We absolutely... |
use bytes::IntoBuf;
use futures::{Async, Future, Poll, Stream};
use futures::future::{self, Either};
use futures::sync::mpsc;
use h2::client::{Builder, Handshake, SendRequest};
use tokio_io::{AsyncRead, AsyncWrite};
use headers::content_length_parse_all;
use body::Payload;
use ::common::{Exec, Never};
use headers;
use... |
// 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 {
crate::{
constants::PKG_URL_PREFIX,
font_catalog as fi,
font_catalog::{AssetInFamilyIndex, FamilyIndex, TypefaceInAssetIn... |
use core::time::Duration;
use ggez::{GameResult, Context};
use ggez::graphics::{Point2,Vector2};
use car::{self,Car};
use globals::*;
#[derive(Clone, Copy, Debug)]
pub enum DrawableObject {
DrawableCar(Car),
}
#[derive(Clone, Copy, Debug)]
pub struct TranslationAnimation {
start_time: Duration,
duration... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::_0_RIS {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &... |
use std::io::{Read, Bytes};
pub struct BinaryReader<T: Read> {
buffer: u8,
index: i8,
reader: Bytes<T>,
}
impl<T: Read> BinaryReader<T> {
pub fn new(r: T) -> Self {
BinaryReader {
buffer: 0,
index: -1,
reader: r.bytes(),
}
}
pub fn read_bit(&... |
use std::convert::TryFrom;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum GnssId {
Gps = 0,
Sbas = 1,
Galileo = 2,
BeiDou = 3,
Imes = 4,
Qzss = 5,
Glonass = 6,
}
impl TryFrom<u8> for GnssId {
type Error = String;
fn try_from(val: u8) -> Result<GnssId, String> {
matc... |
extern crate termion;
use termion::raw::IntoRawMode;
use termion::async_stdin;
use std::io::{Read, Write, stdout};
use std::thread;
use std::time::Duration;
fn main() {
let stdout = stdout();
let mut stdout = stdout.lock().into_raw_mode().unwrap();
let mut stdin = async_stdin().bytes();
write!(stdout... |
use itertools::Itertools as _;
use std::io;
type Cargo = char;
type CargoStacks = Vec<Vec<Cargo>>;
#[derive(Debug)]
struct MoveCmd {
count: usize,
from: usize,
to: usize,
}
fn parse_crate_line(s: &str, stacks: &mut CargoStacks) {
for (pos, mut chunk) in s.chars().chunks(4).into_iter().enumerate() {
... |
// Copyright 2022 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::collections::HashSet;
use instant::Duration;
use legion::systems::Builder;
use legion::world::SubWorld;
use legion::{
component,
maybe_changed,
Entity,
EntityStore,
IntoQuery,
};
use sourcerenderer_core::{
Matrix4,
Platform,
};
use crate::transform::interpolation::InterpolatedTran... |
//! Blinks an LED
// #![deny(warnings)]
#![no_std]
#![no_main]
#![feature(maybe_uninit)]
#[macro_use]
extern crate cortex_m;
#[macro_use]
extern crate cortex_m_rt as rt;
extern crate stm32l4xx_hal as hal;
#[macro_use(block)]
extern crate nb;
use crate::hal::prelude::*;
use crate::hal::delay::Delay;
use crate::hal::t... |
use std::cell::RefCell;
use std::collections::HashMap;
use std::fmt;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use crate::actions::{ActionContext, ActionSet, ContextData};
use crate::config::Config;
use crate::queries::{Condition, Query};
use crate::signals::{Signal, SignalEventShared};
use anyhow::Result... |
use std::ops::Deref;
use crate::{InputType, InputValueError};
pub fn max_items<T: Deref<Target = [E]> + InputType, E>(
value: &T,
len: usize,
) -> Result<(), InputValueError<T>> {
if value.deref().len() <= len {
Ok(())
} else {
Err(format!(
"the value length is {}, must be ... |
pub mod animation;
pub mod character;
pub mod common;
pub mod render;
use specs::World;
pub use self::animation::*;
pub use self::character::{Character, CharacterController};
pub use self::common::*;
pub use self::render::*;
pub fn register_components(world: &mut World) {
world.register::<EntityID>();
world.... |
use crypto_bench;
use openssl::{rand, symm};
use test;
fn generate_sealing_key(algorithm: symm::Cipher) -> Result<Vec<u8>, ()> {
let mut key_bytes = vec![0u8; algorithm.key_len()];
try!(rand::rand_bytes(&mut key_bytes).map_err(|_| ()));
Ok(key_bytes)
}
fn seal_bench(algorithm: symm::Cipher, chunk_len: usi... |
pub mod cso;
pub mod point;
pub mod random;
pub mod level;
|
use std::num::NonZeroU16;
use std::path::PathBuf;
use structopt::StructOpt;
use ipfs::{Ipfs, IpfsOptions, IpfsTypes, UninitializedIpfs};
use ipfs::{Multiaddr, Protocol};
use ipfs_http::{config, v0};
#[macro_use]
extern crate tracing;
#[derive(Debug, StructOpt)]
enum Options {
/// Should initialize the repository... |
use std::convert::TryInto;
use std::path::Path;
use std::fs::OpenOptions;
use std::os::raw::c_int;
use std::os::unix::io::AsRawFd;
use std::io::{Read,Write};
pub fn append_to_file_at_path(path: &Path, buf: &[u8]) -> Result<(),String> {
let mut file = match OpenOptions::new().write(true).append(true).open(path) {
... |
fn main() {
let x = Some("string");
let v: Vec<&str> = x.into_iter().collect();
assert_eq!(v, ["string"]);
println!("{:?}", v);
} |
use crate::traits::UIElement;
use crate::traits::UIEvent;
use super::util::cursor_in_rect;
use piston::input::{
UpdateArgs,
RenderArgs,
Key
};
// Import drawing helper functions
use graphics::{Context, rectangle, text, Transformed};
use graphics::character::CharacterCache;
use opengl_graphics::GlGraphics;
us... |
fn main() {
let string = String::from("carson is my name");
let first_word = find_nth_word(&string, 1);
let second_word = find_nth_word(&string, 2);
println!("{}", first_word);
println!("{}", second_word);
}
// Finds nth word in a string and returns it as a string
fn find_nth_word(input_string: &st... |
pub mod bullets;
pub mod tank; |
use actix_web::{web, HttpResponse, Result};
use actix_web::dev::{ServiceResponse, Body, ResponseBody};
use actix_web::http::{StatusCode, header};
use actix_web::middleware::errhandlers::{ErrorHandlerResponse, ErrorHandlers};
use tera::{Context, Tera};
pub fn init_error_handlers() -> ErrorHandlers<Body> {
ErrorHand... |
use game::*;
const ZOMBIE_SPAWN_CHANCE: f64=0.01;
const MAX_ZOMBIES: usize= 30;
const WOLF_PACK_SPAWN_CHANCE: f64=0.001;
const MAX_WOLF_PACKS: usize=4;
impl MonsterSpawner{
pub fn default()->Self{
MonsterSpawner{
zombie_spawn_chance: ZOMBIE_SPAWN_CHANCE,
wolf_pack_spawn_chance: WOLF_PACK_SPAWN_CHANCE
}
}
p... |
extern crate num;
extern crate argparse;
extern crate image;
extern crate rand;
use std::fs::File;
use std::path::Path;
use rand::Rng;
use argparse::{ArgumentParser, Store, StoreTrue};
use num::complex::Complex;
// Shapes to draw
trait Drawable {
fn draw(&self, px: &mut image::Rgb<u8>, x: u32, y: u32) -> bool;
}
... |
use super::{types, ecc};
use std::io::Cursor;
use std::error::Error;
use rocksdb::DB;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
pub struct DAL {
pub db: DB,
}
const CURRENT_TOKEN_KEY: &str = "current_token";
const FREE_TOKEN_KEY: &str = "free_token";
const TOKEN_KEY_PREFIX: &str = "token_";
... |
#![no_std]
#![no_main]
mod cmd;
mod uart_server;
#[macro_use]
extern crate lazy_static;
extern crate alloc;
use alloc::boxed::Box;
use hal::prelude::*;
use tm4c129x_hal as hal;
use cortex_m::peripheral::scb::Exception;
use fe_osi;
use fe_rtos;
#[no_mangle]
fn main() -> ! {
let p = hal::Peripherals::take().unwra... |
#![allow(clippy::all)]
#![allow(dead_code)]
//! This files represent the API endpoints for the IC System API.
//! It is meant to be a copy-paste of the System API from the spec,
//! and also not exported outside this crate.
//!
//! Each of these functions are in a private module accessible only
//! in this crate. Each... |
// Copyright 2022 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 agre... |
use std::iter::FromIterator;
use std::mem;
use crate::repr::Decor;
use crate::value::{DEFAULT_LEADING_VALUE_DECOR, DEFAULT_VALUE_DECOR};
use crate::{Item, RawString, Value};
/// Type representing a TOML array,
/// payload of the `Value::Array` variant's value
#[derive(Debug, Default, Clone)]
pub struct Array {
//... |
use crate::prelude::*;
use std::collections::HashMap;
pub struct Models<T>
where T: Eq + std::hash::Hash {
data: Vec<(PackedScene, Template, usize)>,
name_data_lookup: HashMap<&'static str, usize>,
t_data_lookup: HashMap<T, usize>,
}
unsafe impl<T> Sync for Models<T> where T: Eq + std::hash::Hash {}... |
use cgmath::{
BaseFloat, Basis2, EuclideanSpace, Euler, Quaternion, Rad, Rotation, Rotation2, Vector3,
VectorSpace, Zero,
};
use Pose;
/// Velocity
///
/// ### Type parameters:
///
/// - `L`: Linear velocity, usually `Vector2` or `Vector3`
/// - `A`: Angular velocity, usually `Scalar` or `Vector3`
#[derive(De... |
use crate::arithmetic_command::ArithmeticCommand;
use crate::segment::Segment;
#[derive(Debug)]
pub enum Command {
Arithmetic(ArithmeticCommand),
Push(Segment, i32),
Pop(Segment, i32),
}
|
use core::fmt;
pub struct Error {
repr: Repr,
}
pub type Result<T> = core::result::Result<T, Error>;
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum ErrorKind {
}
impl From<ErrorKind> for Error {
#[inline]
fn from(kind: ErrorKind) -> Error {
Error {
repr:... |
extern crate oxygengine_core as core;
pub mod audio_asset_protocol;
pub mod component;
pub mod resource;
pub mod system;
pub mod prelude {
pub use crate::{audio_asset_protocol::*, component::*, resource::*, system::*};
}
use crate::{
component::{AudioSource, AudioSourcePrefabProxy},
resource::Audio,
... |
use chrono::prelude::*;
use log::{debug, info};
use yew::{html, Component, ComponentLink, Html, ShouldRender};
pub struct Test {
counter: i32,
link: ComponentLink<Self>,
}
#[derive(Clone)]
pub enum Msg {
Increment,
Decrement,
Bulk(Vec<Msg>),
}
impl Component for Test {
type Message = Msg;
... |
pub mod aarch64;
|
mod utils;
use std::{fs::File, io::{BufReader, Read}, os::unix::prelude::FileExt};
use utils:: *;
pub fn main() {
let mut f = File::open("./demo.mp4").unwrap();
let mut buf = vec![];
f.read_to_end(&mut buf).unwrap();
// println!("{:?}", buf.len());
read_info(buf);
// let mut new_f = File::cre... |
// Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclai... |
pub mod composite_deep_scan_line;
pub mod deep_frame_buffer;
pub mod deep_image;
pub mod deep_image_channel;
pub mod deep_image_io;
pub mod deep_image_level;
pub mod deep_scan_line_input_file;
pub mod deep_scan_line_input_part;
pub mod deep_scan_line_output_file;
pub mod deep_scan_line_output_part;
pub mod deep_tiled_i... |
// ignore-compare-mode-nll
// revisions: base nll
// [nll]compile-flags: -Zborrowck=mir
// Test a "pass-through" object-lifetime-default that produces errors.
#![allow(dead_code)]
trait SomeTrait {
fn dummy(&self) { }
}
struct MyBox<T:?Sized> {
r: Box<T>
}
fn deref<T>(ss: &T) -> T {
// produces the typ... |
use std::env;
use std::io;
use std::io::prelude::*;
use std::process;
use std::str;
const ALLTEXT_VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn main() {
let mut args = env::args();
args.next(); // skipping arg[0]
let mut show_help = false;
let mut null_delimiter = false;
if let Some(arg)... |
//! UI channel
use super::NUM_CHANNEL_CONFIGS;
use static_assertions::const_assert_eq;
// See https://github.com/torvalds/linux/blob/master/drivers/gpu/drm/sun4i/sun8i_mixer.h#L75
// for the format values
register! {
Attr,
u32,
RW,
Fields [
Enable WIDTH(U1) OFFSET(U0),
Format WIDTH(U... |
//! Implementation of a DataFusion `TableProvider` in terms of `QueryChunk`s
use async_trait::async_trait;
use std::{collections::HashSet, sync::Arc};
use arrow::{
datatypes::{Fields, Schema as ArrowSchema, SchemaRef as ArrowSchemaRef},
error::ArrowError,
};
use datafusion::{
datasource::TableProvider,
... |
#[doc = "Reader of register CALR"]
pub type R = crate::R<u32, super::CALR>;
#[doc = "Writer for register CALR"]
pub type W = crate::W<u32, super::CALR>;
#[doc = "Register CALR `reset()`'s with value 0"]
impl crate::ResetValue for super::CALR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Typ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.