text stringlengths 8 4.13M |
|---|
use std::cmp::max;
use std::ffi::{
c_void,
CString,
};
use std::hash::{
Hash,
Hasher,
};
use std::sync::{
Arc,
Mutex,
Weak,
};
use ash::vk;
use ash::vk::Handle;
use smallvec::SmallVec;
use sourcerenderer_core::graphics::{
AddressMode,
Filter,
SamplerInfo,
Texture,
Textur... |
// Copyright (c) 2020 DarkWeb Design
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish... |
extern crate subdemo;
fn main() {
subdemo::hello_world();
}
|
use rand::seq::SliceRandom;
use rand::thread_rng;
use std::char;
use std::fmt;
use serde::{Deserialize, Serialize};
#[derive(Debug)]
pub struct Deck {
pub cards: Vec<Card>,
}
impl Deck {
pub fn shuffle(mut self) -> Self {
self.cards.shuffle(&mut thread_rng());
return self;
}
}
impl Defau... |
//! Error and Result module.
use std::error::Error as StdError;
use std::fmt;
use std::io;
use httparse;
use http;
/// Result type often returned from methods that can have hyper `Error`s.
pub type Result<T> = ::std::result::Result<T, Error>;
type Cause = Box<StdError + Send + Sync>;
/// Represents errors that can ... |
#![allow(dead_code)]
// extern crate num_cpus;
extern crate crossbeam_channel;
extern crate crossbeam_utils;
extern crate image;
extern crate sourcerenderer_bsp;
extern crate sourcerenderer_core;
extern crate sourcerenderer_mdl;
extern crate sourcerenderer_vmt;
extern crate sourcerenderer_vpk;
extern crate sourcerender... |
pub use crate::ma::dao::*;
pub use crate::ma::data::{*};
pub use crate::ma::data_btc::{*};
pub use crate::ma::data_eee::{*};
pub use crate::ma::data_eth::{*};
pub use crate::ma::db::*;
pub use crate::ma::detail::{*};
pub use crate::ma::detail_btc::{*};
pub use crate::ma::detail_eee::{EeeTokenType, MEeeChainTokenShared,... |
#[doc = "Reader of register BOOT4_PRGR"]
pub type R = crate::R<u32, super::BOOT4_PRGR>;
#[doc = "Writer for register BOOT4_PRGR"]
pub type W = crate::W<u32, super::BOOT4_PRGR>;
#[doc = "Register BOOT4_PRGR `reset()`'s with value 0"]
impl crate::ResetValue for super::BOOT4_PRGR {
type Type = u32;
#[inline(always... |
use crate::semantic;
use serde_derive::{Deserialize, Serialize};
use std::str;
use strum_macros::{Display, EnumIter};
// TODO: not compatible yet
pub type Tips = u16;
pub type Score = u16;
pub type MoveNo = u16;
const CONSOLE: yew::services::ConsoleService = yew::services::ConsoleService {};
#[derive(Deserialize, Cl... |
#[doc = "Reader of register AHB1RSTR"]
pub type R = crate::R<u32, super::AHB1RSTR>;
#[doc = "Writer for register AHB1RSTR"]
pub type W = crate::W<u32, super::AHB1RSTR>;
#[doc = "Register AHB1RSTR `reset()`'s with value 0"]
impl crate::ResetValue for super::AHB1RSTR {
type Type = u32;
#[inline(always)]
fn re... |
//! Azul is a free, functional, immediate-mode GUI framework for rapid development
//! of desktop applications written in Rust, supported by the Mozilla WebRender
//! rendering engine, using a flexbox-based CSS / DOM model for layout and styling.
//!
//! # Concept
//!
//! Azul is largely based on the principle of immed... |
pub mod vm;
extern crate either;
fn main() {
println!("Hello, world!");
}
|
// does not test any rustfixable lints
#![warn(clippy::mixed_case_hex_literals)]
#![warn(clippy::zero_prefixed_literal)]
#![warn(clippy::unseparated_literal_suffix)]
#![warn(clippy::separated_literal_suffix)]
#![allow(dead_code)]
fn main() {
let ok1 = 0xABCD;
let ok3 = 0xab_cd;
let ok4 = 0xab_cd_i32;
... |
#[derive(Debug)]
pub struct RawVec<T> {
buf: Vec<T>,
}
impl<T> RawVec<T> {
#[inline]
pub fn with_capacity(cap: usize) -> Self {
RawVec {
buf: Vec::with_capacity(cap),
}
}
#[inline]
pub fn ptr(&self) -> *mut T {
let ptr = self.buf.as_ptr();
ptr as *mu... |
#[doc = "Reader of register M1FAR"]
pub type R = crate::R<u32, super::M1FAR>;
#[doc = "Writer for register M1FAR"]
pub type W = crate::W<u32, super::M1FAR>;
#[doc = "Register M1FAR `reset()`'s with value 0"]
impl crate::ResetValue for super::M1FAR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Sel... |
use pest::iterators::Pair;
use std::borrow::Cow;
use std::fmt;
#[derive(Parser)]
#[grammar = "nono.pest"]
pub struct NonoParser;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Clue(pub Vec<usize>);
impl<'a> From<Pair<'a, Rule>> for Clue {
fn from(pair: Pair<Rule>) -> Self {
assert_eq!(pair.as_rule(), ... |
use anyhow::{Context, Result};
use std::{env, fs::read};
use synacor::program::Program;
fn main() -> Result<()> {
env_logger::init();
let mut args = env::args();
args.next();
let input_file = args.next().context("expected argument")?;
let bytes = read(input_file).context("failed to open file")?;
... |
use crate::pdf::{Dict, Name, Object};
use std::collections::LinkedList;
use std::rc::Rc;
pub mod path;
pub use path::Path;
pub mod text;
pub use text::{Font, Text};
pub mod context;
use context::GraphicParameters;
pub use context::{Color, Graphic, GraphicsContextType, Point, Rect};
#[derive(Debug)]
pub struct GraphicC... |
#[macro_use]
extern crate lazy_static;
extern crate nix;
use nix::sys::wait::{waitpid, WaitPidFlag, WaitStatus};
use nix::unistd::{fork, ForkResult, Pid, chdir, execvp};
use std::collections::HashMap;
use std::ffi::CString;
use std::io::{self, Write};
use std::process::exit;
lazy_static! {
pub static ref BUILDIN_... |
use log::error;
mod args;
use args::*;
use lupo::errors::*;
use lupo::*;
// Rust doesn't trap a unix signal appropriately occasionally: https://github.com/rust-lang/rust/issues/46016
fn reset_signal_pipe_handler() -> Result<()> {
#[cfg(target_family = "unix")]
{
use nix::sys::signal;
unsafe ... |
use super::*;
use std::thread;
use std::time::Duration;
#[test]
fn with_invalid_unit_errors_badarg() {
with_process(|process| {
assert_badarg!(
result(process, atom!("invalid")),
"atom (invalid) is not supported"
);
});
}
#[test]
fn with_second_increases_after_2_second... |
pub mod ai;
pub mod game;
pub mod grid;
pub use ai::AI;
pub use game::TicTacToe;
pub use grid::Grid;
use std::ops::Add;
#[derive(Debug, PartialEq)]
pub struct Side(pub u16);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct Coordinates {
pub x: i16,
pub y: i16,
}
impl Add<Coordinates> for Coord... |
use std::fmt;
#[derive(Clone)]
struct NucleotideCompressorError { nucleotide: char }
impl fmt::Display for NucleotideCompressorError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Invalid nucleotide: {}", self.nucleotide)
}
}
pub struct NucleotideCompressor {
bit_string: u32... |
//use std::env;
//use std::process;
//use minigrep::Config;
fn main() {
println!("Rust book chapter 12 minigrep");
//let args: Vec<String> = std::env::args().collect();
//println!("{:?}", args);
let config = minigrep::Config::new(std::env::args()).unwrap_or_else(|err| {
eprintln!("Problem par... |
use game::*;
pub use biomes::*;
pub fn add_chunk(game: &mut Game1, coords: &(i64, i64)){
add_grass_biome(game,coords)
}
impl ChunkLoader{
pub fn new(chunk_loaders: &mut GVec<ChunkLoader>)->ChunkLoaderID{
ChunkLoaderID{id: chunk_loaders.add(ChunkLoader{loaded_chunks: Vec::new(), keep_loaded: Vec::new(), terrain_... |
mod mersenne;
use mersenne::{MersenneTwister};
fn main() {
let mut rand1 = MersenneTwister::new_from_seed(44332);
let mut out = [0;624];
for i in 0..624{
out[i] = rand1.gen_rand();
}
let mut rand2 = MersenneTwister::clone(&out);
for i in 0..100000{
assert_eq!(rand1.gen_rand(... |
use result::{Error, Payload};
use rocket_contrib::json::Json;
pub type ApiResponse<T> = Result<Json<Payload<T>>, Error>;
|
use super::system_prelude::*;
#[derive(Default)]
pub struct SpikeSystem;
impl<'a> System<'a> for SpikeSystem {
type SystemData = (
Entities<'a>,
Write<'a, ResetLevel>,
Write<'a, PlayerDeaths>,
ReadStorage<'a, Spike>,
ReadStorage<'a, Player>,
ReadStorage<'a, Collisio... |
#[doc = "Reader of register OR"]
pub type R = crate::R<u32, super::OR>;
#[doc = "Writer for register OR"]
pub type W = crate::W<u32, super::OR>;
#[doc = "Register OR `reset()`'s with value 0"]
impl crate::ResetValue for super::OR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
use crate::math;
use std::f32;
#[derive(Clone)]
pub struct Camera {
pub view: math::Mat4x4f,
pub pos: math::Vec3f,
pub pitch: f32,
pub yaw: f32,
pub near: f32,
pub far: f32,
pub aspect: f32,
pub fov: f32,
}
pub fn create_default_camera(width: u32, height: u32) -> Camera {
Camera {
... |
extern crate thin;
extern crate fn_move;
use thin::ThinBox;
use fn_move::FnMove;
#[test]
fn thin_box_closure() {
let v1 = vec![1i32,2,3];
let v2 = vec![-1i32, -2, -3];
let closure: ThinBox<FnMove() -> Vec<i32>> = ThinBox::new(move ||{
v1.into_iter()
.zip(v2)
// have to return a ... |
use std::io::Write;
use crate::Color;
use crate::util::clamp;
pub fn write_color<W: Write>(out: &mut W, pixel_color: Color, samples_per_pixel: i32) {
// Divide the color by the number of samples and gamma-correct for gamma=2.0.
let scale = 1.0 / samples_per_pixel as f64;
let r = (pixel_color.x() * scale).... |
use core::ops::ControlFlow;
use anyhow::anyhow;
use firefly_diagnostics::{SourceSpan, Span};
use firefly_intern::{symbols, Ident};
use firefly_pass::Pass;
use firefly_syntax_base::FunctionName;
use crate::ast::*;
use crate::visit::{self as visit, VisitMut};
/// This pass performs expansion of records and record ope... |
#[doc = "Reader of register MDIOS_RDFR"]
pub type R = crate::R<u32, super::MDIOS_RDFR>;
#[doc = "Reader of field `RDF`"]
pub type RDF_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - Read flags for MDIO registers 0 to 31"]
#[inline(always)]
pub fn rdf(&self) -> RDF_R {
RDF_R::new((self.bits & 0... |
use crate::error::RpcError;
use crate::module::Module;
pub(crate) mod methods;
/// Registers all methods for the pathfinder RPC API
pub fn register_methods(module: Module) -> anyhow::Result<Module> {
let module = module
.register_method_with_no_input("v0.1_pathfinder_version", |_| async {
Resu... |
use failure::Error;
use yew::{html, Callback, Component, ComponentLink, Html, Renderable, ShouldRender};
use yew::services::fetch::FetchTask;
use crate::services::froovie_service::{FroovieService, Selections, Movie};
pub struct UserSelectionModel {
froovie: FroovieService,
callback: Callback<Result<Selectio... |
//! Static Single Assignment (SSA) Transformation
use crate::graph::*;
use crate::il;
use crate::Error;
use std::collections::{HashMap, HashSet, VecDeque};
/// Transform the IL function into SSA form.
pub fn ssa_transformation(function: &il::Function) -> Result<il::Function, Error> {
let mut ssa_function = functi... |
use crate::schema::atividades_administrativas;
use chrono::NaiveDateTime;
#[derive(Serialize, Deserialize, Queryable)]
pub struct AtividadesAdministrativas {
pub id: i32,
pub id_professor: i32,
pub atividade: String,
pub numero_portaria: i32,
pub ano_portaria: i32,
pub created_at: NaiveDateTime... |
//! Account commitment managment
#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
#[cfg(not(feature = "std"))]
use alloc::{collections::btree_map as map, collections::BTreeMap as Map, collections::BTreeSet as Set};
use bigint::{Address, M256, U256};
#[cfg(not(feature = "std"))]
use core::cell::RefCell;
#[cfg(feature... |
use cranelift_entity::{self as entity, entity_impl};
use firefly_diagnostics::SourceSpan;
use firefly_syntax_base::Type;
use super::{Block, Inst};
pub type ValueList = entity::EntityList<Value>;
pub type ValueListPool = entity::ListPool<Value>;
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct... |
use std::path::Path;
fn main() {
assert_eq!(Path::new("/tmp/ok").exists(), false);
}
|
extern crate ndarray;
use ndarray::prelude::*;
use std::time::Instant;
#[derive(Debug)]
struct WGraph {
adj_matrix: ndarray::prelude::Array2<f64>,
visited: ndarray::prelude::Array1<f64>,
size: i32,
}
impl WGraph {
fn add_biedge(&mut self, source: usize, destination: usize, weight: f64) {
self... |
// 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::labels::{NodeId, NodeLinkId};
use failure::Error;
use std::collections::{BTreeMap, BinaryHeap};
use std::time::Duration;
/// Describes a node i... |
#[doc = "Reader of register FIFOCNT"]
pub type R = crate::R<u32, super::FIFOCNT>;
#[doc = "Reader of field `FIF0COUNT`"]
pub type FIF0COUNT_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:23 - FIF0COUNT"]
#[inline(always)]
pub fn fif0count(&self) -> FIF0COUNT_R {
FIF0COUNT_R::new((self.bits & 0x00f... |
use proc_macro::TokenStream;
use quote::quote;
use syn::{
ext::IdentExt, Block, Error, ImplItem, ItemImpl, ReturnType, Type, TypeImplTrait,
TypeParamBound,
};
use crate::{
args::{self, ComplexityType, RenameRuleExt, RenameTarget, SubscriptionField},
output_type::OutputType,
utils::{
extract... |
//! https://github.com/lumen/otp/tree/lumen/lib/inets/src/http_server
use super::*;
test_compiles_lumen_otp!(httpd);
test_compiles_lumen_otp!(httpd_acceptor);
test_compiles_lumen_otp!(httpd_acceptor_sup);
test_compiles_lumen_otp!(httpd_cgi);
test_compiles_lumen_otp!(httpd_conf);
test_compiles_lumen_otp!(httpd_connect... |
use examples_shared::{self as es, anyhow, ds, tokio, tracing};
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
let client = es::make_client(ds::Subscriptions::ACTIVITY).await;
let mut activity_events = client.wheel.activity();
tokio::task::spawn(async move {
while let Ok(ae) = activ... |
#[macro_export]
macro_rules! ast {
(
($d:tt), $Path:ident
) => {
macro_rules! path {
(
$d ( $d e:expr),*
) => (
$Path::with_steps(vec![$d ($d e),*])
);
}
};
(
$Neighborhood:ident, $Path:ident, $Step:ident... |
use std::ops::{Deref, DerefMut};
use std::sync::{LockResult, Mutex, MutexGuard, PoisonError, TryLockError, TryLockResult};
pub struct RwMutex<T> {
mutex: Mutex<T>,
}
pub struct RwMutexReadGuard<'a, T: ?Sized + 'a> {
mutex_guard: MutexGuard<'a, T>,
}
pub struct RwMutexWriteGuard<'a, T: ?Sized + 'a> {
mute... |
// Copyright 2015 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 ... |
/*
DeepSAFL - mutate operations
------------------------------------------------------
Written and maintained by Liang Jie <liangjie.mailbox.cn@google.com>
Copyright 2018. All rights reserved.
*/
#![allow(unused)]
use std;
use std::cmp;
use std::mem;
use super::config;
use rand;
use ... |
use std::time::Duration;
use crate::error::{RotatorResult, RotatorError};
use crate::passwd::get_random_password;
use crate::config::Config;
use crate::iam::{
CredentialStatus,
list_service_specific_credentials,
create_service_specific_credential,
reset_service_specific_credential,
update_service_sp... |
fn main() {
proconio::input!{n:u64,x:u64,t:u64}
println!("{}", (n+x-1)/x*t);
} |
use crate::snapshot_comparison::Language;
use crate::{
check_flight_error, run_influxql, run_sql, snapshot_comparison, try_run_influxql, try_run_sql,
MiniCluster,
};
use arrow::record_batch::RecordBatch;
use arrow_util::assert_batches_sorted_eq;
use futures::future::BoxFuture;
use http::StatusCode;
use observab... |
use clap;
use crate::clients::{Parameters, VoteClient, VoteClientConstructor};
use memcached;
use memcached::proto::{MultiOperation, ProtoType};
pub struct Constructor(String, bool);
pub struct Client(memcached::Client, bool);
impl VoteClientConstructor for Constructor {
type Instance = Client;
fn new(params... |
//! HTTP and websocket server providing RPC calls to clients
//!
//! This is the main server application. It uses the `database`, `music_container` and `sync` crate
//! to manage the music and provides further routines to upload or download music from the server.
//! The server actually consists of three different serv... |
use proconio::input;
fn main() {
input! {
n: usize,
p: u64,
q: u64,
r: u64,
a: [u64; n],
};
let mut cum = vec![0; n + 1];
for i in 0..n {
cum[i + 1] = cum[i] + a[i];
}
for w in 1..=n {
let s = cum[w];
if s >= r && cum.binary_sear... |
#![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
#[macro_use]
extern crate lazy_static;
extern crate openssl;
extern crate regex;
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
extern crate url;
pub mod httpstream;
pub mod tcp;
pub mod unix;
pub mod tls;
pub mod errors;
pub mod t... |
use super::entity::Entity;
use super::resource_registry::ResourceRegistry;
use super::shape::EntityShape;
use anymap::AnyMap;
use glutin::event::Event;
use std::any::TypeId;
pub type Resources = AnyMap;
type SystemFn = fn(&mut Entity, resourceRegistry: &mut ResourceRegistry, value: &RunSystemPhase);
type ServiceFn = ... |
use super::{parse_zeek_timestamp, TryFromZeekRecord, PROTO_ICMP, PROTO_TCP, PROTO_UDP};
use anyhow::{anyhow, Context, Result};
use giganto_client::ingest::network::{Conn, DceRpc, Dns, Http, Kerberos, Ntlm, Rdp, Smtp, Ssh};
use num_traits::ToPrimitive;
use std::net::IpAddr;
impl TryFromZeekRecord for Conn {
#[allow... |
use async_std::task;
use futures;
use futures::executor::block_on;
use std::thread::sleep;
use std::time::Duration;
#[derive(Debug)]
struct Song {
lyrics: String,
}
async fn learn_song() {
task::sleep(Duration::new(5, 0)).await;
println!("I'm learnding!")
}
async fn sing_song() {
let song: Song = Son... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[doc(hidden)]
pub struct IMicrosoftAccountMultiFactorAuthenticationManager(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IMicrosoftAccou... |
use std::vec::Vec;
use std::cmp::Ordering;
use std::mem;
// courtesy of https://stackoverflow.com/a/28294764
fn swap<T>(x: &mut Vec<T>, i: usize, j: usize) {
let (lo, hi) = match i.cmp(&j) {
// no swapping necessary
Ordering::Equal => return,
// get the smallest and largest of the two indi... |
#![no_main]
use libfuzzer_sys::fuzz_target;
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
if s.len() > 30 && &s[0..10] == "hardtofind" {
println!("panic url:{}", s);
panic!("BOOM");
}
}
});
|
use std::{
collections::HashMap,
path::{Path, PathBuf},
time::{Duration, SystemTime},
};
use tokio::io::AsyncWriteExt;
pub(crate) struct DeletionTracker {
log_path: PathBuf,
}
const FOURTEEN_DAYS_AS_SECS: u64 = 7 * 24 * 60 * 60;
#[cfg(not(windows))]
const LINE_ENDING: &str = "\n";
#[cfg(windows)]
con... |
use super::*;
#[test]
fn with_invalid_unit_errors_badarg() {
with_process(|process| {
assert_badarg!(result(process, atom!("invalid")), SUPPORTED_UNITS);
});
}
#[test]
fn with_second_increases_after_2_seconds() {
with_process(|process| {
let unit = Atom::str_to_term("second");
let ... |
use nalgebra::{Vector3, Point3, UnitQuaternion, Quaternion, Rotation3};
const JOINT_COUNT: usize = k4a::joint_id::K4ABT_JOINT_COUNT as usize;
#[derive(Debug, Clone)]
pub struct SmoothParams {
smoothing: f64,
correction: f64,
prediction: f64,
jitter_radius: f64,
max_deviation_radius: f64,... |
use crate::state::mouse::MouseButton;
use keyboard_types::{Code, Key};
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum CursorIcon {
Arrow,
NResize,
EResize,
}
#[derive(Debug, Clone, PartialEq)]
pub enum WindowEvent {
WindowClose,
WindowResize(f32, f32),
MouseDown(MouseButton),
MouseUp(... |
pub struct Expr {}
|
//! Parse and compile crontab syntax, not needed for on-chain code.
use std::str::FromStr;
use crate::bitset::{BitSetIndex, NonEmptyBitSet};
use crate::cron::CronCompiled;
#[derive(Clone, PartialEq, Debug)]
pub enum CronItem {
Range {
/// inclusive
start: BitSetIndex,
/// inclusive
... |
use protocols::*;
use types::*;
use gates::*;
use circuit::{BoolCircuit, BoolCircuitDesc, Output};
use std::collections::HashMap;
// Debug Protocol
pub struct DebugProtocol {
this_party: u32,
}
impl ProtocolDesc for DebugProtocol {
type VarType = bool;
type CDescType = BoolCircuitDesc;
fn new(party: ... |
use std::path::Path;
use std::fs::{File, OpenOptions};
use std::io::{Read, Cursor, Seek, SeekFrom};
use bytes::{Bytes, Buf};
use crate::reader::Reader;
use anyhow::{Result, bail, anyhow, Error};
use crate::io;
use crate::util;
use std::cmp::min;
use std::os::unix::io::{AsRawFd, RawFd};
use derivative::Derivative;
use n... |
use crate::{Point, Ray, Vec3};
pub struct Camera {
origin: Point,
lower_left: Point,
horizontal: Vec3,
vertical: Vec3,
u: Vec3,
v: Vec3,
lens_radius: f64,
}
impl Camera {
pub fn new(
lookfrom: Point,
lookat: Point,
vup: Vec3,
vert_fov: f64,
aspec... |
#[macro_use] extern crate lazy_static;
mod tokenizer;
mod ast;
mod runtime;
mod util;
fn main() {
println!("Running Joey-Script 1.0");
let input = String::from(include_str!("main.js"));
let tokens = tokenizer::tokenize(&input);
let ast = ast::parse(&tokens);
runtime::run(&ast);
}
|
use std::convert::TryInto;
use std::io::{ErrorKind, Read};
use std::net::{Ipv4Addr, SocketAddrV4};
use std::os::unix::io::AsRawFd;
use std::process::exit;
use anyhow::{anyhow, Context, Result};
use nix::ioctl_write_ptr;
use nix::sys::select::{select, FdSet};
use nix::sys::time::{TimeSpec, TimeValLike};
use nix::sys::t... |
//! Полилинии
use crate::sig::HasWrite;
use nom::{
bytes::complete::take,
number::complete::{le_i16, le_u16, le_u32, le_u8},
IResult,
};
use std::fmt;
#[derive(Debug)]
pub struct Poly {
poly_type: u16, //тип полилинии 0=контур элемента, 16=отверстие
node_from: u16, //С узла N
node_to: u16, //... |
// 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.
#![warn(missing_docs)]
//! `timekeeper` is responsible for external time synchronization in Fuchsia.
use {
chrono::prelude::*,
failure::{Error, R... |
extern crate hsl;
extern crate rand;
extern crate sdl2;
use sdl2::audio::{AudioCVT, AudioSpecDesired, AudioSpecWAV, AudioQueue};
use sdl2::event::Event;
use sdl2::image::{INIT_PNG, LoadSurface};
use sdl2::gfx::rotozoom::RotozoomSurface;
use sdl2::keyboard::Keycode;
use sdl2::pixels::Color;
use sdl2::rect::Rect;
use sd... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
pub const CLSID_VdsLoader: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9c38ed61_d565_4728_aeee_c80952f0ecde);
pub const CLSID_VdsService: ::windows::core::GUID = ::windows::cor... |
use std::{path::Path, sync::Arc};
use criterion::{
criterion_group, criterion_main, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId,
Criterion, Throughput,
};
use data_types::{
partition_template::{NamespacePartitionTemplateOverride, TablePartitionTemplateOverride},
NamespaceId, Namespace... |
use crate::bucket::DailyBucket;
use crate::hotspotmap::HotspotMap;
use crate::msg::QueryAnswer;
use crate::pointer::{Pointer, Pointers, ONE_DAY};
use cosmwasm_std::{
to_binary, Api, Env, Extern, HandleResponse, Querier, QueryResult, StdResult, Storage,
};
pub fn query_dates<S: Storage, A: Api, Q: Querier>(deps: &E... |
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
//
use std::path::Path;
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
use serde_derive::{Deserialize, Serialize};
use crate::{Error, Tag, WorkAsset};
/// The Metadata struct & accessor methods
pub mod metadata;
pub use metadata::Met... |
fn main() {
println!("Hello 100 Days of Code");
} |
pub struct Solution;
impl Solution {
pub fn max_profit(prices: Vec<i32>) -> i32 {
let mut a = std::i32::MIN;
let mut b = std::i32::MIN;
let mut c = std::i32::MIN;
let mut d = std::i32::MIN;
for p in prices {
a = a.max(-p);
b = b.max(a + p);
... |
//! This crate provides various matcher algorithms for line oriented search given the query string.
//!
//! The matcher result consists of the score and the indices of matched items.
//!
//! Matching flow:
//!
//! // arc<dyn ClapItem>
//! // |
//! // ↓
//! // +---------------------... |
use telegram_bot::*;
pub type Coord = (usize, usize);
pub struct InteractResult {
pub update_text: Option<String>,
pub update_board: Option<InlineKeyboardMarkup>,
pub game_end: bool,
}
pub trait Game {
fn interact(&mut self, coord: Coord, user: &User) -> Option<InteractResult>;
}
impl InteractResul... |
/*
A reduced test case for Issue #506, provided by Rob Arnold.
*/
native "rust" mod rustrt {
fn task_yield();
}
fn main() { spawn rustrt::task_yield(); }
|
#![allow(unused)]
extern crate hackscanner_lib;
use hackscanner_lib::file_finder::FileFinderTrait;
use hackscanner_lib::*;
use std::path::Path;
use std::thread;
pub fn get_test_dir() -> String {
format!("{}/tests", env!("CARGO_MANIFEST_DIR"))
}
pub fn get_rules_multiple_results() -> Vec<Rule> {
vec![Rule::ne... |
use std::io::{self, Read};
use minesweeper::{Configuration, check_configuration, ProbeResult};
fn main() -> io::Result<()> {
println!("A Minesweeper board configuration consists of `_` (unknown), `?` (probe), number (number of mines around).");
println!("Enter a consistent Minesweeper board configuration with ... |
use crate::Error;
pub fn register_app(app: super::Application) -> Result<(), Error> {
use super::LaunchCommand;
fn inner(app: super::Application) -> anyhow::Result<()> {
use anyhow::Context as _;
let mut desktop_path = app_dirs2::get_data_root(app_dirs2::AppDataType::UserData)
.co... |
#[derive(Debug)]
struct Token {
value: i32
}
pub fn fv_run() {
println!("-------------------- {} --------------------", file!());
let incoming_tokens: Vec<Token> = vec![
Token { value: 5 },
Token { value: 10 },
Token { value: 12 },
Token { value: -3 },
Token { value... |
use crate::types::GrinboxError;
use crate::utils::bech32::CodingError;
use failure::Fail;
#[derive(Clone, Debug, Eq, Fail, PartialEq, Serialize, Deserialize)]
pub enum ErrorKind {
#[fail(display = "\x1b[31;1merror:\x1b[0m {}", 0)]
GenericError(String),
#[fail(display = "\x1b[31;1merror:\x1b[0m secp error")]
SecpEr... |
//! Module providing the search capability using BAM/BAI files
//!
use std::{fs::File, path::Path};
use bam::bai::index::reference_sequence::bin::Chunk;
use noodles_bam::{self as bam, bai};
use noodles_bgzf::VirtualPosition;
use noodles_sam::{self as sam};
use crate::{
htsget::{Format, HtsGetError, Query, Response... |
use std::cell::RefCell;
use std::rc::Rc;
extern crate rustyline;
use rustyline::error::ReadlineError;
use rustyline::Editor;
#[macro_use]
extern crate log;
use ::lispy_rs::lispy::*;
use ::lispy_rs::parser::*;
use ::lispy_rs::*;
/// Loads and evaluates files supplied in `files`
/// TODO think of a better name. This ... |
use serde::{Deserialize, Serialize};
use serde_json;
use crate::clients::client_utils::UrlHelper;
use super::client_utils::error_conversion;
#[allow(non_snake_case)]
#[derive(Debug, Serialize, Deserialize)]
pub struct CollectionOptions {
disableMeta: bool,
asyncListeners: bool,
disableDeltaChangesApi: bo... |
#[test]
fn test_vec_create() {
let v = vec![1, 2, 3, 4, 5];
}
#[test]
fn test_vec_repeating() {
let v = vec![0; 10]; // ten zeros
}
#[test]
fn test_vec_access() {
let v = vec![1, 2, 3, 4, 5];
let i: usize = 0;
let j: i32 = 0;
// indexing must be done with usize
v[i];
// doesn't comp... |
// This file is part of syslog2. 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/syslog2/master/COPYRIGHT. No part of syslog2, including this file, may be copied, modified, propagated, or distributed except... |
#[doc = "Reader of register AHBRSTR"]
pub type R = crate::R<u32, super::AHBRSTR>;
#[doc = "Writer for register AHBRSTR"]
pub type W = crate::W<u32, super::AHBRSTR>;
#[doc = "Register AHBRSTR `reset()`'s with value 0"]
impl crate::ResetValue for super::AHBRSTR {
type Type = u32;
#[inline(always)]
fn reset_va... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(feature = "Data_Html")]
pub mod Html;
#[cfg(feature = "Data_Json")]
pub mod Json;
#[cfg(feature = "Data_Pdf")]
pub mod Pdf;
#[cfg(feature = "Data_Text")]
pub mod Text;
#[cfg(feature = "... |
use std::num::Wrapping;
use crate::brainfuck_lexer::BFT;
#[derive(Debug, Clone)]
pub enum LoopCacheStatus {
NotAvailable,
Available(usize),
Unknown
}
pub fn loop_cache_control(caching_reference: &mut Vec<LoopCacheStatus>, code_pointer: &mut usize, code: &[BFT], caching_data: &mut Vec<LoopCacheMeta>, mem... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.