text stringlengths 8 4.13M |
|---|
#[doc = "Register `CCIPR5` reader"]
pub type R = crate::R<CCIPR5_SPEC>;
#[doc = "Register `CCIPR5` writer"]
pub type W = crate::W<CCIPR5_SPEC>;
#[doc = "Field `ADCDACSEL` reader - ADC and DAC kernel clock source selection others: reserved, the kernel clock is disabled"]
pub type ADCDACSEL_R = crate::FieldReader;
#[doc ... |
#[doc = "Register `TX_LPI_USEC_CNTR` reader"]
pub type R = crate::R<TX_LPI_USEC_CNTR_SPEC>;
#[doc = "Field `TXLPIUSC` reader - Tx LPI Microseconds Counter"]
pub type TXLPIUSC_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:31 - Tx LPI Microseconds Counter"]
#[inline(always)]
pub fn txlpiusc(&self) -> ... |
use std::io::{stdin, File};
use std::libc::{size_t, free, c_void};
use std::os::args;
use std::path::Path;
use std::ptr::null;
use std::vec::raw::from_buf_raw;
extern {
fn skr_compress(model: *u8, modlen: size_t,
inp: *u8, inlen: size_t,
outp: **u8, outlen: size_t,
... |
use crate::ray::Ray;
use crate::hittable::HitRecord;
use crate::vec3::Vec3;
use crate::sphere::random_in_unit_sphere;
use rand::{thread_rng, Rng};
pub trait Material {
fn scatter(&self, ray_in: &Ray, hit: &HitRecord, color: &mut Vec3, scattered_ray: &mut Ray) -> bool;
}
pub struct Lambertian {
pub albedo: Vec... |
pub trait Menu {
type MenuItem;
fn new(String, Option<Vec<Self::MenuItem>>) -> Self;
}
|
pub use linkerd2_app_core::{dns, profiles::*};
pub fn resolver<T>() -> crate::resolver::Profiles<T>
where
T: std::hash::Hash + Eq + std::fmt::Debug,
{
crate::resolver::Resolver::new()
}
pub fn with_name(name: &str) -> Profile {
use std::str::FromStr;
let name = dns::Name::from_str(name).expect("non-as... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use ir::StringInterner;
const TOP_LEVELS_CLASS: &str = "$root";
/// Used for things that can mangle themselves directly.
pub(crate) tr... |
use ::widget::Widget;
use ::window::WindowBuilder;
use super::gtk::{
Window as GtkWindow,
WindowTrait,
WindowType
};
impl Widget for GtkWindow {
type Builder = WindowBuilder;
fn build(builder: WindowBuilder) -> Self {
let window = GtkWindow::new(WindowType::Toplevel).unwrap();
wi... |
#[derive(Debug)]
struct Point <T> {
x:T,
y:T,
}
impl <T> Point <T> {
fn x(&self) -> &T {
&self.x
}
fn y(&self) -> &T {
&self.y
}
// fn mul (&self) -> &T {
// self.x * self.y
// }
}
impl Point <f32> {
fn distance_from_origin(&self) -> f32 {
(self.x... |
//mod panic_unrecoverable_errors;
mod result_recoverable_errors;
fn main() {
//panic_unrecoverable_errors::run();
result_recoverable_errors::run();
}
|
enum Path<'a> {
Map { parent: &'a Path<'a> },
Unknown { parent: &'a Path<'a> },
}
struct Deserializer<'a> {
path: Path<'a>,
}
impl<'a> Deserializer<'a> {
fn next_value_seed(&self)
{
let mut value_de = Deserializer {
path: if true {
Path::Map {
... |
use std::ops::RangeInclusive;
use chrono::prelude::Datelike;
use chrono::{Duration, NaiveDate};
use crate::utils::wrapping_range_contains;
pub type Weekday = chrono::Weekday;
/// Generic trait to specify the behavior of a selector over dates.
pub trait DateFilter {
fn filter(&self, date: NaiveDate) -> bool;
}
... |
// compiled with rustc
use std::fs;
use std::cmp::Eq;
use std::collections::HashSet;
use std::f32::consts::PI;
#[derive(Eq, PartialEq, Hash, Debug, PartialOrd, Clone, Copy, Ord)]
struct Point {
x: i32,
y: i32,
}
fn are_points_collinear(a: Point, b: Point, c: Point) -> bool {
return a.x * (b.y - c.y) + b.x... |
fn main() {
let oe5 = is_odd(5);
let oe6 = is_odd(6);
println!("Is 5 odd ? 6 ?: {} {}", oe5, oe6);
let td: (f32, f64) = tuple_and_cast((4,6,3));
println!("Tuple demo: {:?}", td);
println!("Factorial: {}", factorial(5));
}
fn is_odd(x: i32) -> bool {
//bitwise binary operation that return... |
#![crate_name = "reforge_server"]
#![crate_type = "bin"]
#![feature(box_syntax)]
#![feature(rand)]
#![feature(core)]
#![feature(os)]
#![feature(io)]
#![feature(old_io)]
#![feature(alloc)]
#![feature(thread_sleep)]
#![feature(collections)]
#![feature(std_misc)]
extern crate bincode;
extern crate time;
extern crate rust... |
//! Helper utilities
use std::ops::AddAssign;
use num::Integer;
/// Converts an `Iterator` over any integral primitive type into `SetVariationIterator`,
/// which will enumerate every variation of the numbers in the list. This is blanket implemented
/// over every fixed-sized iterator with integers, but given how man... |
use std::collections::HashMap;
use std::cmp::Ordering;
fn main() {
let list: Vec<usize> = vec![28, 18, 9, 7, 115, 7, 674, 89, 115, 115];
println!("{:?}", list);
println!("The mean of this list is {}", mean(&list[..]));
println!("The median of this list is {}", median(&list[..]));
println!("The mode... |
fn all_divisors(n: usize) -> Vec<usize> {
let mut result_increacing = Vec::<usize>::new();
let mut result_decreacing = Vec::<usize>::new();
for i in 1..=n {
if i > n / i {
break;
}
if n % i == 0 {
result_increacing.push(i);
if i != n / i {
... |
use alloc::arc::Arc;
use alloc::boxed::Box;
use collections::borrow::ToOwned;
use collections::String;
use core::cell::UnsafeCell;
use core::cmp;
use disk::Disk;
use fs::{KScheme, Resource, ResourceSeek, VecResource};
use syscall::{MODE_DIR, MODE_FILE, Stat};
use system::error::{Error, Result, ENOENT};
/// A disk ... |
// SPDX-License-Identifier: Apache-2.0
use core::mem::size_of;
use primordial::{Page, Register};
use xsave::XSave;
pub use x86_64::InterruptVector as Vector;
/// Section 38.9.1.1, Table 38-9
#[repr(C, align(4))]
#[derive(Copy, Clone)]
pub struct ExitInfo {
vector: Vector,
exit_type: u8,
reserved: u8,
... |
use crate::convert::*;
use core::ops::Add;
use core::ops::Mul;
pub(crate) trait FoldedMultiply: Mul + Add + Sized {
fn folded_multiply(self, by: Self) -> Self;
}
impl FoldedMultiply for u64 {
#[inline(always)]
fn folded_multiply(self, by: u64) -> u64 {
let result: [u64; 2] = (self as u128).wrappin... |
#[doc = "Reader of register SW_CMP_N_SEL"]
pub type R = crate::R<u32, super::SW_CMP_N_SEL>;
#[doc = "Writer for register SW_CMP_N_SEL"]
pub type W = crate::W<u32, super::SW_CMP_N_SEL>;
#[doc = "Register SW_CMP_N_SEL `reset()`'s with value 0"]
impl crate::ResetValue for super::SW_CMP_N_SEL {
type Type = u32;
#[i... |
use serde::{Deserialize, Serialize};
use crate::SingleTableCondition;
/// Selection query for single table.
///
/// This struct is independent of physical column distribution (PK, secondary-index, row, ...).
#[derive(Clone, PartialEq, Debug, Serialize, Deserialize)]
pub enum RowSelectionQuery {
/// Full scan
... |
#[derive(Debug)]
enum Student{
online,
offline,
}
fn call(X:Student){
println!("{:#?}",X);
}
fn main() {
let m=Student::offline;
call(m);
}
|
#![allow(clippy::type_complexity)]
use crate::components::{
keyboard_movement::{Direction, KeyboardMovement},
speed::Speed,
};
use oxygengine::prelude::*;
pub type KeyboardMovementSystemResources<'a> = (
WorldRef,
&'a InputController,
&'a AppLifeCycle,
&'a UserInterface,
Comp<&'a Speed>,
... |
#![allow(mutable_transmutes)]
use std::mem::transmute;
/// The `muzzle` function takes an immutable reference and transmutes it to a mutable one.
/// This function is obviously evil and should therefore be used sparingly.
/// Suffice it to say, you should *never* do this with an object that is to be passed
/// or sh... |
#[doc = "Reader of register WDT_CTL"]
pub type R = crate::R<u32, super::WDT_CTL>;
#[doc = "Writer for register WDT_CTL"]
pub type W = crate::W<u32, super::WDT_CTL>;
#[doc = "Register WDT_CTL `reset()`'s with value 0xc000_0001"]
impl crate::ResetValue for super::WDT_CTL {
type Type = u32;
#[inline(always)]
f... |
use crate::functions::{activation, loss};
use crate::neuron::Neuron;
pub struct NeuralNetwork {
network: Vec<Vec<Neuron>>,
learning_constant: f64,
}
pub struct TrainingResult {
guess: Vec<f64>,
error: f64,
}
impl NeuralNetwork {
pub fn new(layers: &[u32], learning_constant: f64) -> Self {
... |
use std::fs::File;
use std::io::prelude::*;
use std::io::ErrorKind;
use std::{thread, time};
use rand;
use rand::Rng;
use graphics::{Graphics, DrawResult};
use parsing::Instruction;
// A CPUState struct represents the internal state of a Chip8 CPU.
// It includes a Graphics struct implemented in graphics.rs.
#[allow(... |
/// When seccomp decides not to execute a syscall the kernel returns to userspace
/// without modifying the registers. There is no negative return value to
/// indicate that whatever side effects the syscall would happen did not take
/// place. This is a problem for rd, because for syscalls that require special
/// han... |
use std::sync::RwLock;
use crate::avl::AvlTree;
use crate::store::{Location, PathValue, Storage};
/// An in-memory store backed by an AvlTree.
pub struct Memory {
store: RwLock<Vec<AvlTree<Vec<u8>, Vec<u8>>>>,
pending: RwLock<AvlTree<Vec<u8>, Vec<u8>>>,
}
impl Memory {
/// The store starts out by compris... |
#[doc = "Reader of register SWIER3"]
pub type R = crate::R<u32, super::SWIER3>;
#[doc = "Writer for register SWIER3"]
pub type W = crate::W<u32, super::SWIER3>;
#[doc = "Register SWIER3 `reset()`'s with value 0"]
impl crate::ResetValue for super::SWIER3 {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
// Copyright 2019 EinsteinDB Project Authors. Licensed under Apache-2.0.
#[macro_use]
extern crate slog;
use slog::{Drain, Logger};
use std::collections::HashMap;
use std::sync::mpsc::{self, RecvTimeoutError};
use std::thread;
use std::time::{Duration, Instant};
use violetabft::evioletabftpb::ConfState;
use violetab... |
use super::{Expression, visitor::ExpressionVisitor};
#[derive(Debug)]
pub struct NameExpression {
pub name: String
}
impl NameExpression {
pub fn new(name: String) -> NameExpression {
NameExpression { name }
}
}
impl Expression for NameExpression {
fn accept(&mut self, visitor: &mut dyn Expre... |
fn main() {
let mut sum = 0;
for number in 0..1000 {
if number % 3 == 0 {
sum = sum + number;
println!("we got {}, and sum is {}", number, sum);
} else if number % 5 == 0 {
sum = sum + number;
println!("we got {}, and sum is {}", number, sum);
... |
use std::collections::VecDeque;
pub struct Reverb {
delay: usize,
decay: f32,
buf: VecDeque<f32>,
}
impl Reverb {
/// `delay_ms`: Reverb delay in ms
///
/// `sample_rate`: Sample rate of samples
///
/// `decay`: Strength of the reverb
pub fn new(delay_ms: usize, sample_rate: usize,... |
/*!
```rudra-poc
[target]
crate = "cache"
version = "0.2.0"
[[target.peer]]
crate = "crossbeam-utils"
version = "0.8.0"
[report]
issue_url = "https://github.com/krl/cache/issues/1"
issue_date = 2020-11-24
rustsec_url = "https://github.com/RustSec/advisory-db/pull/704"
rustsec_id = "RUSTSEC-2020-0128"
[[bugs]]
analyz... |
// Copyright 2018-2019 Mozilla
//
// 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 in writing, sof... |
#[doc = "Register `SCR` writer"]
pub type W = crate::W<SCR_SPEC>;
#[doc = "Field `CTAMP1F` writer - CTAMP1F"]
pub type CTAMP1F_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `CTAMP2F` writer - CTAMP2F"]
pub type CTAMP2F_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
#[doc = "Field `CTAM... |
use crate::graphics::{CurrentFrame, GraphicsState};
use rand::Rng;
pub struct RendererGlyph {
//
}
impl RendererGlyph {
pub fn new(_graphics_state: &GraphicsState) -> Self {
RendererGlyph {}
}
pub fn draw(&mut self, current_frame: &mut CurrentFrame) {
let window_inner_size = current_f... |
use crate::ast::{ Ast };
use crate::object::{ Object, new_error };
fn len(args: Vec<Object>) -> Object {
if args.len() != 1 {
return new_error(format!("wrong number of arguments. got={}, want=1", args.len()));
}
match &args[0] {
Object::String { value } => return Object::Integer { value: v... |
use common::LOGGER;
use exec::CommandStore;
// Token内にいるかどうかはcurrent_tokenで判断
#[derive(Clone, Copy, Debug)]
pub enum ParseStatus {
WaitCommand,
WaitArgs,
WaitInFile,
WaitOutFile,
WaitErrFile,
}
// なんでResultが一種類しかないの?
#[derive(Clone, Copy, Debug)]
enum ParseResult {
CmdOk,
}
pub const DELIMITERS... |
use crate::clients::QueueClient;
use crate::responses::*;
use crate::QueueStoredAccessPolicy;
use azure_core::headers::add_optional_header;
use azure_core::prelude::*;
use azure_storage::StoredAccessPolicyList;
use std::convert::TryInto;
#[derive(Debug, Clone)]
pub struct SetQueueACLBuilder<'a> {
queue_client: &'a... |
extern crate serde_yaml;
use std::fs;
use std::fs::File;
use std::io::Write;
use std::io::prelude::*;
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone)]
pub struct MinaFile {
pub name:String,
pub version:String,
pub pkg_rel:String,
pub provides:String,
pub source:String,
pub maintainer... |
pub mod link;
pub mod dynload; |
use crate::repr::{HIR, Call};
use crate::runtime_defs;
use crate::error;
use super::common::*;
use super::top_level::compile_top_level_hirs;
use super::call;
use unlisp_rt;
use inkwell::basic_block::BasicBlock;
use inkwell::builder::Builder;
use inkwell::context::Context;
use inkwell::execution_engine::{ExecutionEngi... |
use super::ListConsumer;
use rayon::iter::plumbing::{
bridge_producer_consumer, Folder, Producer, ProducerCallback, Reducer, UnindexedConsumer,
};
use rayon::prelude::*;
pub struct ByBlocksIter<I, S> {
pub(super) sizes: S,
pub(super) base: I,
}
struct BlocksCallback<S, C> {
sizes: S,
consumer: C,
... |
use crate::{
gui::{
AssetItemMessage, BuildContext, CustomWidget, EditorUiMessage, EditorUiNode, Ui, UiMessage,
UiNode, UiWidgetBuilder,
},
load_image,
preview::PreviewPanel,
GameEngine,
};
use rg3d::{
core::{color::Color, pool::Handle, scope_profile},
engine::resource_manage... |
use std::mem::forget;
fn main() {
for _ in 0..10000 {
let mut a = vec![2; 10000000];
a[2] = 2;
forget(a);
}
}
|
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
#[allow(dead_code)]
struct Scanner<'a> {
cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
fn new(cin: StdinLock<'a>) -> Scanner<'a> {
Scanner { cin: cin }
}
fn read<T: FromStr>(&mut self) -> Option<T> {
let t... |
use common::result::Result;
use crate::domain::publication::Frame;
#[derive(Debug, Clone)]
pub struct Image {
url: String,
frames: Vec<Frame>,
}
impl Image {
pub fn new<S: Into<String>>(url: S) -> Result<Self> {
Ok(Image {
url: url.into(),
frames: Vec::new(),
})
... |
use serde::{Deserialize, Serialize};
/// Structure that represent a color.
/// Internally alpha is stored as `f32` that ranges from `0.0` (transparent) to `1.0` (opaque).
/// The other components (RGB) are stored as `f32` that range from `0.0` up to `f32::MAX`,
/// the values encode the brightness of each channel prop... |
#[doc = "Register `HIFCR` writer"]
pub type W = crate::W<HIFCR_SPEC>;
#[doc = "Stream x clear FIFO error interrupt flag (x = 7..4)\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CFEIF4_AW {
#[doc = "1: Clear the corresponding CFEIFx flag"]
Clear = 1,
}
impl From<CFEIF4_AW> for bool... |
#[doc = "Register `CR` reader"]
pub type R = crate::R<CR_SPEC>;
#[doc = "Register `CR` writer"]
pub type W = crate::W<CR_SPEC>;
#[doc = "Field `MSION` reader - MSI clock enable"]
pub type MSION_R = crate::BitReader<MSION_A>;
#[doc = "MSI clock enable\n\nValue on reset: 1"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
p... |
use regex::Regex;
use tracing::{info, warn, instrument};
use tracing_subscriber::{layer::SubscriberExt, Registry};
use tracing_layer_slack::{EventFilters, SlackLayer};
#[instrument]
pub async fn create_user(id: u64) {
network_io(id).await;
info!(param = id, "A user was created");
}
#[instrument]
pub async fn... |
use crossbeam::channel::{self, Receiver, Sender};
use winit::event::VirtualKeyCode;
use crate::app::mainview::MainViewMsg;
use crate::app::AppMsg;
use crate::gui::GuiMsg;
use crate::overlays::OverlayData;
pub type BindMsg = (
VirtualKeyCode,
Option<Box<dyn Fn() + Send + Sync + 'static>>,
);
pub enum OverlayC... |
use std::collections::HashSet;
pub fn solve_v1() -> i32 {
let data = super::load_file("day8.txt");
let instructions: Vec<&str> = data.lines().collect();
let mut visited: HashSet<usize> = HashSet::new();
let mut acc = 0;
let mut pc = 0;
while pc < instructions.len() && !visited.contains(&pc) {
... |
extern crate dmi;
use dmi::sysfs_read_smbios_entry_point;
use dmi::smbios2::SM21EntryPoint;
fn main() {
let mut buf = [0 as u8; 31];
sysfs_read_smbios_entry_point(&mut buf).expect("Could not read entry point!");
let entry_point = SM21EntryPoint::new(&buf);
println!("Entry Point: {:?}", entry_point);... |
use std::collections::HashMap;
fn main() {
for m in &[2020, 30000000] {
let mut input: Vec<usize> = vec![0, 1, 5, 10, 3, 12, 19];
input.reserve(*m);
let n = input.len();
let mut map: HashMap<usize, usize> = HashMap::new();
for (i, x) in input.iter().enumerate() {
... |
//!
//! ```ignore
//! +---------------+ +---------------+
//! | | | frame metadata+----+
//! | | +---------------+ |
//! | frame | |
//! ... |
extern crate rand;
use std::io;
use rand::Rng;
use std::cmp::Ordering; //head
fn main() {
println!("Welcome to Guessing Game!");//welcome message
let mut t=0;//reset counter
println!("Please input your guess(1~100):");
let secret_number = rand::thread_rng().gen_range(1,101);//random
while t<11 {//control the... |
pub struct Fish {
pub name: String,
pub water_type: WaterType,
pub weight: u32,
}
pub enum WaterType {
Fresh,
Brackish,
Salty,
}
|
use std::io::prelude::*;
use std::fs::File;
use std::collections::HashMap;
pub struct Message {
matrix: Vec<Vec<char>>,
}
impl Message {
pub fn new(filename: &str) -> Message {
let mut f = File::open(filename).unwrap();
let mut s = String::new();
f.read_to_string(&mut s).unwrap();
... |
use super::*;
use gfx_h::{TextData, WorldTextData};
pub struct ScoreTableRendering {
reader: ReaderId<Primitive>,
}
impl ScoreTableRendering {
pub fn new(reader: ReaderId<Primitive>) -> Self {
ScoreTableRendering { reader: reader }
}
}
impl<'a> System<'a> for ScoreTableRendering {
type System... |
enum IpAddrKing {
V4(u8,u8,u8,u8),
V6(String)
}
// Rusts "null" value, Some can be any kind of Datatype
enum Option<T> {
Some(T),
None,
}
let home = IpAddr::V4(127,0,0,1);
let loopback = IpAddrKing::V6(String::from("::1"));
fn main() {
let four = IpAddrKing::V4;
let six = IpAddrKing::V6;
//... |
#[derive(Debug)]
pub struct RecordDatum {
name: String,
value: i64
}
impl RecordDatum {
pub fn new(n: String, v: i64) -> RecordDatum {
RecordDatum {
name: n,
value: v
}
}
}
|
pub mod part1;
pub mod part2;
pub fn run() {
part1::run();
part2::run();
}
pub fn default_input() -> &'static str {
include_str!("input")
}
pub fn parse_input(input : &str) -> Vec<i64> {
input.chars().map(|c| c.to_digit(10).unwrap() as i64).collect()
}
#[derive(Copy, Clone, Eq, PartialEq, Hash)]
pub... |
use crate::service::OutboxService;
use actix::prelude::*;
use drogue_cloud_database_common::error::ServiceError;
use drogue_cloud_database_common::models::outbox::OutboxEntry;
use drogue_cloud_registry_events::{Event, EventSender, EventSenderError};
use futures::TryStreamExt;
use std::convert::Infallible;
use std::sync... |
// 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 agre... |
use std::fs::File;
use std::io::{BufRead, BufReader, Error};
pub fn entries(path: &str) -> Result<Vec<String>, Error> {
let input = File::open(path)?;
let buffered = BufReader::new(input);
let mut lines = Vec::new();
for line in buffered.lines() {
lines.push(line.unwrap());
}
Ok(lines)
... |
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast; // For dyn_into().
use crate::model::Model;
use crate::{Point2D, VirtualKey};
#[wasm_bindgen]
pub fn setup_for_debug() {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));
console_log::init_with_level(log::Level::Debug).unwrap();
info!("... |
use std::fmt::{self, Display, Formatter};
use std::collections::HashMap;
use model::column::Column;
use model::table::Table;
pub struct TablesAndColumns<'a> {
tables_and_columns: HashMap<Table, Vec<&'a Column>>,
}
impl<'a> TablesAndColumns<'a> {
pub fn from_columns(v: &'a Vec<Column>) -> TablesAndColumns<'a> ... |
// # Mech
// ## Prelude
extern crate mech_core;
extern crate mech_syntax;
extern crate mech_program;
extern crate mech_utilities;
mod repl;
pub use mech_core::{Core, TableIndex, ValueMethods, Change, Transaction, Transformation, hash_string, Block, Table, Value, Error, ErrorType};
pub use mech_core::QuantityMath;
p... |
use super::{osgood, Exception, Isolate, Local, Valuable, V8};
pub use V8::Script;
impl Script {
pub fn compile(
ctx: Local<V8::Context>,
src: Local<V8::String>,
) -> Result<Local<V8::Script>, std::string::String> {
unsafe {
let result = osgood::compile_script(Isolate::raw()... |
// Tic-tac-toe in Rust!
// Author: Kyle Racette <kracette at gmail dot com>
use std::result::Result;
/*
Defines a player type, which interacts with the game.
*/
struct Player {
symbol: char,
find_move: fn(player: &Player, board: &Game) -> (u32, u32)
}
impl PartialEq for Player {
fn eq(&self, other: &Self) -> boo... |
use core::ptr;
pub const HID_BASE: u32 = 0x10146000u32;
#[derive(Clone, Copy)]
#[allow(non_camel_case_types)]
enum Reg {
PAD = 0x00,
}
#[derive(Clone, Copy, Eq, PartialEq)]
pub enum Button {
A = 0,
B = 1,
Select = 2,
Start = 3,
DPadR = 4,
DPadL = 5,
DPadU = 6,
DPadD ... |
//! MetroBus client. Contains the client for fetching data from
//! the WMATA API and data structures returned from those endpoint calls.
pub mod responses;
mod tests;
use crate::{
bus::{
traits::{NeedsRoute, NeedsStop},
urls::URLs,
},
error::Error,
requests::{Fetch, Request as WMATAReq... |
// Copyright (c) The diem-devtools Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Basic tests for the test runner.
use anyhow::Result;
use camino::Utf8Path;
use cargo_metadata::Message;
use duct::cmd;
use maplit::btreemap;
use nextest_config::NextestConfig;
use nextest_runner::{
reporter::TestEven... |
use crate::config::{init_config_env, init_simplicate_client};
use crate::links::Link;
use chrono::offset::Utc;
use chrono::NaiveDateTime;
use colored::*;
use serde::Deserialize;
use serde_json::{to_string_pretty, Value};
use simplicate::structures::NewHours;
use simplicate::Post;
use std::env;
use structopt::StructOpt;... |
mod impls;
mod models;
mod util;
use sqlx::postgres::{PgPool, PgPoolOptions};
use crate::BotResult;
pub use self::models::{
Authorities, DBBeatmap, DBBeatmapset, EmbedsSize, GuildConfig, MapsetTagWrapper, MinimizedPp,
OsuData, Prefix, Prefixes, TagRow, TrackingUser, UserConfig, UserStatsColumn, UserValueRaw,... |
use std::str::from_utf8;
use nom::bits::complete::tag;
use nom::bits::complete::take;
use nom::multi::{many0, many_m_n, many_till};
use nom::sequence::tuple;
use nom::IResult;
use hymns::runner::timed_run;
macro_rules! read_bits {
($name:ident, $bits:expr, $return_type:ty) => {
fn $name(input: BitIO) -> ... |
//! using `#[cfg]` on `static` shouldn't cause compile errors
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
extern crate cortex_m_rt as rt;
extern crate panic_halt;
use rt::{entry, exception};
#[entry]
fn main() -> ! {
#[cfg(never)]
static mut COUNT: u32 = 0;
loop {}
}
#[exception]
f... |
#![allow(clippy::module_inception)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::ptr_arg)]
#![allow(clippy::large_enum_variant)]
#![doc = "generated by AutoRust 0.1.0"]
#[cfg(feature = "package-preview-7.3-preview")]
pub mod package_preview_7_3_preview;
#[cfg(all(feature = "package-preview-7.3-preview", not(f... |
use std::collections::HashMap;
use std::fmt;
use std::sync::mpsc;
#[derive(Debug, PartialEq)]
enum Opcode {
Add,
Multiply,
GetInput,
Print,
JumpIfTrue,
JumpIfFalse,
LessThan,
Equals,
AdjustRelativeBase,
EndOfProgram,
}
impl fmt::Display for Opcode {
fn fmt(&self, f: &mut fm... |
// Copyright (c) 2021 Thomas J. Otterson
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
pub mod constants {
/// The pin assignment for the first I/O pin of switch 1.
pub const A1: usize = 1;
/// The pin assignment for the second I/O pin of switch 1.
pub co... |
/// Creates a binary tree from expressions.
///
/// # Examples
///
/// ```
/// #[macro_use] extern crate ego_binary_tree;
/// # fn main() {
/// let tree = binary_tree!("root");
/// # }
/// ```
///
/// ```
/// #[macro_use] extern crate ego_binary_tree;
/// # fn main() {
/// let tree = binary_tree! {
/// "root" => {
... |
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]
trait Animal
{
fn create(name: &'static str) -> Self;
fn name(&self) -> &'static str;
fn talk(&self)
{
println!("{} cannot talk", self.name());
}
}
trait Summable<T>
{
fn sum(&self) -> T;
}
struct Human
{
... |
pub fn run() {
// Print to console
println!("Hello from the print.rs file");
// Basic Formatting
println!("{} is from {}", "John", "South Korea");
// Positional Arguments
println!("{0} is from {1} and {0} likes to {2}", "John", "South Korea", "code");
// Named Arguments
println!("{nam... |
fn benchmark_osm(osm_path: &Path) {
// [.. initial setup ..]
let mut g = Graph::new();
let mut edges = Vec::new();
let mut indices = Vec::new();
// [.. parse nodes and edges ..]
// Add edges to graph
for (mut e, (n1, n2)) in edges.into_iter()
.zip(indices.into_iter()) {
e.l... |
use mio::event;
use mio::net::TcpStream;
#[test]
fn assert_event_source_implemented_for() {
fn assert_event_source<E: event::Source>() {}
assert_event_source::<Box<dyn event::Source>>();
assert_event_source::<Box<TcpStream>>();
}
|
//! The implementation of HTTP server for tsukuyomi.
use {
crate::app::App,
futures01::Future,
izanami::{h1::H1, net::tcp::AddrIncoming, service::ServiceExt},
std::{io, net::ToSocketAddrs},
tokio::runtime::Runtime,
};
#[allow(missing_debug_implementations)]
pub struct Server {
app: App,
ru... |
use crate::sys::unix::net::{new_ip_socket, socket_addr};
use crate::unix::SourceFd;
use crate::{event, Interest, Registry, Token};
use std::net::{Ipv4Addr, Ipv6Addr, SocketAddr};
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
use std::{fmt, io, net};
pub struct UdpSocket {
io: net::UdpSocket,
}
i... |
// Copyright 2019 The Grin Developers
//
// 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 agree... |
mod alarms;
mod configuration;
mod status;
pub use self::alarms::{
Alarm1Matching, Alarm2Matching, DayAlarm1, DayAlarm2, WeekdayAlarm1, WeekdayAlarm2,
};
mod datetime;
use super::{BitFlags, Error};
use super::{Datelike, Hours, NaiveDate, NaiveDateTime, NaiveTime, Rtcc, Timelike};
// Transforms a decimal number to ... |
use futures_01::future::Future as Future01;
use futures_util::{compat::Future01CompatExt, future::FutureExt};
use std::cell::RefCell;
use tokio_02::runtime::Handle;
use tokio_executor_01 as executor_01;
use super::idle;
#[derive(Clone, Debug)]
pub(super) struct CompatSpawner<S> {
pub(super) inner: S,
pub(supe... |
use z80::Z80;
/*
** RL(C) register or (hl)
*/
pub fn rl_r(z80: &mut Z80, op: u8) {
let mut val = match op & 0xF {
0x0 => z80.r.b,
0x1 => z80.r.c,
0x2 => z80.r.d,
0x3 => z80.r.e,
0x4 => z80.r.h,
0x5 => z80.r.l,
0x6 => z80.mmu.rb(z80.r.get_hl()),
0x7 =>... |
use std::io;
use std::thread;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::convert::TryFrom;
const SUDOKU_SIZE :usize = 9;
const SUDOKU_BLOCKS :usize = 3;
type Sudoku = [[u8; SUDOKU_SIZE]; SUDOKU_SIZE];
type SudokuInp = [[[bool; SUDOKU_SIZE]; SUDOKU_SIZE];SUDOKU_SIZE];
fn read_input() -> Sudoku {
... |
use std::error::Error;
pub type CmdResult = Result<(), Box<dyn Error>>;
|
use axum::http::HeaderMap;
use axum::http::HeaderValue;
use eyre::eyre;
use eyre::Result;
use futures::future;
use lazy_static::lazy_static;
use rayon::iter::IntoParallelIterator;
use rayon::iter::ParallelIterator;
use regex::Regex;
use reqwest::header::HeaderName;
use reqwest::header::CACHE_CONTROL;
use s3::bucket::Bu... |
#[doc = "Reader of register ETH_DMAC1SFCSR"]
pub type R = crate::R<u32, super::ETH_DMAC1SFCSR>;
#[doc = "Writer for register ETH_DMAC1SFCSR"]
pub type W = crate::W<u32, super::ETH_DMAC1SFCSR>;
#[doc = "Register ETH_DMAC1SFCSR `reset()`'s with value 0"]
impl crate::ResetValue for super::ETH_DMAC1SFCSR {
type Type = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.