text stringlengths 8 4.13M |
|---|
use std::{path::Path};
use crate::error::Error;
pub enum SamplingKind {
WithReplacement,
WithoutReplacement,
}
pub trait SampleText {
fn sample(
src: &Path,
dst: &Path,
sample_size: usize,
sampling: SamplingKind,
) -> Result<(), Error>;
}
|
// Copyright 2014 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 ... |
use serde::{Serialize, Deserialize};
use std::io::Write;
#[derive(Debug, Serialize, Deserialize)]
pub struct Array{
pub values: Vec<String>
}
impl Array{
#[inline]
pub fn walk(&self, name: &str, mut file: &std::fs::File, depth: u64){
let t = (0..depth).map(|_| "\t").collect::<String>();
le... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(feature = "Devices_Spi_Provider")]
pub mod Provider;
#[repr(transparent)]
#[doc(hidden)]
pub struct ISpiBusInfo(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interfac... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless ... |
use actix_web::client::{Client, Connector};
use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
pub struct SSLClinet {}
impl SSLClinet {
pub fn build() -> Client {
// disable ssl verification
let mut builder = SslConnector::builder(SslMethod::tls()).unwrap();
builder.set_verify(Ssl... |
use nannou::ease::*;
pub trait EasingsExtension {
fn ease_out_circ(&self) -> f32;
fn ease_in_circ(&self) -> f32;
fn ease_in_cubic(&self) -> f32;
fn ease_out_cubic(&self) -> f32;
fn ease_in_quad(&self) -> f32;
fn ease_out_quad(&self) -> f32;
fn ease_in_sine(&self) -> f32;
fn ease_out_s... |
extern crate fastcgi;
extern crate serde_json;
extern crate redis;
use std::io::Write;
use std::io::Read;
use std::str;
use std::sync::{Arc, Mutex};
use serde_json::{json};
use redis::Commands;
fn deserialize_body(req: &mut fastcgi::Request) -> Result<serde_json::Value, serde_json::Error> {
let mut buffer =... |
use std::libc::*;
use opcode::*;
use interpret::*;
use libjit::*;
use jit::*;
mod variable_type;
mod libjit;
mod opcode;
mod interpret;
mod jit;
mod basic_block;
mod analysis;
fn main() {
// Sample VM function that omputes the factorial of 10.
let factorial = ~[
// n := 10 //
Constf3... |
use crate::{app::AppContextPointer, gui::control_area::BOX_SPACING};
use gtk::{self, gdk::RGBA, prelude::*, Frame, ScrolledWindow};
use std::rc::Rc;
pub fn make_data_option_frame(ac: &AppContextPointer) -> ScrolledWindow {
let f = Frame::new(None);
//f.set_shadow_type(gtk::ShadowType::None);
f.set_hexpand(... |
use super::{Error, SassFunction};
use css::{CallArgs, Value};
use num_rational::Rational;
use num_traits::One;
use std::collections::BTreeMap;
use value::{ListSeparator, Number, Unit};
pub fn register(f: &mut BTreeMap<&'static str, SassFunction>) {
def!(f, rgb(red, green, blue), |s| Ok(Value::rgba(
to_int(... |
use proconio::input;
fn main() {
input! {
n: usize,
h: [u32; n],
};
let max = h.iter().copied().max().unwrap();
let ans = h.iter().position(|&x| x == max).unwrap() + 1;
println!("{}", ans);
}
|
use std::{
fmt::{self, Display},
marker::PhantomData,
ptr::NonNull,
};
use crate::{
pointer_trait::{AsMutPtr, AsPtr, CanTransmuteElement, GetPointerKind, PK_MutReference},
sabi_types::RRef,
};
/// Equivalent to `&'a mut T`,
/// which allows a few more operations without causing Undefined Behavior.... |
use std::path::Path;
use thiserror::Error;
pub trait Vad {
fn reset(&mut self) -> Result<(), VadError>;
fn is_someone_talking(&mut self, audio: &[i16]) -> Result<bool, VadError>;
}
#[cfg(feature = "snowboy")]
pub struct SnowboyVad {
vad: rsnowboy::SnowboyVad,
}
#[cfg(feature = "snowboy")]
impl SnowboyVad... |
/// Parse a URL from a string to a Url type
///
/// The `parse` method from the url crate validates and parses a `&str` into a
/// `Url` struct. The input string may be mafromed so this method returns
/// `Result<Url, ParseError>`
///
/// Once the URL has been parsed, it can be used with all of the methods on the
/// ... |
// https://docs.rs/assert_cmd/0.11.1/assert_cmd/
// https://docs.rs/predicates/1.0.1/predicates/
use std::process::Command;
use assert_cmd::prelude::*;
use predicates::prelude::*;
#[test]
fn errors_when_no_reference() {
let mut cmd = Command::cargo_bin("henry_commentary_cargo").unwrap();
cmd.assert()
... |
// error-pattern:>> cannot be applied to type `port[int]`
fn main() {
let p1: port[int] = port();
let p2: port[int] = port();
let x = p1 >> p2;
} |
use crate::{FunctionCtx, Backend};
use lowlang_syntax as syntax;
impl<'a, 't, 'l, B: Backend> FunctionCtx<'a, 't, 'l, B> {
pub fn trans_stmt(&mut self, stmt: &syntax::Stmt<'t>) {
match stmt {
syntax::Stmt::Assign(place, value) => {
let place = self.trans_place(place);
... |
// -*- rust -*-
fn main() {
let v: vec[int] = [10, 20];
assert (v.(0) == 10);
assert (v.(1) == 20);
let x: int = 0;
assert (v.(x) == 10);
assert (v.(x + 1) == 20);
x = x + 1;
assert (v.(x) == 20);
assert (v.(x - 1) == 10);
} |
pub mod barriers;
pub mod controller_collector_context;
pub mod global;
pub mod mutator_context;
pub mod plan_constraints;
pub mod tracelocal;
pub mod transitive_closure;
pub use self::global::AllocationSemantics;
pub use self::global::CopyContext;
pub use self::global::Plan;
pub use self::mutator_context::Mutator;
pub... |
#[path = "float_to_binary_1/with_float.rs"]
pub mod with_float;
// `without_float_errors_badarg` in unit tests
|
// 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 {
super::{asset::Asset, cache::Cache},
failure::{format_err, Error, ResultExt},
fidl::endpoints::create_proxy,
fidl_fuchsia_io as io, f... |
#![allow(clippy::comparison_chain)]
#![allow(clippy::collapsible_if)]
use std::cmp::Reverse;
use std::cmp::{max, min};
use std::collections::{BTreeSet, HashMap, HashSet};
use std::fmt::Debug;
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000_000_007;
/// 2の逆元 mod ten97.割りたいときに使う
const in... |
pub use ::libnx::UsbCommsInterfaceInfo;
use std::sync::atomic::{AtomicBool, Ordering};
use os;
#[derive(Debug)]
pub struct Handle(());
static INITIALIZED: AtomicBool = AtomicBool::new(false);
impl Drop for Handle {
fn drop(&mut self) {
if INITIALIZED.swap(false, Ordering::SeqCst) {
unsafe ... |
// Average of Levels in Binary Tree
// https://leetcode.com/explore/challenge/card/march-leetcoding-challenge-2021/588/week-1-march-1st-march-7th/3661/
use crate::tree::TreeNode;
pub struct Solution;
use std::{cell::RefCell, rc::Rc};
impl Solution {
fn visit(
acc: &mut Vec<(f64, usize)>,
node: &... |
use vec3::*;
use util::*;
use onb::*;
use hitable::*;
pub fn random_cosine_direction(rng: &mut Rng) -> Vec3<f64> {
let r1 = rng.rand64();
let r2 = rng.rand64();
let z = (1.-r2).sqrt();
let phi = 2.*PI*r1;
let x = phi.cos()*2.*r2.sqrt();
let y = phi.sin()*2.*r2.sqrt();
return Vec3::new(x,y,z... |
include!("common.in");
fn main() {
init_async_rt();
async_rt::task::block_on(tcp_echo());
}
|
// 参考: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! read_value {
($iter:expr, ( $($t:tt),* )) => {
( $(read_value!($iter, $t)),* )
};
($iter:expr, [ $t:tt ; $len:expr ]) => {
(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
};
($iter:expr, chars) =... |
use super::component_prelude::*;
#[derive(Default)]
pub struct Tile;
impl Component for Tile {
type Storage = NullStorage<Self>;
}
|
/// Return value when reading a slice with `CLob::read_slice()` or `NCLob::read_slice()`.
///
/// Both methods allow specifying the `offset` and the `length` of the requested slice.
///
/// * `CLob::read_slice()` interprets `offset` and `length` as numbers of bytes, applied to the
/// HANA-internally used CESU8-encod... |
use std::collections::HashSet;
use legion::*;
#[derive(Clone, Copy, Debug, PartialEq)]
struct Pos(f32, f32, f32);
#[derive(Clone, Copy, Debug, PartialEq)]
struct Rot(f32, f32, f32);
#[derive(Clone, Copy, Debug, PartialEq)]
struct Scale(f32, f32, f32);
#[derive(Clone, Copy, Debug, PartialEq)]
struct Vel(f32, f32, f32)... |
use super::*;
#[derive(Clone)]
pub struct TypeSpec(pub Row);
impl TypeSpec {
pub fn blob(&self) -> Blob {
self.0.blob(0)
}
}
|
#![allow(dead_code)]
struct ComplexRefs<'a> {
int_ref: &'a i32,
unsigned_ref: &'a u32,
str_ref: &'a str
}
fn main() {
// initialize 3 integers
let a : i32 = -423;
let c : i32 = 2321;
let d : u32 = 5;
let str_ref : &str = "hahaha";
let cr : ComplexRefs = ComplexRefs {
in... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
pub const CERTIFICATE_HASH_LENGTH: u32 = 20u32;
pub const EAPCODE_Failure: u32 = 4u32;
pub const EAPCODE_Request: u32 = 1u32;
pub const EAPCODE_Response: u32 = 2u32;
pub const EAPCODE_Success... |
use std::fmt;
use std::future::Future;
use std::io;
use std::io::{Read, SeekFrom, Write};
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll};
use actix::prelude::*;
use chrono::DateTime;
use fs2::FileExt;
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use serde_json;
use tokio::fs::Fil... |
use declarative_dataflow::scheduling::{AsScheduler, RealtimeScheduler, SchedulingEvent};
use std::time::Duration;
#[test]
fn test_schedule_now() {
let mut scheduler = RealtimeScheduler::new();
assert!(!scheduler.has_pending());
assert!(scheduler.until_next().is_none());
scheduler.event_after(Duration... |
use super::generator::Generator;
use super::Ctx;
pub enum FractalType {
Mandelbrot(f32),
Julia,
}
impl FractalType {
pub fn as_f32(&self) -> f32 {
match self {
Self::Mandelbrot(v) => *v,
Self::Julia => 3.0,
}
}
}
pub struct Renderer {
pub generator: Generat... |
extern crate ramp;
use rand;
pub use self::ramp::Int;
use extra_ops::{ModPow, RandInt, ToStrRadix};
impl ModPow for Int {
fn mod_pow(&self, exponent: &Self, modulus: &Self) -> Self {
self.pow_mod(exponent, modulus)
}
}
impl RandInt for Int {
fn get_rand_below(max: &Self) -> Self {
use se... |
use std::time::Duration;
use source::Empty;
use source::Source;
use source::Zero;
use Sample;
#[derive(Debug)]
enum MusicPlayerCommand {
Play,
Pause,
Stop,
NextTrack,
}
pub struct SourcesQueueController<S> {
command_channel: std::sync::mpsc::Sender<MusicPlayerCommand>,
sound_channel: std::sy... |
#![feature(plugin)]
#![feature(test)]
#![plugin(deuterium_plugin)]
#[allow(plugin_as_library)]
#[macro_use] extern crate deuterium_plugin;
#[macro_use] extern crate deuterium_orm;
extern crate time;
extern crate deuterium;
extern crate byteorder;
extern crate num;
#[macro_use] extern crate enum_primitive;
extern cra... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Security_Authorization_UI"))]
#[inline]
pub unsafe fn DSCreateISecurityInfoObject<'a, Param0: ::windows::core::IntoParam<'a, super::su... |
extern crate difference;
extern crate cobalt;
extern crate walkdir;
use std::path::Path;
use std::fs::{self, File};
use std::io::Read;
use walkdir::WalkDir;
fn run_test(name: &str) {
let source = format!("tests/fixtures/{}/", name);
let target = format!("tests/target/{}/", name);
let dest = format!("tests... |
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Pin assign register 0. Assign movable functions U0_TXD, U0_RXD, U0_RTS, U0_CTS"]
pub pinassign0: PINASSIGN0,
#[doc = "0x04 - Pin assign register 1. Assign movable functions U0_SCLC, U1_TXD, U1_RXD"]
pub pinassign1: PINASSI... |
use rand::{Rng, thread_rng};
use std::f64::consts::PI;
const TAU: f64 = PI * 2.0;
pub struct Synthesizer {
voices: Vec<Voice>,
}
impl Synthesizer {
pub fn new() -> Synthesizer {
Synthesizer {
voices: Vec::new(),
}
}
pub fn voice(&mut self, voice: Voice) {
self.voic... |
use std::process::{Child, Command};
use std::str;
use n3_machine_ffi::{LocalQuery, Machine, NetError, Program, Query, Result, WorkHandler};
use n3_torch_ffi::{ProcessMachine as ProcessMachineTrait, PyMachine};
use crate::python::PyMachineBase;
pub struct ProcessMachine {
process: Option<Child>,
handler: Opti... |
/*
* hurl (https://hurl.dev)
* Copyright (C) 2020 Orange
*
* 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 ... |
/*
Project Euler Problem 4:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
*/
fn main() {
let mut l = 0;
for x in 0..1000 {
for y in 0..1... |
pub mod generator;
use monster::Monster;
use theme::Keyword;
use std::collections::HashMap;
pub struct Dungeon {
pub rooms: Vec<Room>,
/// Vector index is source, value[CompassPoint] is destination. Length is
/// always equal to room count.
passages: Vec<Passages>,
}
impl Dungeon {
pub fn new(roo... |
use constants::*;
use utils::*;
use types::*;
use cipherstate::*;
#[cfg(feature = "nightly")] use std::convert::TryFrom;
#[cfg(not(feature = "nightly"))] use utils::TryFrom;
use symmetricstate::*;
use params::*;
use error::{ErrorKind, Result, InitStage, StateProblem};
/// A state machine encompassing the handshake ph... |
#[derive(PartialEq, Debug)]
pub enum KeypadDirection {
Up,
Down,
Left,
Right
}
pub fn char_to_keypad_direction(keypad_char: char) -> KeypadDirection {
match keypad_char {
'U' => KeypadDirection::Up,
'D' => KeypadDirection::Down,
'L' => KeypadDirection::Left,
'R' => K... |
use rand::random;
use hitable::{HitRecord, Hitable};
use material::Material;
use ray::Ray;
use vec3::{dot, Vec3};
//#[derive(Debug)]
pub struct Sphere {
pub center: Vec3,
pub radius: f32,
pub material: Box<dyn Material>,
}
impl Hitable for Sphere {
fn hit(&self, r: &Ray, t_min: f32, t_max: f32, rec: ... |
//!
//! division.rs
//!
//! Created by Mitchell Nordine at 02:34AM on November 02, 2014.
//!
//!
use num::{NumCast, FromPrimitive, ToPrimitive};
use std::ops::{Add, Sub};
use super::TimeSig;
pub type NumDiv = i64;
/// An enum with variants used to represent a musical division.
#[derive(Debug, Copy, Clone, PartialE... |
use crate::MenmosFS;
use super::{Error, Result};
impl MenmosFS {
pub async fn release_impl(&self, ino: u64, is_writable: bool) -> Result<()> {
log::info!("release i{}", ino);
let mut buffers_guard = self.write_buffers.lock().await;
if let Some(buffer) = buffers_guard.remove(&ino) {
... |
fn main() {
panic!("
The use of the dinghy crate is deprecated, use cargo-dinghy instead.
Install it with the following command:
\t$ cargo install cargo-dinghy
");
}
|
use super::*;
pub struct Player<'a> {
pub id: String,
pub name: String,
pub money: u32,
pub nodes: Vec<&'a mut node::Node>,
pub execs: Vec<exec::Exec>,
}
impl<'a> Player<'a> {
pub fn new(id: String, name: String, money: u32) -> Player<'a> {
let nodes: Vec<&'a mut node::Node> = Vec::new... |
use ::amethyst::controls::FlyControlTag;
use ::amethyst::renderer::{camera::ActiveCamera, Camera};
use ::amethyst::shrev::EventChannel;
use ::amethyst::core::*;
use ::amethyst::ecs::*;
use ::amethyst::input::*;
use serde::Serialize;
#[derive(new, Debug, Serialize, Deserialize)]
pub struct NoClip<T>
where
T: Bin... |
use crate::AlfredError;
use std::process::Command;
#[derive(Debug)]
pub struct BrowserActiveTabInfo {
pub url: String,
pub title: String,
}
const OSASCRIPT_OUTPUT_SPECIAL_SEPERATOR: &str = " fd850fc2e63511e79f720023dfdf24ec ";
pub fn get() -> Result<BrowserActiveTabInfo, Box<dyn std::error::Error>> {
deb... |
// 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 ... |
//! > winnow, making parsing a breeze
//!
//! `winnow` is a parser combinator library
//!
//! Quick links:
//! - [List of combinators][crate::combinator]
//! - [Tutorial][_tutorial::chapter_0]
//! - [Special Topics][_topic]
//! - [Discussions](https://github.com/winnow-rs/winnow/discussions)
//!
//! ## Aspirations
//!
... |
// `collect` mengkonsumsi iterator dan mengembalikan data berupa array/vector
fn main() {
let data = [1, 2, 3, 4, 5];
let data_string = ['a', 'b', 'c', 'd'];
simple_collect(&data);
turbofish_collect(&data);
make_string_collect(&data_string);
}
// simple `collect` dengan mengalikan 2 pada setia... |
use super::component_prelude::*;
#[derive(Default)]
pub struct Goal;
impl Component for Goal {
type Storage = NullStorage<Self>;
}
|
//! This module contains a DataFusion extension node to "split" a
//! stream based on an expression.
//!
//! All rows for which the expression are true are sent to partition
//! `0` and all other rows are sent to partition `1`.
//!
//! There are corresponding [`LogicalPlan`] ([`StreamSplitNode`]) and
//! [`ExecutionPla... |
// Copyright 2018 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 ... |
use nalgebra::Scalar;
use crate::Pose;
pub mod resampling;
#[derive(Clone, Debug)]
pub struct ParticleFilter<N: Scalar> {
pose: Vec<Pose<N>>,
weights: Vec<N>,
}
// impl<N> StateFilter<N> for ParticleFilter<N> {}
|
fn main()
{
let username = "foo";
let username = "bar";
println!("This is it: {}", username);
} |
extern crate serde;
extern crate serde_json;
use decisionengine::datasource::applicationdata::ApplicationDataV1;
use decisionengine::datasource::experian::ExperianV1_0;
use decisionengine::datasource::experian::ExperianV1_1;
use decisionengine::datasource::mocks::decisiondatafetcher::{MockedExperianV1_0Fetcher,
... |
pub mod handlers;
pub mod wheel;
use crate::{
io,
proto::{self, CommandKind, Event, EventKind, Rpc},
types::ErrorPayloadStack,
Error,
};
use crossbeam_channel as cc;
/// An event or error sent from Discord
#[derive(Debug)]
pub enum DiscordMsg {
Event(Event),
Error(Error),
}
#[async_trait::asy... |
use piston_window::{PistonWindow, WindowSettings};
use piston_window::{Context, G2d};
use piston_window::{rectangle, clear};
use piston_window::types::Color;
use piston_window::color::{BLACK, WHITE};
use crate::ball::Ball;
use crate::terrain::Terrain;
const BLOCK_SIZE:f64 = 25.0;
pub enum Col {
White,
}
pub fn ... |
// The MIT License (MIT)
//
// Copyright (c) 2015 FaultyRAM
//
// 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,... |
//! Locality-preserving maps between `(u32,u32)` and `u64`.
//!
//! The Hilbert space-filling curve and Z-Order are two maps between pairs of `u32` values and a
//! single `u64` value with the property that locality in both elements of the pair results in
//! locality in the larger value. Technically, the Z-Order does ... |
use clap::{App, Arg};
use iron_carrier::config::Config;
use std::process::exit;
#[tokio::main]
async fn main() {
let matches = App::new("Iron Carrier")
.version("0.1")
.author("Ilson Roberto Balliego Junior <ilson.balliego@gmail.com>")
.about("Synchronize your files")
.arg(
... |
use sqlx::Sqlite;
use sqlx_test::test_type;
test_type!(null(
Sqlite,
Option<i32>,
"NULL" == None::<i32>
));
test_type!(bool(Sqlite, bool, "FALSE" == false, "TRUE" == true));
test_type!(i32(Sqlite, i32, "94101" == 94101_i32));
test_type!(i64(Sqlite, i64, "9358295312" == 9358295312_i64));
// NOTE: This b... |
#[derive(Copy, Clone)]
pub struct Decoder;
impl toml_test_harness::Decoder for Decoder {
fn name(&self) -> &str {
"toml_edit"
}
fn decode(&self, data: &[u8]) -> Result<toml_test_harness::Decoded, toml_test_harness::Error> {
let data = std::str::from_utf8(data).map_err(toml_test_harness::Er... |
#[derive(Debug, Clone, PartialEq)]
pub enum Expr {
Number(f64),
Add(Box<Expr>, Box<Expr>),
Sub(Box<Expr>, Box<Expr>),
Mul(Box<Expr>, Box<Expr>),
Div(Box<Expr>, Box<Expr>),
Pow(Box<Expr>, Box<Expr>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum RuntimeError {
ZeroDivision,
}
impl Expr {
... |
use crate::prelude::*;
use std::os::raw::c_void;
#[repr(C)]
#[derive(Debug)]
pub struct VkCopyDescriptorSet {
pub sType: VkStructureType,
pub pNext: *const c_void,
pub srcSet: VkDescriptorSet,
pub srcBinding: u32,
pub srcArrayElement: u32,
pub dstSet: VkDescriptorSet,
pub dstBinding: u32,
... |
// 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 ... |
use super::Material;
use crate::{Color, Ray, Vec3};
pub struct Lambertian {
albedo: Color,
}
impl Lambertian {
pub fn new(albedo: Color) -> Self {
Self { albedo }
}
}
impl Material for Lambertian {
fn scatter(
&self,
_ray: &crate::Ray,
rec: &mut crate::HitRecord,
... |
//! phd is a small, easy-to-use Gopher server that tries to make
//! serving up a Gopher site quick and painless. Best used for local
//! development or low traffic Gopher sites.
#![allow(unused_must_use)]
#![warn(absolute_paths_not_starting_with_crate)]
#![warn(explicit_outlives_requirements)]
#![warn(unreachable_pub... |
use darling::ast::{Data, Style};
use proc_macro::TokenStream;
use quote::quote;
use syn::{Error, Type};
use crate::{
args,
args::{RenameRuleExt, RenameTarget},
utils::{get_crate_name, get_rustdoc, visible_fn, GeneratorResult},
};
pub fn generate(object_args: &args::OneofObject) -> GeneratorResult<TokenStr... |
extern crate proconio;
use proconio::input;
fn main() {
input! {
a: f64,
b: f64,
c: f64,
}
let f = |t: f64| a * t + b * (c * t * std::f64::consts::PI).sin();
let mut l = 0.0;
let mut r = 1000.0;
for _ in 0..100 {
let t = (l + r) / 2.0;
if f(t) < 100.0 {... |
use std::io::{BufReader, Cursor, Read, Seek, SeekFrom};
use std::path::Path;
use std::str;
use cloud_storage::{Error, Object};
use uuid::Uuid;
use crate::error::QuocoError;
use crate::formats::{Hashes, Names, ReferenceFormat};
use crate::object::fs_source::LOCK_FILE_NAME;
use crate::object::{Finish, Key, ObjectHash, ... |
use crate::prelude::*;
use std::os::raw::c_char;
use std::slice::Iter;
pub struct VkNames {
r_names: Vec<VkString>,
c_names: Vec<*const c_char>,
}
impl VkNames {
pub fn new(names: &[VkString]) -> Self {
let local: Vec<VkString> = names.iter().map(|s| s.clone()).collect();
VkNames {
... |
extern crate rayon;
mod structs;
mod heuristics;
pub use structs::{Dimension, PackInput, PackResult, PackErr, PackOptions, Bin};
pub use heuristics::{SortHeuristic, AreaSort, PerimeterSort, SideSort, WidthSort, HeightSort, SquarenessByAreaSort, SquarenessByPerimeterSort};
use self::structs::*;
use self::heuristics::... |
use std::{default::Default, time::Duration};
/// Contains Config properties which will be used by a Server or Client
#[derive(Clone, Debug)]
pub struct ConnectionConfig {
/// The duration to wait for communication from a remote host before
/// initiating a disconnect
pub disconnection_timeout_duration: Dur... |
pub mod colors;
pub mod camera;
pub mod renderer;
pub mod terrain;
pub mod deferred;
pub mod skybox;
|
use std::collections::HashMap;
use crate::singleton::SingletonDS;
use crate::datastore::{Read, Write};
use crate::error::*;
use crate::key::Key;
use crate::{Batch, Batching, Datastore, Txn, TxnDatastore};
use std::ops::{Deref, DerefMut};
#[derive(Debug, Default)]
pub struct InnerDB(HashMap<Key, Vec<u8>>);
pub type ... |
//! Bundles the `cipher` module into a CBC-mode block cipher, which
//! wraps and implements the `std::io::Read` and `std::io::Write`
//! interfaces.
//!
//! # Example:
//! ```
//! use std::fs;
//! use std::io::{BufReader, Read, Write};
//! use tea::io::{Reader, Writer};
//!
//! let tmp_dir = fs::TempDir::new("tea-read... |
// Copyright 2023 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agre... |
pub const SCREEN_WIDTH : usize = 64;
pub const SCREEN_HEIGHT : usize = 32;
pub trait DisplayOutput {
fn display_buffer (&mut self, buffer : &[u8 ; SCREEN_WIDTH/8 * SCREEN_HEIGHT]) ;
}
pub struct ScreenBuffer <'a> {
pub packed_pixels : [u8 ; SCREEN_WIDTH/8 * SCREEN_HEIGHT],
pub display_output : &'a mut... |
use std::sync::Arc;
use std::time::Duration;
use sourcerenderer_core::graphics::{
Backend,
SwapchainError,
};
use sourcerenderer_core::Platform;
use super::drawable::View;
use super::renderer_assets::{
RendererAssets,
RendererTexture,
};
use super::renderer_resources::RendererResources;
use super::ren... |
use cgl_math::{Vec2, Vec3, Vec4, barycentric};
use image::{Image, Color};
use shader::Shader;
use model::{Model, Vertex};
pub struct Renderer {
color: Image<Color>,
zbuf: Image<f32>,
}
impl Renderer {
pub fn with_dimensions(w: usize, h: usize) -> Self {
Renderer {
color: Image::with_di... |
use P09;
pub fn encode<T: Copy + PartialEq>(li: &Vec<T>) -> Vec<(usize, T)> {
P09::pack(li).iter().map(|x| (x.len(), x[0])).collect()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_encode() {
let li = vec![
'a', 'a', 'a', 'a', 'b', 'c', 'c', 'a', 'a', 'd', 'e', 'e', 'e', ... |
extern crate paillier;
#[cfg(not(feature="keygen"))]
fn main() {
println!("*** please run with 'keygen' feature ***")
}
#[cfg(feature="keygen")]
fn main() {
use paillier::*;
// generate a fresh keypair
let (ek, dk) = Paillier::keypair().keys();
// encrypt two values
let c1 = Paillier::encr... |
pub fn is_space_or_newline(c: char) -> bool {
c.is_whitespace() || c == '\n'
}
pub fn is_alphanumeric(c: char) -> bool {
c.is_alphanumeric() || c == '_'
}
pub fn is_operator(c: char) -> bool {
['+', '-', '/', '*', '^', '=', '>', '<', '&', '|']
.iter()
.any(|&x| x == c)
}
pub fn is_allowed... |
table! {
player (date) {
date -> Integer,
playcount -> Integer,
clear -> Integer,
epg -> Integer,
lpg -> Integer,
egr -> Integer,
lgr -> Integer,
egd -> Integer,
lgd -> Integer,
ebd -> Integer,
lbd -> Integer,
epr -> Int... |
use crate::message::Message;
pub trait Game {
fn update(&mut self, message: Message);
}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]... |
#[cfg(feature = "dynamic")]
extern crate pkg_config;
#[cfg(any(feature = "static", feature = "static-fallback"))]
extern crate cc;
use std::env;
use std::env::consts;
use std::path::Path;
fn main() {
if let Ok(include_dir) = env::var("LCMS2_INCLUDE_DIR") {
println!("cargo:include={}", include_dir);
}
... |
use serde_json::to_string;
use declarative_dataflow::{Uuid, Value};
use Value::{Aid, Bool, Instant, Number, String};
#[test]
fn test_serialization() {
assert_eq!(
to_string(&Aid(":edge".to_string())).unwrap(),
"{\"Aid\":\":edge\"}".to_string()
);
assert_eq!(
to_string(&String("foo"... |
use std::{collections::HashSet, fmt::Display};
use async_trait::async_trait;
use data_types::PartitionId;
use super::PartitionsSubsetSource;
/// A mock of [`PartitionsSubsetSource`], which returns based on subset inclusion.
#[derive(Debug)]
pub(crate) struct MockInclusionPartitionsSubsetSource {
partitions: Hash... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.