text stringlengths 8 4.13M |
|---|
use gfx;
use glutin;
use gfx_device_gl;
use gfx::format::{Srgba8, Rgba8};
use gfx::Device;
use gfx::traits::FactoryExt;
use gfx_window_glutin;
use gfx::texture::ImageInfoCommon;
use gfx::format::R8_G8_B8_A8;
use super::{Vertex, ColorFormat, DepthFormat, GeometryBuffer, Locals};
use super::{pipe_blend, pipe_opaque, g... |
//! # CRC digest of resource paths
use crc::{Crc, CRC_32_MPEG_2};
fn normalize_char(b: u8) -> u8 {
match b {
b'/' => b'\\',
b'A'..=b'Z' => b + 0x20,
_ => b,
}
}
const ALG: Crc<u32> = Crc::<u32>::new(&CRC_32_MPEG_2);
/// Calculate the Cyclic-Redundancy-Check for a file path
///
/// Th... |
fn main() {
let mut mine = User {
username: "Len",
age: 26,
active: true,
};
mine.active = false;
println!("mine: {:#?}", mine);
let test = build_user("Test", 30);
println!("test user: {:?}", test);
let cp_mine = User {
age: 29,
..mine
};
p... |
use std::fmt;
use std::io;
#[allow(unused_variables)]
#[allow(unused_must_use)]
fn main() {
let traffic_light = vec!((4,2), (4,3), (4,4), (4,5), (4,6));
let galaxy = vec!(
(3,3),(3,4),(3,5),(3,6),(3,7),(3,8),(3,10),(3,11),
(4,3),(4,4),(4,5),(4,6),(4,7),(4,8),(4,10),(4,11),
(5,10),(5,11)... |
use crate::helpers::configuration::*;
#[derive (serde::Deserialize, Debug)]
pub enum Virustotal {
DataIp(VTdataIp),
DataUrl(VTdataUrl),
}
#[derive(serde::Deserialize, Debug)]
pub struct VTdataIp {
data: Vec<VTattributesIp>,
}
#[derive(serde::Deserialize, Debug)]
pub struct VTattributesIp {
attributes... |
use std::collections::HashMap;
impl Solution {
pub fn num_buses_to_destination(routes: Vec<Vec<i32>>, source: i32, target: i32) -> i32 {
if target == source{
return 0;
}
let n = routes.len();
let mut que = Vec::new();
let mut g = HashMap::new();
let mut di... |
fn main() {
let x =1;
let c ='c';
match c{
x => println!("x: {} c: {}",x,c),//x is fucking shadowed
}
println!("x: {}",x);
}
|
//! Maps the API endpoints to functions
use std::collections::HashMap;
use chrono::NaiveDateTime;
use diesel;
use diesel::prelude::*;
use diesel::BelongingToDsl;
use rocket::State;
use rocket_contrib::Json;
use serde_json;
use super::DbPool;
use helpers::{debug, get_user_from_username, get_last_update};
use models::... |
#[doc = "Register `C1SCR` reader"]
pub type R = crate::R<C1SCR_SPEC>;
#[doc = "Register `C1SCR` writer"]
pub type W = crate::W<C1SCR_SPEC>;
#[doc = "Field `CH1C` reader - CH1C"]
pub type CH1C_R = crate::BitReader<CH1C_A>;
#[doc = "CH1C\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum CH1C_A ... |
#![cfg_attr(feature = "unstable", feature(test))]
#[cfg(feature = "libwebkit2gtk")]
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "libwebkit2gtk")]
extern crate ammonia;
#[cfg(feature = "libwebkit2gtk")]
extern crate pulldown_cmark;
extern crate structopt;
#[cfg(feature = "libwebkit2gtk")]
extern crate syntec... |
use hex;
use regex::Regex;
use skia_safe::{canvas::Canvas, Paint, Rect as SkRect};
#[derive(Debug)]
pub struct ColourParseError {}
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct ArgbColour {
a: u8,
r: u8,
g: u8,
b: u8,
}
impl ArgbColour {
pub fn from_hex(hex: &str) -> Result<ArgbColour, Colou... |
use tide::middleware::RootLogger;
use tide_static_files::StaticFiles;
fn main() {
let mut app = tide::App::new(());
app.middleware(RootLogger::new());
let static_files = StaticFiles::new(".").unwrap();
app.at("/static/*").get(static_files);
app.serve("127.0.0.1:8000").unwrap();
}
|
#[macro_use]
extern crate criterion;
use criterion::{black_box, Criterion};
use feather_blocks::{BlockId, EastWire, WestWire};
// Some useless vanity benchmarks.
fn to_id_complex_state(c: &mut Criterion) {
feather_blocks::init();
let block = BlockId::redstone_wire()
.with_east_wire(EastWire::Up)
... |
pub mod default;
/// Used only for allowing dynamic known species
pub trait Species: std::fmt::Display {
fn name(&self) -> &str;
}
|
use super::super::alu::*;
use super::super::{Cpu, Cycles, Memory};
use util::bits::Bits as _;
pub const S_SET: bool = true;
pub const S_CLR: bool = false;
pub const REG_SHIFT: bool = true;
pub const IMM_SHIFT: bool = false;
/// Creates a function for an arithmetic data processing function that writes
/// back to the ... |
use std::env;
pub fn is_debug() -> bool {
let args: Vec<String> = env::args().collect();
for arg in args {
if arg == "-d" || arg == "--debug" {
return true;
}
}
return false;
}
|
#[doc = "Reader of register ADV_NEXT_INSTANT"]
pub type R = crate::R<u32, super::ADV_NEXT_INSTANT>;
#[doc = "Reader of field `ADV_NEXT_INSTANT`"]
pub type ADV_NEXT_INSTANT_R = crate::R<u16, u16>;
impl R {
#[doc = "Bits 0:15 - Shows the next start of advertising event with reference to the internal reference clock."... |
fn main() {
vectors();
}
fn vectors() {
let mut nums = vec![1i, 2i, 3i];
let nums2 = [1i, ..20];
nums.push(4i); // works
let nums_arr = [1i, 2i, 3i];
// nums_arr.push(4i); <-- won't work
let slice = nums.as_slice();
for i in nums2.iter() {
println!("{}", i);
}
let names = ["Grayson", "Brian", "Nik... |
#[doc = "Register `WMMONR` reader"]
pub type R = crate::R<WMMONR_SPEC>;
#[doc = "Field `WMISSMON` reader - cache write-miss monitor counter"]
pub type WMISSMON_R = crate::FieldReader<u16>;
impl R {
#[doc = "Bits 0:15 - cache write-miss monitor counter"]
#[inline(always)]
pub fn wmissmon(&self) -> WMISSMON_R... |
use volatile::Volatile;
use super::color::ColorCode;
pub(crate) const BUFFER_HEIGHT: usize = 25;
pub(crate) const BUFFER_WIDTH: usize = 80;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(C)]
pub(crate) struct ScreenChar {
pub(crate) character: u8,
pub(crate) color_code: ColorCode,
}
#[repr(transparent)... |
#![no_std]
pub(crate) mod emulator;
pub(crate) mod settings;
pub(crate) mod utils;
pub mod error;
pub mod host;
pub mod zx;
pub use emulator::Emulator;
pub use settings::RustzxSettings;
pub use utils::EmulationMode;
#[cfg(feature = "strum")]
pub use strum::IntoEnumIterator as IterableEnum;
extern crate alloc;
pub... |
#[doc = "Reader of register SIE_EP3_CR0"]
pub type R = crate::R<u32, super::SIE_EP3_CR0>;
#[doc = "Writer for register SIE_EP3_CR0"]
pub type W = crate::W<u32, super::SIE_EP3_CR0>;
#[doc = "Register SIE_EP3_CR0 `reset()`'s with value 0"]
impl crate::ResetValue for super::SIE_EP3_CR0 {
type Type = u32;
#[inline(... |
pub use self::hci::Hci;
pub use self::setup::Setup;
pub mod desc;
pub mod ehci;
pub mod hci;
pub mod ohci;
pub mod setup;
pub mod uhci;
pub mod xhci;
#[derive(Debug)]
pub enum Packet<'a> {
Setup(&'a Setup),
In(&'a mut [u8]),
Out(&'a [u8]),
}
#[derive(Debug)]
pub enum Pipe {
Control,
Interrupt,
... |
#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(missing_debug_implementations)]
//! <div align="center">
//!
//! <img src="https://raw.githubusercontent.com/SeaQL/sea-query/master/docs/SeaQL logo dual.png" width="320"/>
//!
//! <h1>SeaQuery</h1>
//!
//! <p>
//! <strong>🌊 A dynamic query builder for MySQL, Po... |
use crate::route::Route;
use crate::types::Product;
use yew::prelude::*;
use yew_router::components::RouterAnchor;
type Anchor = RouterAnchor<Route>;
pub fn product_card(product: &Product, atc_button: Html) -> Html {
html! {
<div class="product_card_container">
<Anchor route=Route::ProductDeta... |
use std::{fmt::Write, sync::Arc};
use eyre::Report;
use hashbrown::{HashMap, HashSet};
use rand::Rng;
use tokio::time::{interval, Duration};
use twilight_http::{
api_error::{ApiError, GeneralApiError},
error::ErrorType,
};
use twilight_model::id::{marker::ChannelMarker, Id};
use crate::{
custom_client::Tw... |
use super::{Task, TaskId};
use alloc::task::Wake;
use alloc::{collections::BTreeMap, sync::Arc};
use core::task::Waker;
use core::task::{Context, Poll};
use crossbeam_queue::ArrayQueue;
use crate::serial_println;
/// # Executor
///
/// A much more optimized, and generally better executor than SimpleExecutor.
///
//... |
//https://ptrace.fefe.de/wp/wpopt.rs
use std::fmt::Write;
use std::iter::FromIterator;
use bytes::{BufMut, Bytes, BytesMut};
use futures::stream;
use futures::FutureExt;
use futures::StreamExt;
use tokio_util::codec::{BytesCodec, FramedRead, FramedWrite};
use std::time::Instant;
use word_count::util::*;
use parallel... |
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Copy, Serialize, Deserialize)]
pub enum PacketStage {
Handshaking = 0,
Status = 1,
Login = 2,
Play = 3,
}
#[derive(Debug, Clone, PartialOrd, Ord, PartialEq, Eq, Copy, Serialize, Deserial... |
pub mod filesystem;
|
#[doc = "Register `AHB1ENR` reader"]
pub type R = crate::R<AHB1ENR_SPEC>;
#[doc = "Register `AHB1ENR` writer"]
pub type W = crate::W<AHB1ENR_SPEC>;
#[doc = "Field `GPIOAEN` reader - IO port A clock enable"]
pub type GPIOAEN_R = crate::BitReader<GPIOAEN_A>;
#[doc = "IO port A clock enable\n\nValue on reset: 0"]
#[derive... |
fn main() {
if cfg!(target_os = "linux") {
// these pragmas are optional on my system but left as examples if you run into trouble.
println!("cargo:rustc-link-lib=X11");
println!("cargo:rustc-link-lib=Xcursor");
println!("cargo:rustc-link-lib=Xrandr");
println!("cargo:rustc-l... |
use {
exitfailure::ExitFailure,
std::path::PathBuf,
tsukuyomi::{endpoint, path, server::Server, App},
};
fn main() -> Result<(), ExitFailure> {
let app = App::build(|mut scope| {
// a route that matches the root path.
scope.at("/")?.to({
// an endpoint that matches *all* met... |
mod kay_auto;
pub use kay_auto::*;
use kay::{ActorSystem, World};
// most basic possible boilerplate
#[derive(Clone, Compact)]
pub struct BasicActor {
id: BasicActorID,
}
// Actor must have creation method or it won't generate
impl BasicActor {
pub fn spawn(id: BasicActorID, _: &mut World) -> Self {
... |
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::ffi::CStr;
use std::ffi::CString;
use std::io;
use super::Addr;
use super::AddrMut;
use s... |
use std::io;
use std::collections::HashMap;
use std::ops::Deref;
use directory::ReadOnlySource;
use common::BinarySerializable;
use DocId;
use schema::{Field, SchemaBuilder};
use std::path::Path;
use schema::FAST;
use directory::{WritePtr, RAMDirectory, Directory};
use fastfield::FastFieldSerializer;
use fastfield::U3... |
//////////////////////////////////////////////////
// General Notes
//
// The Module System:
//
// Packages: A Cargo feature that lets you build, test, and share crates
// Crates: A tree of modules that produces a library or executable
// Modules and use: Let you control the organization, scope... |
use mockito::{mock, server_url};
speculate::speculate! {
before {
env_logger::try_init().ok();
}
test "simple response body" {
let m = mock("GET", "/")
.with_body("hello world")
.create();
let mut response = chttp::get(server_url()).unwrap();
let re... |
use errors::*;
use std::fs::{File, OpenOptions};
use std::io::{BufReader, BufWriter};
use std::io::{Read, Write};
use std::path::{Path, PathBuf};
use store::{DataInput, DataOutput, KVDataInput, KVDataOutput};
const CHUNK_SIZE: usize = 8 * 1024;
pub(crate) struct FsDataInput {
_path: PathBuf,
pub reader: BufR... |
struct Person {
name: &'static str,
age: u8
}
impl
fn main() {
let my = Person{name:"Adam", age:19};
println!("Length of my name is: {}", my.name.len());
}
|
use fancy_regex::Regex;
use lazy_static::lazy_static;
use serde::{Deserialize, Serialize};
use rocket::response::status::NotFound;
use rocket::http::hyper::uri::Uri;
use rocket::serde::json::Json;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
lazy_static! {
pub static ref PROFILE_REGEX: Reg... |
#[macro_use(values_t,value_t,crate_version,crate_authors)]
extern crate clap;
extern crate handlebars;
#[macro_use]
extern crate serde_json;
extern crate env_logger;
extern crate serde;
extern crate crossbeam;
use clap::{App, Arg,ArgMatches};
use handlebars::Handlebars;
use std::collections::btree_map::BTreeMap;
use... |
use crate::ast::expressions;
pub fn some_expression<E: expressions::Expression + 'static>(
expression: E,
) -> Option<Box<dyn expressions::Expression>> {
log_debug!("Made expression: {:?}", expression);
Some(Box::new(expression))
}
#[macro_export]
macro_rules! make_keyword_rule {
[$fn_name: ident, $((... |
// Copyright 2014-2015 The GeoRust 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 a... |
fn main() {
let x = 9;
if x > 9 {
println!("bigger than 9: {}", x);
} else if x > 3 {
println!("range (3-9]: {}", x);
} else {
println!("less-or-eq that 3: {}", x);
}
}
|
extern crate libc;
extern crate pam;
use std::os::raw::{c_char, c_int};
use std::ptr;
use std::mem;
use pam::{constants, module};
use pam::constants::*;
use pam::module::{PamHandleT, PamItem, PamResult};
use std::marker::{PhantomData};
#[link(name = "pam")]
extern {
fn pam_get_item(pamh: *const PamHandleT,
... |
#![feature(core)]
/*
* Datetime.rs
*
* Copyright 2015 Wiserlix <wiserlix@wiserlix.oa.to>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at you... |
use std::string::ParseError;
use std::str::FromStr;
type Severity = usize;
type Depth = usize;
type Range = usize;
type Time = usize;
type Trip = Vec<Scanner>;
fn main() {
let input = include_str!("input.txt");
let trip = get_trip(input);
println!("Answer #1: {:?}", trip_severity(&trip, 0));
println!... |
use std::cmp;
use std::env;
use std::fmt;
use std::fs;
#[derive(Clone, Copy, PartialEq)]
enum Position {
Floor,
Empty,
Occupied,
}
impl fmt::Debug for Position {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match &self {
Position::Floor => ".",
... |
/*
* Copyright (C) 2019-2022 TON Labs. All Rights Reserved.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an ... |
#[doc = "Reader of register IC_RXFLR"]
pub type R = crate::R<u32, super::IC_RXFLR>;
#[doc = "Reader of field `RXFLR`"]
pub type RXFLR_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:4 - Receive FIFO Level. Contains the number of valid data entries in the receive FIFO.\\n\\n Reset value: 0x0"]
#[inline(always)]
... |
use proc_macro_hack::proc_macro_hack;
#[proc_macro_hack]
pub use dotenv_codegen_implementation::{dotenv, dotenv_or_default};
|
use quote::{quote_spanned, ToTokens};
use super::{
FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, OperatorWriteOutput,
WriteContextArgs, RANGE_0, RANGE_1, RANGE_ANY,
};
/// > 1 input stream, *n* output streams
///
/// Takes the input stream and delivers a copy of each item to each out... |
// put_uvarint encodes a uint64 into buf and returns the number of bytes written.
// If the buffer is too small, put_uvarint will panic.
pub fn put_uvarint(mut buffer: impl AsMut<[u8]>, x: u64) -> usize {
let mut i = 0;
let mut mx = x;
let buf = buffer.as_mut();
while mx >= 0x80 {
buf[i] = mx as... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct KqlScriptsResourceCollectionResponse {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub value: ... |
#[macro_use]
extern crate log;
#[macro_use]
extern crate serde;
use std::{
collections::{BTreeSet, HashMap},
sync::Arc,
};
use anyhow::Result;
use secstr::SecUtf8;
use std::sync::Mutex;
use strum::EnumString;
pub mod accounts;
pub mod alerts;
pub mod options;
pub mod orders;
mod session;
pub mod transactions;
... |
pub use self::user_mapper::*;
mod user_mapper; |
// verification-helper: PROBLEM https://judge.yosupo.jp/problem/unionfind
use proconio::input;
fn main() {
input! {
vertices_len: usize,
queries_len: usize,
}
let mut uf = cprlib::union_find::UnionFind::new(vertices_len);
input! {
queries: [(u64, usize, usize); queries_len],
... |
use std::mem;
struct Node {
elem: i32,
next: Link,
}
pub struct List {
head: Link,
}
impl List {
pub fn new() -> Self {
List { head: Link::Empty }
}
pub fn push(&mut self, elem: i32) {
let new_node = Box::new(Node {
elem: elem,
// this line, replaces t... |
/// bindings for ARINC653P1-5 3.6.2.2 queuing
pub mod basic {
use crate::bindings::*;
use crate::Locked;
pub type QueuingPortName = ApexName;
/// According to ARINC 653P1-5 this may either be 32 or 64 bits.
/// Internally we will use 64-bit by default.
/// The implementing Hypervisor may cast ... |
#[derive(Serialize, Deserialize, Debug)]
#[allow(non_snake_case)]
pub struct SystemInfo {
pub Containers: u64,
pub Images: u64,
pub Driver: String,
pub DriverStatus: Vec<(String, String)>,
pub ExecutionDriver: String,
pub KernelVersion: String,
pub NCPU: u64,
pub MemTotal: u64,
pub N... |
/*
* A sample API conforming to the draft standard OGC API - Features - Part 1: Core
*
* This is a sample OpenAPI definition that conforms to the conformance classes \"Core\", \"GeoJSON\", \"HTML\" and \"OpenAPI 3.0\" of the draft standard \"OGC API - Features - Part 1: Core\". This example is a generic OGC API Fea... |
#![doc = "generated by AutoRust 0.1.0"]
#[cfg(feature = "package-2020-03-preview")]
mod package_2020_03_preview;
#[cfg(feature = "package-2020-03-preview")]
pub use package_2020_03_preview::{models, operations, API_VERSION};
#[cfg(feature = "package-pure-2020-03-preview")]
mod package_pure_2020_03_preview;
#[cfg(featur... |
use rocket::Request;
use rocket_contrib::Template;
#[catch(404)]
fn not_found(req: &Request) -> Template {
let mut map = std::collections::HashMap::new();
map.insert("path", req.uri().as_str());
Template::render("error/not-found", &map)
}
// https://api.rocket.rs/rocket_contrib/struct.Template.html |
use std::cell::RefCell;
use std::path::Path;
use std::sync::{Arc, Weak};
use pane::{Item, Pane};
use project::Project;
use platform;
pub struct Workspace {
/// Parent application reference.
pub application: Weak<platform::Application>,
pub project: Project,
/// Window to which the `Workspace` is rende... |
use db;
use error::Result;
use spec;
use may::sync::Mutex;
lazy_static! {
static ref WRITER_MUTEX: Mutex<()> = Mutex::new(());
}
/// save a unit
pub fn save_joint(joint: spec::Joint) -> Result<()> {
// first construct all the sql within a mutex
info!("saving unit = {:?}", joint.unit);
let _g = WRITER... |
#![allow(non_snake_case)]
#![allow(non_camel_case_types)]
use nell::Message;
use nell::Netlink;
use nell::Socket;
use nell::Family;
use nell::ffi::diag::{inet_diag_msg, inet_diag_req_v2, SOCK_DIAG_BY_FAMILY, INET_DIAG_INFO};
use nell::ffi::core::{NLM_F_DUMP, NLM_F_REQUEST, IPPROTO_TCP, AF_INET};
use nell::sys::Bytes;
u... |
use serde_json::{Value};
use std::collections::HashMap;
//Note that (thick) triples are not OWL
pub fn translate(v : &Value,
m : &HashMap<String, String>,
t: &dyn Fn(&Value, &HashMap<String, String>) -> Value)
-> Value {
let owl_operator: String = v[0].to_string();
//TO... |
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use futures::prelude::*;
use libp2p::core::{
self, muxing::StreamMuxerBox, transport::boxed::Boxed, transport::OptionalTransport, upgrade,
};
#[cfg(not(target_os = "unknown")... |
use super::*;
#[cfg(feature = "aes256-cbc")]
impl<S: Syscall> Aes256Cbc for ClientImplementation<S> {}
pub trait Aes256Cbc: CryptoClient {
fn decrypt_aes256cbc<'c>(&'c mut self, key: KeyId, message: &[u8])
-> ClientResult<'c, reply::Decrypt, Self>
{
self.decrypt(
Mechanism::Aes256C... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use super::{models, API_VERSION};
#[non_exhaustive]
#[derive(Debug, thiserror :: Error)]
#[allow(non_camel_case_types)]
pub enum Error {
#[error(transparent)]
Reservation_AvailableScopes(#[from] r... |
pub const POSEIDON_ROUNDS: usize = 31;
|
use super::*;
pub fn expression() -> Expression {
Expression {
boostrap_compiler,
typecheck,
codegen,
}
}
fn boostrap_compiler(_compiler: &mut Compiler) {}
pub fn typecheck(
resolver: &mut TypeResolver<TypecheckType>,
function: &TypevarFunction,
args: &Vec<TypeVar>,
) -> G... |
use std::rc::Rc;
use std::cell::RefCell;
use std::collections::VecDeque;
/// Tree structure provided by LeetCode
pub struct TreeNode {
pub val: i32,
pub left: Option<Rc<RefCell<TreeNode>>>,
pub right: Option<Rc<RefCell<TreeNode>>>,
}
impl TreeNode {
/// Creates a new TreeNode. Provided by LeetCod... |
#[doc = "Register `UR1` reader"]
pub type R = crate::R<UR1_SPEC>;
#[doc = "Register `UR1` writer"]
pub type W = crate::W<UR1_SPEC>;
#[doc = "Field `BCM4` reader - Boot Cortex-M4"]
pub type BCM4_R = crate::BitReader;
#[doc = "Field `BCM4` writer - Boot Cortex-M4"]
pub type BCM4_W<'a, REG, const O: u8> = crate::BitWriter... |
use blake3::Hasher;
use std::env;
use std::fs;
use std::io;
/// This is a utility program to hash files using blake3. I am reimplementing
/// this instead of relying on a utility to keep dependencies low.
fn main() {
// Get the command line arguments
let args: Vec<String> = env::args().collect();
// Check... |
#[doc = r"Register block"]
#[repr(C)]
pub struct CH {
#[doc = "0x00 - channel x configuration register"]
pub cr: CR,
#[doc = "0x04 - channel x number of data register"]
pub ndtr: NDTR,
#[doc = "0x08 - channel x peripheral address register"]
pub par: PAR,
#[doc = "0x0c - channel x memory addr... |
#[doc = r" Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Configuration Register"]
pub cfg: CFG,
#[doc = "0x04 - Software POI Reset"]
pub swpoi: SWPOI,
#[doc = "0x08 - Software POR Reset"]
pub swpor: SWPOR,
_reserved0: [u8; 8usize],
#[doc = "0x14 - TPIU reset"]
... |
use core::cell::{RefCell, RefMut};
use gfx::Bitmap3;
pub type FbGetter<'a> = fn() -> RefMut<'a, Framebuffer>;
pub fn top_screen<'a>() -> RefMut<'a, Framebuffer> {
unsafe {
TOP_SCREEN.borrow_mut()
}
}
static mut TOP_SCREEN: RefCell<Framebuffer> = RefCell::new(Framebuffer {
addr: 0,
width: 400... |
use log::info;
use serde::{Deserialize, Serialize};
use serde_xml_rs::from_reader;
use anyhow::Result;
#[derive(Debug, Deserialize, Serialize)]
pub struct EnaLineageTaxon {
#[serde(rename = "scientificName")]
pub name: String,
#[serde(rename = "taxId")]
pub taxid: usize,
pub rank: Option<String... |
use std::collections::HashMap;
use cards::{Pile, HALF_POINTS, NUM_CARDS, TALON_SIZE};
use contracts::{Klop};
use player::{PlayerId, ContractPlayers};
// A map of scores for individual players.
// Only players that have the score != 0 are included.
pub type PlayerScores = HashMap<PlayerId, int>;
// Calculate the scor... |
extern crate diesel;
use super::schema::posts;
use super::schema::comments;
use diesel::*;
#[derive(Queryable, Identifiable, PartialEq, Clone)]
pub struct Post {
pub id: i32,
pub title: String,
pub body: String,
pub published: bool,
}
#[derive(Insertable)]
#[table_name="posts"]
pub struct NewPost<'a... |
extern crate wallpaper;
extern crate chrono;
extern crate structopt;
extern crate serde_json;
extern crate serde;
use structopt::StructOpt;
use chrono::prelude::*;
use serde::{Deserialize, Serialize};
use std::fs;
use std::path::PathBuf;
fn parse_time(time: &str) -> NaiveTime {
NaiveTime::parse_from_str(time, "%H... |
#[doc = "Register `ETH_MACRxQC2R` reader"]
pub type R = crate::R<ETH_MACRX_QC2R_SPEC>;
#[doc = "Register `ETH_MACRxQC2R` writer"]
pub type W = crate::W<ETH_MACRX_QC2R_SPEC>;
#[doc = "Field `PSRQ0` reader - PSRQ0"]
pub type PSRQ0_R = crate::FieldReader;
#[doc = "Field `PSRQ0` writer - PSRQ0"]
pub type PSRQ0_W<'a, REG, c... |
v1_imports!();
use rocket::Route;
use db::{project, session, staff, student, user};
use session::Session;
pub fn get_routes() -> Vec<Route> {
routes![
get_projs,
new_proj,
update_proj,
rm_proj,
get_project_students
]
}
#[allow(needless_pass_by_value)]
#[get("/projects... |
use crate::{
cost_model::transferred_byte_cycles,
syscalls::{
utils::store_data, CellField, Source, SourceEntry, INDEX_OUT_OF_BOUND, ITEM_MISSING,
LOAD_CELL_BY_FIELD_SYSCALL_NUMBER, LOAD_CELL_SYSCALL_NUMBER, SUCCESS,
},
};
use byteorder::{LittleEndian, WriteBytesExt};
use ckb_types::{
co... |
use crate::common::{self, *};
pub type LinearLayout = AMember<AControl<AContainer<AMultiContainer<ALinearLayout<TestableLinearLayout>>>>>;
#[repr(C)]
pub struct TestableLinearLayout {
base: TestableControlBase<LinearLayout>,
orientation: layout::Orientation,
children: Vec<Box<dyn controls::Control... |
#[macro_use]
extern crate diesel;
pub mod apps;
pub mod config;
pub mod db;
pub mod errors;
pub mod redis;
pub mod routes;
#[cfg(test)]
mod tests;
|
// Copyright 2020 The VectorDB Authors.
//
// Code is licensed under Apache License, Version 2.0.
#[macro_use]
mod macros;
mod tests;
pub mod arithmetic;
pub mod comparator;
pub mod datum;
pub use self::datum::Datum;
|
use hex::FromHex;
fn xor(x1: Vec<u8>, x2: Vec<u8>) -> Vec<u8> {
assert_eq!(x1.len(), x2.len());
let mut out = vec![0; x1.len()];
for x in 0..x1.len() {
out[x] = x1[x] ^ x2[x];
}
return out;
}
fn main() {
let x1 = Vec::from_hex("1c0111001f010100061a024b53535009181c").expect("invalid hex... |
// Copyright 2020 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.
// Build lowlevel types into the library but don't let clients use them.
mod lowlevel;
// Reexport generated high level types for use by clients.
mod gene... |
#[cfg(feature = "src_mysql")]
use crate::sources::mysql::{BinaryProtocol as MySQLBinaryProtocol, TextProtocol};
#[cfg(feature = "src_postgres")]
use crate::sources::postgres::{
rewrite_tls_args, BinaryProtocol as PgBinaryProtocol, CSVProtocol, CursorProtocol,
SimpleProtocol,
};
use crate::{prelude::*, sql::CXQu... |
extern crate tomorrow_core;
extern crate hyper;
extern crate hyper_native_tls;
extern crate serde;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
pub const PACKAGE: &'static str = env!("CARGO_PKG_NAME");
pub const VERSION: &'static str = env!("CARGO_PKG_VERSION");
pub mod json;
pub mod raw;
mod b... |
#[derive(Serialize, Deserialize, Debug)]
struct Languages {
lang: Vec<Language>,
}
#[derive(Serialize, Deserialize, Debug)]
struct Language {
name: String,
identifier: String,
extension: String,
}
pub fn get_lang(extension: String) -> Option<String> {
let langs = get_langdata().lang;
for lang... |
use std::ptr;
use rustc_serialize::hex::FromHex as RustcFromHex;
use bloomchain::Bloom;
pub trait FromHex {
fn from_hex(s: &str) -> Self where Self: Sized;
}
impl FromHex for Bloom {
fn from_hex(s: &str) -> Self {
let mut res = [0u8; 256];
let v = s.from_hex().unwrap();
assert_eq!(res.len(), v.len());
unsaf... |
mod gfx;
use crate::gfx::*;
use lazy_static::*;
use std::collections::*;
use std::env;
use std::io::*;
use termcolor::*;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 1 || args[1] == "--help" {
print_help(&args);
return;
}
if args[1] == "--species" {
... |
#[allow(non_snake_case)]
fn main() {
println!("{}", addPers(199))
}
/// Returns the additive persistence of a number
///
/// # Arguments
/// * `num` - The i32 you want the additive persistence of
///
/// # An Example
/// addPers(13) would return 1
#[allow(non_snake_case)]
fn addPers(mut num: i32) -> i32 {
let ... |
// Copyright 2012-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-MI... |
use ocl;
use std::ffi::CString;
use parenchyma::error::Result;
use parenchyma::frameworks::OpenCLContext;
// const WGS: usize = 64;
// const WGS1: usize = 64;
// const WGS2: usize = 64;
// /// Caches instances of `Kernel`
// #[derive(Debug)]
// pub struct OpenCLPackage {
// pub(in super) program: ocl::Program,
//... |
pub mod cr1 {
pub mod ckd {
pub fn get() -> u32 {
unsafe {
(core::ptr::read_volatile(0x40014C00u32 as *const u32) >> 8) & 0x3
}
}
pub fn set(val: u32) {
unsafe {
let mut reg = core::ptr::read_volatile(0x40014C00u32 as *cons... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.