text stringlengths 8 4.13M |
|---|
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn add_two_ints(a: u32, b: u32) -> u32 {
a + b
}
#[wasm_bindgen]
pub fn fib(n: i32) -> i32 {
if n == 0 || n == 1 {
return n;
}
fib(n - 1) + fib(n + 2)
}
fn main() {
println!("Hello World");
let r = add_two_ints(1, 2);
println!("{}"... |
pub mod http_status;
pub mod response_helper;
|
use axgeom::*;
pub struct Symbol<'a>{
inner:&'a [Vec2<usize>]
}
impl<'a> Symbol<'a>{
pub fn get(&self)->&[Vec2<usize>]{
self.inner
}
pub fn into_inner(self)->&'a [Vec2<usize>]{
self.inner
}
}
pub struct SymbolTable{
inner:Vec<Vec<Vec2<usize>>>
}
impl SymbolTable{
pub fn lookup(&self,num:usize)... |
//! The AUTHENTICATE_MESSAGE defines an NTLM authenticate message that is sent from the client
//! to the server after the CHALLENGE_MESSAGE is processed by the client.
use super::{AvPair, DomainNameFields, Version, WorkstationFields};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Authenticate {
/// LmChallen... |
extern crate gl;
use cgmath::{Matrix4, perspective, Deg};
use std::ptr;
use crate::entities::entity::Entity;
use crate::shaders::static_shader::StaticShader;
use crate::toolbox::math;
const FOV: f32 = 70.0;
const NEAR_PLANE: f32 = 0.1;
const FAR_PLANE: f32 = 1000.0;
pub fn initialize(shader: &StaticShader) {
... |
//https://leetcode.com/problems/find-center-of-star-graph/submissions/
impl Solution {
pub fn find_center(edges: Vec<Vec<i32>>) -> i32 {
let mut ans = 0;
let mut cnt: Vec<i32> = vec![0; 100001];
for i in 0..edges.len() {
cnt[edges[i][0] as usize] += 1;
cnt[ed... |
use std::io::Cursor;
use crate::end_to_end_cases::{
server::TestService,
test_utils::{Fixture, RecordingSink},
};
use assert_matches::assert_matches;
use grpc_binary_logger_proto::{
grpc_log_entry::{EventType, Payload},
ClientHeader, Message, Metadata, MetadataEntry, ServerHeader, Trailer,
};
use grpc_... |
use std::{
pin::Pin,
task::{Context, Poll},
};
use crate::{actor::Actor, fut::future::ActorFuture};
mod and_then;
mod map_err;
mod map_ok;
pub use and_then::AndThen;
pub use map_err::MapErr;
pub use map_ok::MapOk;
mod private_try_act_future {
use super::{Actor, ActorFuture};
pub trait Sealed<A> {}
... |
use super::*;
pub struct SincronizadorCoordinador {
pub jugadores_handler: Vec<thread::JoinHandle<()>>,
pub jugadores_channels: Vec<Sender<mazo::Carta>>,
pub jugadores_ronda: Vec<Sender<bool>>,
pub pilon_central_cartas: Receiver<juego::Jugada>,
pub barrier: Arc<Barrier>
}
pub struct Sincronizador... |
extern crate winrt_notification;
use std::path::Path;
use winrt_notification::{
IconCrop,
Toast,
};
fn main() {
Toast::new("application that needs a toast with an image")
.hero(&Path::new("C:\\absolute\\path\\to\\image.jpeg"), "alt text")
.icon(
&Path::new("c:/this/style/works/t... |
//! inversion id type
use std::sync::Arc;
/// inversion id type
#[derive(
Clone,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
serde::Serialize,
serde::Deserialize,
)]
pub struct InvId(Arc<str>);
impl InvId {
/// inversion id constructor
pub fn new_raw(s: Box<str>) -> Self {
S... |
// 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... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(feature = "Web_Http_Diagnostics")]
pub mod Diagnostics;
#[cfg(feature = "Web_Http_Filters")]
pub mod Filters;
#[cfg(feature = "Web_Http_Headers")]
pub mod Headers;
#[repr(transparent)]
... |
// 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 ... |
// 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 crate::decode::Decode;
use crate::encode::Encode;
use crate::io::{Buf, BufMut};
use crate::postgres::protocol::TypeId;
use crate::postgres::{PgData, PgRawBuffer, PgTypeInfo, PgValue, Postgres};
use crate::types::{Json, Type};
use crate::value::RawValue;
use serde::{Deserialize, Serialize};
use serde_json::value::Ra... |
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
pub fn read_lines<P>(path: P) -> io::Result<io::Lines<io::BufReader<File>>>
where
P: AsRef<Path>,
{
let file = File::open(path)?;
Ok(io::BufReader::new(file).lines())
}
pub fn is_numeric_string_in_range(s: &str, min: usize, max: usize) ... |
// 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... |
//! libuefi clone of the ::std::borrow module
pub enum Cow<'heap, 'd, T: ?Sized>
where
T: 'd + ToOwned<'heap>
{
Owned(T::Owned),
Borrowed(&'d T)
}
impl<'bs, 'd, T: ?Sized> From<&'d T> for Cow<'bs, 'd, T>
where
T: 'd + ToOwned<'bs>
{
fn from(v: &'d T) -> Self {
Cow::Borrowed(v)
}
}
impl<'bs, 'd, T: ?Sized> ::co... |
//! Operator and utilities to source data from plain files containing
//! arbitrary json structures.
use std::cell::RefCell;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::path::Path;
use std::rc::Weak;
use std::time::{Duration, Instant};
use timely::dataflow::operators::generic::builder_rc::OperatorB... |
// Crates
extern crate chrono;
extern crate docopt;
extern crate rustc_serialize;
// Standard library imports
// Local modules
mod altdate;
// Crate imports
use chrono::Datelike;
use docopt::Docopt;
static VERSION: &'static str = "ddate (RUST implementaion of gnucoreutils) 0.1
Copyright (C) 2016 Marco Kaulea
Licens... |
use std::io;
use std::path::PathBuf;
#[derive(Debug)]
pub enum Error {
Json(serde_json::Error),
Io(io::Error),
Ini(ini::ini::ParseError),
SectionMissing,
FileNotFound(PathBuf),
HomeNotFound,
}
impl From<serde_json::Error> for Error {
fn from(error: serde_json::Error) -> Self {
Erro... |
#[cfg(all(not(target_arch = "wasm32"), feature = "gamepads"))]
use gilrs;
#[cfg(not(target_arch = "wasm32"))]
use glutin;
use image;
#[cfg(all(not(target_arch = "wasm32"), feature = "rodio"))]
use rodio;
use crate::graphics::{AtlasError, ImageError};
#[cfg(feature = "rusttype")]
use rusttype::Error as FontError;
#[cfg(... |
#[derive(Debug)]
struct RectangularArray<T> {
width: usize,
height: usize,
data: Vec<Vec<T>>,
}
fn main() {
let two_by_three_data = vec![vec![1, 2], vec![3, 4], vec![5, 6]];
let two_by_three = RectangularArray::<i32> {
width: 2,
height: 3,
data: two_by_three_data,
};
... |
use std::cell::RefCell;
use resource::Resource;
thread_local! {
static STDIN: RefCell<Resource> = RefCell::new(
Resource::open(b"std://in").unwrap()
);
static STDOUT: RefCell<Resource> = RefCell::new(
Resource::open(b"std://out").unwrap()
);
static STDERR: RefCell<Resource> = RefCe... |
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
fn main() {
let n: usize = parse_line().unwrap();
if n % 2 == 1 {
return;
}
dfs("".to_string(), n / 2, n / 2);
}
fn dfs(now: String, leftleft: usize, rightleft: usize) {
... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qsharedmemory.h
// dst-file: /src/core/qsharedmemory.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begi... |
//https://leetcode.com/problems/determine-color-of-a-chessboard-square/
impl Solution {
pub fn square_is_white(coordinates: String) -> bool {
let position_parity = coordinates.chars().nth(0).unwrap() as u8 - 'a' as u8
+ coordinates.chars().nth(1).unwrap() as u8 - '1' as u8;
... |
// 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 ... |
//! https://github.com/lumen/otp/tree/lumen/lib/megaco/src/engine
use super::*;
test_compiles_lumen_otp!(megaco_config);
test_compiles_lumen_otp!(megaco_config_misc);
test_compiles_lumen_otp!(megaco_digit_map);
test_compiles_lumen_otp!(megaco_edist_compress);
test_compiles_lumen_otp!(megaco_encoder);
test_compiles_lu... |
#[macro_use]
extern crate serde_derive;
use futures::future::ok;
use futures::prelude::*;
use hyper::{client::Client, Body, Uri};
use std::vec::Vec;
use tokio_core::reactor::Core;
use serde::de::DeserializeOwned;
#[derive(Deserialize, Serialize, Debug)]
struct Todo {
id: usize,
#[serde(rename = "userId")]
... |
use yew::prelude::*;
pub struct SmsTry {}
pub enum Msg {}
impl Component for SmsTry {
type Message = Msg;
type Properties = ();
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
SmsTry {}
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
true
}
... |
use tokio::net::TcpListener;
use tokio::prelude::*;
use futures::stream::StreamExt;
#[tokio::main]
async fn main() {
let addr = "127.0.0.1:6142";
let mut listener = TcpListener::bind(addr).await.unwrap();
// Here we convert the `TcpListener` to a stream of incoming connections
// with the `incoming` m... |
extern crate core;
extern crate ggez;
extern crate rand;
use ggez::{GameResult, Context};
use ggez::event::{self, Keycode, Mod};
use ggez::graphics::{self, Font};
use ggez::timer;
use rand::Rng;
mod ai;
mod animation;
mod bg;
mod bomb;
mod car;
mod center;
mod checkpoint;
mod globals;
mod hex;
mod map;
mod racer;
mod... |
use super::widget::WidgetKind;
use crate::{
cpu::CPU,
debug::{util::FromHexString, widget::Widget},
memory_map::Mem,
Dst, Src,
};
use crossterm::event::{KeyCode, KeyEvent};
use std::{borrow::Cow, io::Stdout};
use tui::{
backend::CrosstermBackend,
layout::{Alignment, Rect},
style::{Color, Sty... |
use std::{
error::Error,
fmt,
fs::File,
path::Path
};
use amethyst::{
assets::{AssetStorage, Handle, Loader},
core::{
math::Vector3,
transform::Transform
},
ecs::{Entity, Builder, World, WorldExt},
renderer::{
formats::texture::ImageFormat,
sprite::{Sp... |
use projecteuler::digits;
use projecteuler::helper;
use projecteuler::primes;
fn main() {
helper::check_bench(|| {
solve(4, 3);
});
//helper::check_bench(|| {
// solve(6, 4);
//});
assert_eq!(solve(4, 3)[1], [2969, 6299, 9629]);
dbg!(solve(6, 4));
//dbg!(solve(10, 5));
}
//n... |
use std::io;
use std::fs::File;
use std::io::BufRead;
use std::path::Path;
use std::str::FromStr;
pub fn read_lines<P>(filename: P) -> impl Iterator<Item = String> where P: AsRef<Path> {
let file = File::open(filename).expect("Failed to read file.");
io::BufReader::new(file)
.lines()
.map(|line... |
use super::map::Map;
use super::math::vector::Vec2;
use super::data_structures::heap::Heap;
extern crate ahash;
struct Node {
father: Option<std::rc::Rc<Node>>,
position: Vec2<i32>,
real_distance: i32,
}
fn heuristic(start_point: Vec2<i32>, mid_point: Vec2<i32>, end_point: Vec2<i32>) -> f32 {
let diff ... |
//!
//! Objects are accessed usually through Object Group layers.
//!
//! Objects in Tiled describe just a couple of things:
//! - Text
//! - Points
//! - Ellipses
//! - Polygons
//! - Polylines
//!
//! How you use these things is up to you. For example, Tile definitions in
//! Tilesets contain objects when col... |
use std::cell::{ RefCell, RefMut };
use std::rc::Rc;
use graphics::math::{ Scalar, Matrix2d };
use gfx_device_gl::{ Resources };
use util::texture_register::TextureRegister;
use game::input_state::InputState;
use game::Game;
pub struct UpdateContext<'a> {
pub width: u32,
pub height: u32,
pub input_state: ... |
//! Pretty print logs.
use crate::{Femme, Logger};
use log::{kv, Level, Log, Metadata, Record};
use std::io::{self, StdoutLock, Write};
// ANSI term codes.
const RESET: &'static str = "\x1b[0m";
const BOLD: &'static str = "\x1b[1m";
const RED: &'static str = "\x1b[31m";
const GREEN: &'static str = "\x1b[32m";
const Y... |
// Copyright 2016 Serde YAML Developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except acc... |
use std::fmt;
use std::ops::{Mul, Neg, MulAssign};
use rand::{Rand, Rng};
use num::One;
use structs::matrix::{Matrix3, Matrix4};
use traits::structure::{Dimension, Column, BaseFloat, BaseNum};
use traits::operations::{Inverse, ApproxEq};
use traits::geometry::{Rotation, Transform, Transformation, Translation, ToHomoge... |
// 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 ... |
fn main() {
let a = [1.0, 2.0, 3.0];
println!("{:?} {:?}", a[1], a[3]); // thread '<main>' panicked at 'index out of bounds: the len is 3 but the index is 3', main.rs:4
}
|
mod body;
mod calibration;
mod capture;
mod device;
mod device_configuration;
mod error;
mod frame;
mod tracker;
mod tracker_configuration;
mod playback;
pub use body::{
Body, Float2, Float3, Joint, Quaternion, Skeleton, joint_id,
};
pub use calibration::Calibration;
pub use capture::Capture;
pub use device::{Devi... |
// 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 crate::error::Error;
use math::{
partition::integer_interval_map::IntegerIntervalMap,
set::{
contiguous_integer_set::ContiguousIntegerSet,
ordered_integer_set::OrderedIntegerSet, traits::Intersect,
},
};
use num::{Integer, Num};
use std::collections::HashMap;
pub trait ChromIntervalValu... |
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 max_depth(root: Tree) -> i32 {
match root {
None ... |
use crate::backend::{self, Backend};
use crate::config::Config;
use crate::dir_cleaner::DirCleaner;
use anyhow::{Context, Result};
use base64::encode;
use sha1::{Digest, Sha1};
use std::cell::RefCell;
use std::fs;
use std::path::{Path, PathBuf};
pub trait RendererTrait {
fn render(
&self,
plantuml... |
// `without_boolean_right_errors_badarg` in unit tests
test_stdout!(with_false_right_returns_false, "false\n");
test_stdout!(with_true_right_returns_true, "true\n");
|
#![allow(dead_code)] // for now
use dynasmrt::x64::Assembler;
use dynasmrt::DynasmApi;
type GPR = u8;
struct GPRs {
bits: u16,
}
impl GPRs {
fn new() -> Self {
Self { bits: 0 }
}
}
static RAX: u8 = 0;
static RCX: u8 = 1;
static RDX: u8 = 2;
static RBX: u8 = 3;
static RSP: u8 = 4;
static RBP: u8... |
use crate::prelude::*;
use super::Api;
use crate::cache::Cache;
use std::collections::BTreeSet;
pub struct UpdatesApi;
#[derive(Debug, Deserialize, Clone)]
pub struct ModuleSpec {
module_name: String,
module_stream: String,
}
#[derive(Debug, Deserialize, Clone)]
pub struct UpdatesReq {
package_list: Vec<... |
use super::InlineObjectTrait;
use crate::{
heap::{
object_heap::HeapObject, symbol_table::impl_ord_with_symbol_table_via_ord, Heap,
InlineObject,
},
utils::{impl_debug_display_via_debugdisplay, DebugDisplay},
};
use candy_frontend::builtin_functions::{self, BuiltinFunction};
use derive_more:... |
extern crate core;
#[derive(Debug)]
pub struct Error;
/// Trait governing random number generation.
///
/// Generators may be infallible (never failing) or fallible. In the latter
/// case, only `try_fill` allows error handling; other functions may panic.
pub trait Rng {
/// Fill dest with random bytes.
/// ... |
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
use coruscant_nbt::as_nbt_array;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
#[non_exhaustive]
pub struct EntityData {
#[serde(rename = "id")]
pub id: Option<String>,
#[serde(rename = "Pos")]
pub pos: [f64; 3],
#[ser... |
// actor/mod.rs
mod player;
//mod computer;
pub use actor::player::Player;
//pub use actor::computer::Computer;
|
#![allow(dead_code)]
extern crate stackvec;
use stackvec::prelude::*;
use ::std::iter::{
self,
Iterator,
};
static NUMBERS: [u8; 9] = [
5, 8, 9, 10, 6, 7, 4, 6, 7
];
mod counted_instances {
use ::std::cell::Cell;
thread_local! {
static INSTANCES_COUNT: Cell<isize> = Cell::new(0);
}
#[derive(Debug)]
pub ... |
pub mod parsed_env;
|
// Copyright © 2017-2023 Trust Wallet.
//
// This file is part of Trust. The full Trust copyright notice, including
// terms governing use, modification, and redistribution, is contained in the
// file LICENSE at the root of the source code distribution tree.
use bs58::{decode::Result, Alphabet};
pub fn encode(input:... |
#![no_std]
extern crate cortex_m;
extern crate embedded_hal;
#[cfg(feature = "chip-efm32gg")]
extern crate efm32gg990 as registers;
#[cfg(feature = "chip-efr32xg1")]
extern crate efr32xg1 as registers;
pub mod time_util;
pub mod cmu;
pub mod gpio;
// Right now that's implemented only there, and does not have the i... |
pub struct Pmu;
const TEST_FAIL: u32 = 0x3333;
const TEST_PASS: u32 = 0x5555;
const TEST_RESET: u32 = 0x7777;
impl rustsbi::Pmu for Pmu {
fn pmu_counter_start(&mut self, counter_idx_base: usize, counter_idx_mask: usize, start_flags: usize, initial_value:u64) -> rustsbi::SbiRet{
rustsbi::SbiRet {
... |
use core::cmp;
use utils::ipoint::IPoint;
use utils::fpoint::FPoint;
#[derive(Clone, Copy, Debug)]
pub struct IRange {
pub start: IPoint,
pub end: IPoint,
}
impl IRange {
pub fn center(self) -> FPoint {
(self.end + self.start).float() * (0.5)
}
pub fn size(self) -> IPoint {
self.en... |
//! Implementation of command line option for running the querier
use crate::process_info::setup_metric_registry;
use super::main;
use clap_blocks::{
catalog_dsn::CatalogDsnConfig, object_store::make_object_store, querier::QuerierConfig,
run_config::RunConfig,
};
use iox_query::exec::Executor;
use iox_time::{... |
pub struct Register {
pub v0: u8,
pub v1: u8,
pub v2: u8,
pub v3: u8,
pub v4: u8,
pub v5: u8,
pub v6: u8,
pub v7: u8,
pub v8: u8,
pub v9: u8,
pub va: u8,
pub vb: u8,
pub vc: u8,
pub vd: u8,
pub ve: u8,
pub vf: u8,
}
impl Register {
... |
#[macro_use]
extern crate serde_json;
mod calculations;
use calculations::percentages;
fn main() {
println!(
"{}\n{}\n{}\n{}",
percentages::change_by_percentage(100.47, 25.0),
percentages::find_percentage_value(50.0, 30.0),
percentages::find_percentage_difference(25.0, 40.0),
... |
/*
Aim: wrap generated parser fns in struct
*/
use super::smtp::{command, session};
pub use super::smtp::{ParseError, ParseResult};
use model::command::{SmtpCommand, SmtpInput};
static PARSER: SmtpParser = SmtpParser;
pub trait Parser {
fn command<'input>(&self, input: &'input str) -> ParseResult<SmtpCommand>... |
use std::io::{
Error as IOError,
ErrorKind,
Read,
Result as IOResult,
};
use sourcerenderer_mdl::PrimitiveRead;
pub struct GlbHeader {
magic: u32,
version: u32,
pub length: u32,
}
impl GlbHeader {
pub fn read<R: Read>(reader: &mut R) -> IOResult<Self> {
let magic = reader.read... |
use pyo3::prelude::*;
use pyo3::types::IntoPyDict;
use super::base::{BuildArgs, BuildCode};
use super::graph::Args;
impl<'a> BuildCode<'a> for n3_program::Program {
type Args = ();
type Output = &'a PyAny;
fn build(&'a self, py: Python<'a>, (): Self::Args) -> PyResult<Self::Output> {
// Step 1. C... |
extern crate env_logger;
/// Tool that generates constraints from stdin to stdout.
extern crate telamon_gen;
use std::path::Path;
use std::process;
fn main() {
env_logger::init();
if let Err(process_error) = telamon_gen::process(
Some(&mut std::io::stdin()),
&mut std::io::stdout(),
&Pa... |
use crate::blog_clusters::TagHandle;
fn valid_date(year: i64, month: i64, day: i64) -> bool {
if year > 2200 || year < 2000 {
return false;
}
let leap = (((year % 4) == 0) && (year % 100 != 0)) || ((year % 400) == 0);
return match month {
1 | 3 | 5 | 7 | 8 | 10 | 12 => day <= 31 && day ... |
use super::*;
use std::cmp::{min, max, Ordering};
/// [0..1] should probably be somewhere close to 0.1
const MAX_DIFFICULTY_DELTA: f32 = 0.2;
/// Allows for evaluation of content for inclusion to dungeon.
pub trait Evaluate: Clone {
fn theme(&self) -> &[Keyword];
fn difficulty(&self) -> usize;
fn max_diff... |
/// for dan iterator
///
/// for in dapat digunakan untuk berinteraksi dengan `Iterator`
/// dalam beberapa cara.
/// jika tidak disebutkan(not specified) maka loop akan menerapkan fungsi `into_iter`
/// pada koleksi untuk mengubah kedalam iterator
///
/// Ada 3 fungsi yang akan mengembalikan pandangan yg berbed... |
use serde::{Deserialize, Serialize};
use serde::ser::{Serializer, SerializeStruct};
use crate::api::message::amount::{Amount, string_or_struct};
use crate::api::utils::tx_flags::*;
use std::error::Error;
use std::fmt;
#[derive(Debug)]
pub enum RelationType {
TRUST = 0,
AUTHORIZE = 1,
FREEZE = 3,
}
... |
extern crate seedlink;
use seedlink::SeedLinkClient;
#[test]
#[ignore]
fn streams() {
let mut slc = SeedLinkClient::new("rtserve.iris.washington.edu", 18000);
slc.connect(true).expect("bad hello");
let info = slc.available_streams().expect("bad streams");
let streams = info.streams();
for s in ... |
// 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 crate::interaction::SurfaceInteraction;
pub trait Texture<T> {
fn evaluate(&self, si: &SurfaceInteraction) -> T;
}
pub mod constant;
pub use constant::*;
|
fn main() {
let s1: String = String::new();
let s2: &str = "hello world";
let s3 = s2.to_string(); // Declare s3: String from s2
let s4 = String::from("like a declaring s3 from s2");
println!("s1: {}", s1);
println!("s2: {}", s2);
println!("s3: {}", s3);
println!("s4: {}", s4);
... |
//! Python bindings for needletail
use std::io::Cursor;
use pyo3::prelude::*;
use pyo3::{create_exception, wrap_pyfunction};
use crate::sequence::{complement, normalize};
use crate::{
parse_fastx_file as rs_parse_fastx_file, parse_fastx_reader, parser::SequenceRecord,
FastxReader,
};
create_exception!(needl... |
use cgmath::Vector3;
use std::marker::PhantomData;
use std::{f32, u32};
use soa_ray::{
SoAHit, SoAHitIter, SoAHitIterMut, SoAHitRef, SoARay, SoARayIter, SoARayIterMut, SoARayRef,
SoARayRefMut,
};
use sys;
pub type Ray4 = sys::RTCRay4;
pub type Hit4 = sys::RTCHit4;
pub type RayHit4 = sys::RTCRayHit4;
impl Ray... |
//! HAL for the STM32L0X3 family of microcontrollers
#![no_std]
pub use stm32l0x3;
pub mod exti;
pub mod flash;
pub mod gpio;
pub mod i2c;
pub mod lpusart;
pub mod prelude;
pub mod rcc;
pub mod time;
|
fn main() {
let t1 = ("tuple1", 1);
println!("{:?}", t1);
match t1 {
(_, v) => println!("{}", v)
}
let t2 = DataTuple("tuple2", 2);
println!("{:?}", t2);
match t2 {
DataTuple(s, _) => println!("{}", s)
}
}
#[derive(Debug)]
struct DataTuple(&'static str, i32);
|
// Copyright 2020 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 ... |
// 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 ... |
#![doc = include_str!("../README.md")]
#![cfg_attr(docsrs, feature(doc_cfg))]
// Due to `schema_introspection` test.
#![cfg_attr(test, recursion_limit = "256")]
#![warn(missing_docs)]
// Required for using `juniper_codegen` macros inside this crate to resolve
// absolute `::juniper` path correctly, without errors.
ext... |
//! Linux [io_uring].
//!
//! This API is very low-level. The main adaptations it makes from the raw
//! Linux io_uring API are the use of appropriately-sized `bitflags`, `enum`,
//! `Result`, `OwnedFd`, `AsFd`, `RawFd`, and `*mut c_void` in place of plain
//! integers.
//!
//! For a higher-level API built on top of th... |
#[doc = "Reader of register CC"]
pub type R = crate::R<u32, super::CC>;
#[doc = "Reader of field `POL`"]
pub type POL_R = crate::R<bool, bool>;
#[doc = "Reader of field `PTPCEN`"]
pub type PTPCEN_R = crate::R<bool, bool>;
impl R {
#[doc = "Bit 17 - LED Polarity Control"]
#[inline(always)]
pub fn pol(&self) ... |
//! Generates markdown code for documentation comments
//! of the output Rust crate.
use rust_code_generator::rust_type_to_code;
use rust_type::RustType;
use rust_info::{RustMethodSelfArgKind, RustMethodArgumentsVariant, RustTypeDeclaration,
RustTypeDeclarationKind, RustMethodScope, RustEnumValue, Rust... |
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
use num::{integer::Roots, BigUint, Integer, PrimInt};
use primal::is_prime;
use std::{collections::BTreeMap, rc::Rc};
fn prime_sum_u64(i: u64, j: u64) -> u64 {
// The vast majority are clones of others so sticking them into a rc to avoid the... |
use std::{
collections::HashMap,
io::{stdin, stdout, Write},
rc::Rc,
vec,
};
use crate::types::{
dot_pair::DotPair,
exception::Exception,
list::{List, ListItem},
struct_declare::Struct,
value::Value,
DynType,
};
fn lang_new(args: Value) -> Result<Value, Exception> {
let mut... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtGui/qrasterwindow.h
// dst-file: /src/gui/qrasterwindow.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin ... |
#![feature(link_args)]
#![feature(libc)]
extern crate libc;
use libc::c_int;
use libc::c_float;
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufReader};
use std::sync::Arc;
use std::thread;
use std::env;
#[link_args = "-L./ -lbs -lsniper_roi"]
#[link(name = "bs", kind="static")]
#[link(name = "snip... |
// NOW_MOUSE_MSG
use num_derive::FromPrimitive;
#[derive(Encode, Decode, FromPrimitive, Debug, PartialEq, Clone, Copy)]
#[repr(u8)]
pub enum MouseMessageType {
Position = 0x01,
Cursor = 0x02,
Mode = 0x03,
State = 0x04,
}
__flags_struct! {
MousePositionFlags: u8 => {
same = SAME = 0x01,
... |
use std::fmt::{self, Debug, Formatter};
use std::marker::PhantomData;
use std::time::Duration;
use enet_sys::{
enet_peer_disconnect, enet_peer_disconnect_later, enet_peer_disconnect_now, enet_peer_receive,
enet_peer_reset, enet_peer_send, ENetPeer, _ENetPeerState,
_ENetPeerState_ENET_PEER_STATE_ACKNOWLEDGI... |
use procon_reader::ProconReader;
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let n: usize = rd.get();
let a: Vec<u64> = rd.get_vec(n);
// a[0] + max
// a[0] * 2 + a[1] + max * 2
// a[0] * 3 + a[1] * 2 + a[2] + max * 3
let mut max = 0;
l... |
use ffi;
use libc;
use AsLua;
use AsMutLua;
use LuaContext;
use LuaRead;
use Push;
use PushGuard;
use std::marker::PhantomData;
use std::fmt::Debug;
use std::mem;
use std::ptr;
/// Wraps a type that implements `FnMut` so that it can be used by hlua.
///
/// This is only needed because of a limitation in Rust's infer... |
// 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 fuchsia_async as fasync;
use futures::{self, task::Poll, FutureExt};
use waitgroup::*;
#[fasync::run_singlethreaded]
#[test]
async fn does_not_termina... |
use super::service::Elapsed;
use crate::Error;
use futures01::{try_ready, Async, Future, Poll};
use std::{
cmp,
time::{Duration, Instant},
};
use tokio01::timer::Delay;
use tower::retry::Policy;
pub enum RetryAction {
/// Indicate that this request should be retried with a reason
Retry(String),
///... |
use huffman::*;
use binary_reader::*;
use std::io::{Read, Write, BufReader};
use std::fs::File;
fn dfs<R: Read>(input: &mut BinaryReader<R>) -> Node {
if input.read_bit() == 1 {
let symbol = input.read_u8();
Node::Leaf(symbol)
} else {
let left = dfs(input);
let right = dfs(inpu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.