text stringlengths 8 4.13M |
|---|
use super::*;
#[test]
fn without_timeout_returns_milliseconds_remaining_and_does_not_send_timeout_message() {
with_timer_in_same_thread(|milliseconds, message, timer_reference, process| {
let start_monotonic = freeze_timeout();
freeze_at_timeout(start_monotonic + milliseconds / 2 + Milliseconds(1))... |
use std::path::PathBuf;
use rscript::Hook;
use serde::{Deserialize, Serialize};
// Reexport crossterm event types
pub mod event {
pub use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
}
pub mod color {
pub use crossterm::style::Color;
}
macro_rules! hookit {
(Hook => $hook: id... |
use stone::{Stone, StoneColor};
pub struct Board {
pub size: u32,
board: Vec<Stone>,
}
impl Board {
pub fn new(size: u32) -> Board {
let mut board = Vec::with_capacity((size ^ 2) as usize);
for _ in 0..size {
for _ in 0..size {
board.push(Stone::liberty());
... |
use crate::errors::{ParsingError, Result};
/// Try to parse the given array of bytes into an f64, by first converting
/// it to the corresponding ASCII (or even here, UTF-8) values.
pub fn parse_f64(value: &[u8]) -> Result<f64> {
let res = std::str::from_utf8(value)?;
let res_f64 = res.parse::<f64>()?;
Ok(... |
use std::io::{Error, ErrorKind};
use paho_mqtt::AsyncClient;
use serde_json::from_str;
use r2d2::Pool;
use r2d2_postgres::{PostgresConnectionManager, postgres::NoTls};
use crate::credentials::{
generate_mqtt_hash,
generate_mqtt_password,
generate_username
};
use crate::db_manager::{
add_elements_to_... |
// Copyright © 2016-2017 VMware, Inc. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use vr::vr_fsm::{VrState, State};
use vr::VrCtx;
/// The replica has left and has told the namespace manager to shut it down.
///
/// It doesn't respond to any messages from here on out
state!(Shutdown {
ctx: VrCtx
}... |
use std::ops::Neg;
use pos::*;
#[derive(Copy,Clone,Debug,PartialEq,Eq)]
pub enum Rotation {
Clockwise,
CounterClockwise
}
#[derive(Copy,Clone,Debug,PartialEq,Eq)]
pub enum Direction {
MainDirection(MainDirection),
SubDirection(SubDirection)
}
#[derive(Copy,Clone,Debug,PartialEq,Eq)]
pub enum MainDire... |
use std::fs;
use std::io::Write;
fn float_min(a: f64, b: f64) -> f64 {
if a < b {
a
} else {
b
}
}
fn float_max(a: f64, b: f64) -> f64 {
if a < b {
b
} else {
a
}
}
fn main() {
let args: Vec<_> = std::env::args().skip(1).collect();
let data = fs::read_to_string(format!("{}.in", args[... |
pub fn main() {
println!("\n-- 19.3 advanced types\n");
newtype_for_type_safety_and_abstraction();
the_never_type_that_never_returns();
dynamically_sized_types_and_the_sized_trait();
println!("\n-- 19.4 advanced functions and closures\n");
advanced_functions_and_closures();
}
fn advanced_functi... |
// 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 agreed to ... |
use std::f64::consts;
pub fn normal(x: &f64, mu: &f64, sig: &f64) -> f64 {
let sqrt_two_pi = (2.0 * consts::PI).sqrt();
let norm_dist = (-(x - mu).powf(2.0)/2.0 / sig.powf(2.0) / sqrt_two_pi * sig).exp();
norm_dist
}
|
// 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::Error;
use loading::*;
use semver::Version;
use std::ffi::CStr;
use std::mem::transmute;
use std::os::raw::c_char;
use std::path::PathBuf;
pub fn find_python() -> Result<PathBuf, Error> {
let locations = get_candidate_locations();
for path in locations {
unsafe {
match load_libra... |
// 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 hashbrown::HashSet;
use std::iter::FromIterator;
pub fn run() {
let input = include_str!("input/day6.txt").trim();
println!("{}", exercise_1(&input));
println!("{}", exercise_2(&input));
}
fn exercise_1(input: &str) -> u32 {
let mut it = input.lines();
let mut sum = 0;
while let Some(x) = ... |
#[derive(Debug, Clone, PartialEq)]
pub enum Error {
StreamNotReadable,
StreamNotWritable,
SizeLimitExceeded(usize),
InvalidData,
InvalidHeader(String),
MissingHeader(String),
}
|
use embedded_graphics::{
draw_target::DrawTarget,
prelude::{PixelColor, Primitive},
primitives::{PrimitiveStyle, PrimitiveStyleBuilder, StrokeAlignment},
Drawable,
};
use embedded_gui::{
geometry::{measurement::MeasureSpec, BoundingBox, MeasuredSize, Position},
widgets::{
graphical::chec... |
use super::*;
#[test]
fn without_reference_errors_badarg() {
run!(
|arc_process| {
(
Just(arc_process.clone()),
strategy::term::is_not_reference(arc_process.clone()),
options(arc_process.clone()),
)
},
|(arc_process, ti... |
/// Magic number to be used shard indices and shard ids in "kafkaless".
pub(crate) const TRANSITION_SHARD_NUMBER: i32 = 1234;
/// In kafkaless mode all new persisted data uses this shard id.
pub(crate) const TRANSITION_SHARD_ID: ShardId = ShardId::new(TRANSITION_SHARD_NUMBER as i64);
/// In kafkaless mode all new persi... |
// https://adventofcode.com/2018/day/2
use std::fs::File;
use std::io::{BufRead, BufReader};
pub fn puzzle1() {
let filename = "input/2.txt";
let file = File::open(filename).expect("There was a problem opening the file:");
let (mut two_count, mut three_count) = (0, 0);
let mut frequencies = [0u16; 25... |
#![warn(missing_docs)]
//! Crate to (hopefully) provide a working userspace driver
//! for XBOX controllers, like xpad
use crossbeam::thread;
use crossbeam::thread::ScopedJoinHandle;
use libusb::{Context, Result};
use devices::Controller;
use crate::protocol::{Command, Protocol};
use crate::uinput::UInputHandle;
use... |
fn accumulate_sum(v: &Vec<usize>) -> Vec<usize> {
let mut res = vec![0; v.len() + 1];
for i in 1..res.len() {
res[i] += v[i - 1] + res[i - 1];
}
res
} |
use std::ops;
use crate::IndexSet;
use rustpython_compiler_core::bytecode::{
CodeFlags, CodeObject, CodeUnit, ConstantData, InstrDisplayContext, Instruction, Label, OpArg,
};
use rustpython_parser_core::source_code::{LineNumber, SourceLocation};
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub struct BlockIdx(pub... |
// 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 agreed to ... |
// Most of this was stolen from https://github.com/unixporn/robbb/blob/master/src/extensions.rs
// The MIT License (MIT)
//
// Copyright (c) 2021 ElKowar
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal... |
extern crate wppr;
use std::path::PathBuf;
use wppr::commands::*;
use wppr::config::*;
use wppr::pipeline::*;
use wppr::wordpress::*;
#[path = "./testfns.rs"]
mod testfns;
fn get_test_plugin_index() -> String {
testfns::get_tests_dir("data/plugins/test-plugin/plugin.php")
.to_str()
.unwrap()
... |
use std::io;
fn safe_div(n: i32, d: i32) -> Option<i32> {
if d == 0 {
return None;
}
return Some(n/d);
}
fn main() {
println!("Please input your numerator.");
let mut numerator = String::new();
io::stdin().read_line(&mut numerator)
.expect("Failed to read line");
let numera... |
use std::iter::FromIterator;
fn react_polymer(poly: &mut Vec<char>, start_idx: usize) -> (bool,usize)
{
let mut remove_idx = 0usize;
for c in start_idx+1..poly.len() {
let PC = poly[c-1].to_ascii_uppercase();
let C = poly[c].to_ascii_uppercase();
if PC == C {
if poly[c-1] !=... |
/*!
# Macro Usage
```
use cloudevents::cloudevent_v1_0;
use cloudevents::{Data, CloudEventBuilder};
use cloudevents::v1_0::CloudEventV1_0;
use failure::Error;
let event : Result<CloudEventV1_0, Error> = cloudevent_v1_0!(
event_type: "test type",
source: "http://www.google.com",
event_id: "id",
time: ... |
use std::any::Any;
use std::io::BufRead;
fn main() {
let mut closure = assert_closure({
#{script}
});
let stdin = std::io::stdin();
let mut it = stdin.lock().lines();
while let Some(Ok(line)) = it.next() {
let output = closure(line);
let display = {
let output_any: &dyn Any = &output;
... |
use std::collections::HashMap;
use legion::systems::{
Builder,
CommandBuffer,
};
use legion::world::SubWorld;
use legion::{
component,
maybe_changed,
Entity,
EntityStore,
IntoQuery,
};
use log::trace;
use sourcerenderer_core::{
Matrix4,
Quaternion,
Vec3,
};
pub struct Transform... |
extern crate futures;
extern crate futures_cpupool;
extern crate grpc;
extern crate protobuf;
mod empty;
pub mod api;
pub mod apigrpc;
pub mod apigrpc_grpc;
pub mod realtime;
|
// Copyright (c) 2020 Sam Blenny
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
#![forbid(unsafe_code)]
pub mod v1;
|
use {
amethyst::{core::Time, derive::SystemDesc, ecs::prelude::*},
log,
std::{collections::VecDeque, time::Duration},
};
pub struct FrameRate {
total_time: Duration,
frame_times: VecDeque<Duration>,
period: Duration,
next_report: Duration,
}
impl FrameRate {
pub fn update(&mut self, dt... |
use object_chain::Chain;
use crate::{
geometry::{axis_order::Vertical, BoundingBox},
widgets::{
layouts::linear::{
layout::LinearLayout, private::LayoutDirection, Cell, CellWeight, ElementSpacing,
NoSpacing, NoWeight, WithSpacing,
},
Widget,
},
};
/// Constr... |
extern crate byteorder;
extern crate libc;
#[macro_use]
extern crate plugkit;
use std::io::{Cursor, Error, ErrorKind};
use byteorder::BigEndian;
use plugkit::token::Token;
use plugkit::reader::ByteReader;
use plugkit::layer::{Confidence, Layer};
use plugkit::context::Context;
use plugkit::worker::Worker;
use plugkit:... |
use file_reader;
const INPUT_FILENAME: &str = "input.txt";
#[derive(Debug, PartialEq)]
enum Action {
North,
South,
East,
West,
Left,
Right,
Forward,
}
#[derive(Debug)]
struct Instruction {
action: Action,
value: u32,
}
#[derive(Debug)]
struct Ship {
instructions: Vec<Instruct... |
#[doc = "Reader of register PLL1DIVR"]
pub type R = crate::R<u32, super::PLL1DIVR>;
#[doc = "Writer for register PLL1DIVR"]
pub type W = crate::W<u32, super::PLL1DIVR>;
#[doc = "Register PLL1DIVR `reset()`'s with value 0x0101_0280"]
impl crate::ResetValue for super::PLL1DIVR {
type Type = u32;
#[inline(always)]... |
#![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 IJsonArray(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IJsonArray {
type Vtable = IJsonArray_abi;
con... |
use std::io::prelude::*;
use std::str::FromStr;
fn parse( s : String ) -> (i32,i32) {
let d : Vec<i32> = s.split_whitespace().map(|x| i32::from_str(x).unwrap()).collect();
(d[0],d[1])
}
fn ans( a:i32, b:i32 ) -> i32 {
let mut s = a + b;
let mut n = 1;
while s >= 10 {
s = s / 10... |
// =========
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use std::process::exit;
const MOD: usize = 1000000007;
macro_rules! input {
(source = $s:expr, $($r:tt)*) => {
let mut iter = $s.split_whitespace();
input_inner!{iter, $($r)*}
};
($($r:tt)*) => {
let s... |
use std::convert::TryFrom;
use log::{debug, warn};
use crate::cuda::Device;
use crate::device::{PciId, Vendor};
use crate::error::{GPUError, GPUResult};
// NOTE vmx 2021-04-14: This is a hack to make sure contexts stay around. We wrap them, so that
// `Sync` can be implemented. `Sync` is needed for lazy static. Thes... |
use cgmath::{Vector2, Vector3, Vector4};
use buffer::Buffer;
use device::Device;
use geometry::Geometry;
use sys::*;
use {BufferType, CurveType, Format, GeometryType};
pub struct BsplineCurve<'a> {
device: &'a Device,
pub(crate) handle: RTCGeometry,
pub vertex_buffer: Buffer<'a, Vector4<f32>>,
pub ind... |
#[cfg(test)]
pub mod data {
extern crate serde;
extern crate serde_json;
use std::f64;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
#[allow(non_snake_case)]
#[derive(Serialize, Deserialize)]
pub struct TestDataInfo {
pub description: String,
pub ... |
extern crate core;
extern crate futures;
pub mod filter_fold;
pub use filter_fold::FilterFoldStream;
pub mod stream_sequence;
pub use stream_sequence::SequenceStream;
|
use fixedbitset::FixedBitSet;
use std::borrow::Borrow;
use std::borrow::Cow;
use std::fmt;
use std::ops::Range;
use std::str::FromStr;
use parser;
use parser::Cell;
use parser::ClueList;
use parser::GridLine;
pub trait LineHint: fmt::Debug {
fn check(&self, line: &Line) -> bool;
fn apply(&self, line: &mut Lin... |
use std::collections::VecDeque;
use super::{FunctionData, Label, Map, Set, CapacityExt};
pub type FlowGraph = Map<Label, Set<Label>>;
pub type Dominators = Map<Label, Label>;
impl FunctionData {
fn preferred_capacity(&self, start: Label) -> usize {
if start == self.entry() {
self.blocks.len(... |
use std::cmp::Ordering;
use std::collections::HashMap;
use std::io::Write;
use std::mem::size_of;
use std::sync::Arc;
use uuid::Uuid;
use crate::prelude::*;
use crate::primitives::*;
use crate::time::{MergeTimestamp, TtlTimestamp};
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
pub struct ColumnId( pu... |
extern crate rusty_machine;
extern crate rand;
use rand::{random, Closed01};
use std::vec::Vec;
use rusty_machine::learning::nnet::{NeuralNet, BCECriterion};
use rusty_machine::learning::toolkit::regularization::Regularization;
use rusty_machine::learning::optim::grad_desc::StochasticGD;
use rusty_machine::linalg::m... |
extern crate monkey;
use std::vec;
use monkey::ast::*;
use monkey::lexer::*;
use monkey::parser::*;
use monkey::token::*;
#[test]
fn let_statements_1() {
let input = "
let x = 5;
let y = 10;
let foobar = 838383;
";
let l = Lexer::new(input.chars().collect());
let mut p = Parser::new(l);
let pro... |
use std::mem;
mod sh;
mod ctrlflw;
mod structures;
mod patternmatch;
mod closures;
const MEANING_OF_LIFE:u8 = 42;
static mut KAKAJUNN:i32 = 123;
fn basics(){
// unsigned 0 ..255
let a:u8 = 123; // 8bits
println!("a= {}", a);
//a = 456;
//mut
let mut b:i8 = 0; //mutable
println!("b = {}... |
use priority_queue::PriorityQueue;
use std::collections::HashMap;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
struct Deps {
fw: HashMap<char, Vec<char>>,
pq: PriorityQueue<char, (i32, i32)>,
}
fn prepare(v: &[(char, char)]) -> Deps {
let mut forward = HashMap::new();
let mut backw... |
// 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 parking_lot::RwLock;
use std::sync::Arc;
use futures::lock::Mutex;
use futures::TryStreamExt;
use fidl::endpoints::ServiceMarker;
use fidl_fuchsia_set... |
use embedded_hal::{
digital::v2::{InputPin, OutputPin},
timer::CountDown,
};
use heapless::FnvIndexMap;
use nb::block;
pub static DIGIT: [u8; 22] = [
0x3F, /*0*/
0x06, /*1*/
0x5B, /*2*/
0x4F, /*3*/
0x66, /*4*/
0x6D, /*5*/
0x7D, /*6*/
0x07, /*7*/
0x7F, /*8*/
0x6F, /*9*/
... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Networking_WinSock"))]
pub struct UAL_DATA_BLOB {
pub S... |
//! Linux LibOS entrance
#![deny(warnings, unused_must_use, missing_docs)]
#![feature(thread_id_value)]
extern crate log;
use linux_loader::*;
use linux_object::fs::STDIN;
use rcore_fs_hostfs::HostFS;
use std::io::Write;
/// main entry
#[async_std::main]
async fn main() {
// init loggger for debug
init_logge... |
#[macro_use]
extern crate assert_approx_eq;
extern crate byteorder;
extern crate colored;
extern crate itertools;
extern crate ndarray;
extern crate num_cpus;
extern crate openmp_sys;
extern crate serde;
extern crate serde_json;
extern crate structopt;
#[macro_use]
extern crate lazy_static;
use structopt::clap::{self... |
use core::u64;
/// Absolute value (magnitude) (f64)
/// Calculates the absolute value (magnitude) of the argument `x`,
/// by direct manipulation of the bit representation of `x`.
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn fabs(x: f64) -> f64 {
// On wasm32 we know that LLVM's intrinsic wil... |
use crate::protocol::parts::option_part::OptionId;
use crate::protocol::parts::option_part::OptionPart;
// An Options part that is used to differentiate between primary and secondary
// connections.
pub type SessionContext = OptionPart<SessionContextId>;
#[derive(Debug, Eq, PartialEq, Hash)]
pub enum SessionContextId... |
use crate::auto_save::ShouldSave;
use serde::Serialize;
/// Super simplistic token-based authentification.
#[derive(Serialize, Deserialize, Clone, Default)]
pub struct Auth {
pub token: String,
#[serde(skip)]
pub validated: bool,
#[serde(skip)]
pub validating: bool,
#[serde(skip)]
pub upda... |
//! config_test.rs
//!
//! Integration tests for configurations.
extern crate toml;
extern crate wppr;
#[path = "./testfns.rs"]
mod testfns;
use std::path::PathBuf;
use std::fs::File;
use std::io::Read;
use wppr::config::*;
#[test]
fn test_configuration_is_loaded_from_toml() {
let src_toml = testfns::get_tests_... |
use crate::view_controller::{FontFacePtr, ViewController, ViewControllerPtr};
use carnelian::FontFace;
use failure::Error;
use fidl::endpoints::{create_endpoints, create_proxy, RequestStream};
use fidl_fuchsia_ui_app as viewsv2;
use fidl_fuchsia_ui_gfx as gfx;
use fidl_fuchsia_ui_scenic::{ScenicMarker, ScenicProxy};
us... |
pub mod user;
pub use user::{Password, UserLite, UserUnchecked, User}; |
fn main(){
let mut a1:f64 = 1.0;//mutable
let b = 0f32;//immutable
a1 = 10.0;
let a1 = a1;//now a1 is immutable
}
|
// extern crate reqwest;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
// use reqwest;
fn main() {
let args: Vec<String> = env::args().collect();
let day = &args
.get(1)
.expect("no day arg passed")
.parse::<i32>()
.expect("invalid day (expect... |
use std::fmt::Debug;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum DeserializationError {
#[error("could not parse value '{value}' to enum variant of '{enum_name}'")]
StringToEnumParseError { enum_name: String, value: String },
#[error("Error while deserializing")]
SerdeError(#[from] serde_jso... |
/*
* @lc app=leetcode.cn id=206 lang=rust
*
* [206] 反转链表
*
* https://leetcode-cn.com/problems/reverse-linked-list/description/
*
* algorithms
* Easy (58.20%)
* Total Accepted: 36.6K
* Total Submissions: 62.8K
* Testcase Example: '[1,2,3,4,5]'
*
* 反转一个单链表。
*
* 示例:
*
* 输入: 1->2->3->4->5->NULL
* 输出: ... |
use crate::TimeTracker;
use directories::UserDirs;
use std::fs;
use std::fs::OpenOptions;
use std::io::Write;
use std::path::PathBuf;
#[allow(dead_code)]
fn not_supported() {
println!("Schedule configuration is not supported on your operating system");
}
fn get_plist_file_contents() -> String {
format!(
... |
use super::*;
use proptest::strategy::Strategy;
#[test]
fn without_local_reference_right_returns_false() {
run!(
|arc_process| {
(
strategy::term::local_reference(arc_process.clone()),
strategy::term(arc_process.clone())
.prop_filter("Right c... |
pub fn sum(slice: &[i32]) -> i32 {
slice.iter().sum()
}
pub fn dedup(vs: &Vec<i32>) -> Vec<i32> {
vs.iter().fold(vec![], |mut acc, item| {
if !acc.contains(item) {
acc.push(*item);
}
acc
})
}
pub fn filter(vs: &Vec<i32>, pred: &Fn(i32) -> bool) -> Vec<i32> {
vs.ite... |
#![deny(rust_2018_idioms)]
pub mod monitoring;
pub mod state;
#[cfg(feature = "p2p")]
pub mod p2p_network;
|
use std::io;
use std::io::{BufRead, Read};
fn into_vec<T: Read>(file: T) -> Vec<u32> {
let reader = io::BufReader::new(file);
let mut result = Vec::<u32>::new();
for line in reader.lines() {
line.map(|str| result.push(str.parse::<u32>().unwrap()))
.unwrap();
}
result
}
fn sum_o... |
// Skeleton code for your Rust projects
// I added several comments and annotations to this file.
// _Please_ read them carefully. They are very important.
// The most important comments are all annotated with "NOTE/WARNING:"
// I will grade your code quality primarily on how "idiomatic" your Rust
// code is, and how... |
mod with_map;
use proptest::prop_assert_eq;
use proptest::strategy::Strategy;
use proptest::test_runner::{Config, TestRunner};
use liblumen_alloc::atom;
use crate::maps::take_2::result;
use crate::test::strategy;
use crate::test::with_process_arc;
#[test]
fn without_map_errors_badmap() {
with_process_arc(|arc_p... |
use std::ops::Deref;
struct WhatThe<F>(F);
impl<F> WhatThe<F> {
fn new(x: F) -> WhatThe<F> {
WhatThe(x)
}
}
impl<F> Deref for WhatThe<F> {
type Target = F;
fn deref(&self) -> &F {
&self.0
}
}
fn main() {
let x = 5;
let y = &x;
let z = Box::new(x);
let a = WhatThe... |
fn read_event_handlers(&Vec<EventHandlers>) {
//...
}
fn push_event_handlers(&mut Vec<EventHandlers>) {
//...
} |
extern crate levenshtein;
fn main() {
let args: Vec<String> = std::env::args().collect();
let (str1, str2) = match args.len() {
l if l >= 3 => {
(&args[1], &args[2])
},
_ => panic!("Error: At least two command-line parameters must be provided.")
};
let chars1: Vec<c... |
#[cfg(feature = "profiler")]
macro_rules! profile_function {
($($arg:expr)?) => {
puffin::profile_function!($($arg)?);
};
}
#[cfg(feature = "profiler")]
macro_rules! profile_scope {
($id:expr $(,$arg:expr)?) => {
puffin::profile_scope!($id $(,$arg)?);
};
}
#[cfg(not(feature = "profiler"... |
#![feature(core_intrinsics, lang_items)]
#![no_std]
mod gpio;
mod watchdog;
use core::intrinsics::{volatile_store, volatile_load};
const GPFSEL2: u32 = 0x3F20_0008;
const GPSET0: u32 = 0x3F20_001C;
const GPCLR0: u32 = 0x3F20_0028;
const GPIO20: u32 = 1 << 20;
const GPIO21: u32 = 1 << 21;
const GPIO22: u32 = 1 << ... |
use crate::rect::Rect;
use crate::{MAP_HEIGHT, MAP_WIDTH};
use rltk::{Algorithm2D, BaseMap, Console, Point, RandomNumberGenerator, Rltk, RGB};
use specs::prelude::*;
use std::cmp::{max, min, Ordering};
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum TileType {
Wall,
Floor,
}
pub trait Map {
fn tiles... |
use crate::codec::{Decode, Encode};
use crate::{remote_type, RemoteEnum, RemoteObject};
use std::collections::HashSet;
remote_type!(
/// Contracts manager. Obtained by calling `SpaceCenter::contract_manager()`.
object SpaceCenter.ContractManager {
properties: {
{
Types {
/// Re... |
// 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 ... |
#[derive(Default)]
pub struct PlayerDeaths(pub u32);
|
use std::{
any::Any,
panic::{catch_unwind, AssertUnwindSafe, Location},
};
pub type ThreadError = Box<dyn Any + Send + 'static>;
#[derive(Debug, Clone)]
pub struct ShouldHavePanickedAt {
pub span: &'static std::panic::Location<'static>,
}
#[track_caller]
pub fn must_panic<F, R>(f: F) -> Result<ThreadErro... |
/* origin: FreeBSD /usr/src/lib/msun/src/s_erff.c */
/*
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
*/
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. busi... |
mod actor;
mod sim;
use actor::action::{Action, Actions};
use actor::active_combos::ActiveCombos;
use actor::apply::{Apply, ApplyCombo, DoDirectDamage, GiveStatusEffect, StartGcd, StartRecast};
use actor::calc::lookup::Job;
use actor::damage::Damage;
use actor::recast_expirations::RecastExpirations;
use actor::rotatio... |
//! Crate level docs.
#![forbid(overflowing_literals)]
#![deny(missing_copy_implementations)]
#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![deny(intra_doc_link_resolution_failure)]
#![deny(path_statements)]
#![deny(trivial_bounds)]
#![deny(type_alias_bounds)]
#![deny(unconditional_recursion)]
#![de... |
extern crate sprinkle;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate cargo_metadata;
extern crate cargo_toml2;
extern crate scroll;
use std::env::{self, VarError};
use std::fs::{File, OpenOptions};
use std::path::PathBuf;
use std::process::{Command, Stdio};
use carg... |
// 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 ... |
extern crate ndk_sys;
extern crate jni;
extern crate sourcerenderer_core;
extern crate sourcerenderer_vulkan;
extern crate libc;
extern crate parking_lot;
#[macro_use]
extern crate lazy_static;
mod android_platform;
mod io;
use std::ffi::CString;
use jni::JNIEnv;
use jni::objects::{JClass, JObject, JString};
use jni:... |
#[doc = "Writer for register R2KEYR2"]
pub type W = crate::W<u32, super::R2KEYR2>;
#[doc = "Register R2KEYR2 `reset()`'s with value 0"]
impl crate::ResetValue for super::R2KEYR2 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Write proxy for field `REGx_KEY_`... |
#![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_Graphics_Gdi")]
pub fn ComputeInvCMAP(prgbcolors: *const super::super::Graphics::Gdi::RGBQUAD, ncolors: u32, pinvtable: *mut u8, c... |
//! Simple test utility to panic when spawned threads are blocked too long.
#![deny(missing_docs)]
use std::thread::{self, ThreadId, JoinHandle};
use std::sync::mpsc::{self, Sender, Receiver};
use std::time::Duration;
use std::cell::RefCell;
use std::collections::HashSet;
use std::ops::Drop;
/// Examples
///
/// ```... |
use sha2::{Digest, Sha256};
use std::sync::Arc;
use std::{
convert::{TryFrom, TryInto},
path::PathBuf,
};
use diesel::prelude::*;
use crate::{
db::SqlitePool,
external_id::ExternalId,
models::{
Album, AlbumBatcher, AlbumInput, AlbumLoader, Artist, ArtistBatcher, ArtistInput,
Artist... |
use crate::{
load_file,
Result,
error::QuicksilverError,
graphics::{Color, Image, PixelFormat},
};
use futures::{Future, future};
use rusttype::{Font as RTFont, FontCollection, PositionedGlyph, Scale, point};
use std::path::Path;
/// An in-memory TTF font that can render text on demand
pub struct Font ... |
use std::time::{Duration, Instant};
use actix::prelude::*;
use actix_web_actors::ws;
use std::collections::VecDeque;
use log::{info, error};
/// How often heartbeat pings are sent
const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
/// How long before lack of client response causes a timeout
const CLIENT_T... |
pub mod album;
pub mod artist;
pub mod contextmenu;
pub mod help;
pub mod layout;
pub mod library;
pub mod listview;
pub mod modal;
pub mod playlist;
pub mod playlists;
pub mod queue;
pub mod search;
pub mod show;
pub mod statusbar;
pub mod tabview;
|
//! Atoms, typed datum.
//!
//! see [cycling 74 docs](https://cycling74.com/sdk/max-sdk-8.0.3/html/group__atom.html)
use crate::symbol::SymbolRef;
use core::ffi::c_void;
/// The type of data that an atom stores.
#[derive(Copy, Clone, Debug)]
pub enum AtomType {
Int,
Float,
Symbol,
Object,
}
/// Typed... |
use iced::{button, checkbox, radio, Background, Color, Vector, Font};
pub const WINDOW_HEIGHT: u16 = 600;
pub const WINDOW_WIDTH: u16 = 400;
pub const SECTION_GAP: u16 = 30;
pub const ITEM_GAP: u16 = 12;
pub const BUTTON_GAP: u16 = 8;
pub const LIST_GAP: u16 = 5;
pub const FORM_LAYOUT_LEFT_WIDTH: u16 = 120;
#[cfg(... |
#[cfg(test)]
use pretty_assertions::assert_eq;
use wce_formats::binary_reader::BinaryReader;
use wce_formats::binary_writer::BinaryWriter;
use wce_formats::BinaryConverter;
use wce_formats::MapArchive;
use crate::globals::MAP_SOUNDS;
use crate::OpeningError;
const DEFAULT_FLOAT: f32 = 4.2949673e+009;
#[derive(Debug... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.