text stringlengths 8 4.13M |
|---|
//! A button which can move through a list of labels.
use druid::{AppLauncher, PlatformError, Widget, WindowDesc};
use crochet::{AppHolder, Button, Cx, DruidAppData, Id, Label, List, ListData, Row};
fn main() -> Result<(), PlatformError> {
let main_window = WindowDesc::new(ui_builder);
let data = Default::de... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use super::{constraints::CompositionPoly, StarkDomain, TracePolyTable};
use air::{Air, DeepCompositionCoefficients, EvaluationFrame};
use ... |
pub mod treats {
pub mod shop {}
pub enum Treat {
Candy,
IceCream,
}
pub struct ConsumedTreat {
treat: Treat,
}
}
|
use std::ptr;
use std::ops::{Deref, DerefMut};
use raw;
pub struct EffectParam {
raw: *mut raw::EffectParam
}
impl EffectParam {
pub unsafe fn from_raw(raw: *mut raw::EffectParam) -> EffectParam {
EffectParam {
raw: raw
}
}
pub fn set_texture(&mut self, texture: &super::Te... |
#[macro_use] extern crate lazy_static;
extern crate regex;
use std::fs::File;
use std::io::prelude::*;
use std::collections::{HashMap, HashSet};
use regex::Regex;
lazy_static! {
static ref MASKLINE: Regex = Regex::new(r"^mask\s+=\s+([X01]+)$").unwrap();
static ref MEMOLINE: Regex = Regex::new(r"^mem\[(\d+)\]... |
use rand::Rng;
pub fn degrees_to_radians(degrees: f64) -> f64 {
degrees * std::f64::consts::PI / 180.0
}
pub fn random_double(min: f64, max: f64) -> f64 {
let mut rng = rand::thread_rng();
min + (max - min) * rng.gen::<f64>()
}
pub fn clamp(x: f64, min: f64, max: f64) -> f64 {
if x < min {
re... |
mod common;
use itertools::Itertools;
fn get_digits(n: i64) -> [i8; 6] {
assert!(n >= 0);
assert!(n <= 999_999);
let mut x = n;
let mut d = [0i8; 6];
const EXP: [i64; 6] = [100_000, 10_000, 1000, 100, 10, 1];
for i in 0..6usize {
let m = EXP[i];
d[i] = (x / m) as i8;
x %... |
use ash;
use ash::extensions::khr;
use ash::prelude::VkResult;
use ash::vk;
use xcb::base::Connection;
use xcb::xproto::Window;
pub struct SurfaceWrapper<'a> {
pub entry: khr::Surface,
pub surface: vk::SurfaceKHR,
xcb_conn: std::marker::PhantomData<&'a Connection>,
}
impl<'a> SurfaceWrapper<'a> {
pub... |
use super::ray::Ray;
use super::vec3::Vec3;
pub struct Camera {
origin: Vec3,
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
u: Vec3,
v: Vec3,
lens_radius: f32,
}
impl Camera {
pub fn new(
look_from: Vec3,
look_at: Vec3,
vup: Vec3,
vfov: f32,... |
#![allow(unused_imports, unused_import_braces, dead_code)]
use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
input::mouse::MouseMotion,
prelude::*,
reflect::TypeUuid,
render::{
camera::Camera,
pipeline::{PipelineDescriptor, RenderPipeline},
render_graph::{base, AssetRenderResourcesN... |
#![allow(dead_code)]
use clap::Arg;
pub fn arg_connect_host<'a, 'b>() -> Arg<'a, 'b> {
Arg::with_name("connect_host")
.long("connect_host")
.value_name("CONNECT_HOST")
.required(false)
.takes_value(true)
.help("specify a connecting host")
}
pub fn arg_connect_port<'a, 'b>()... |
#[derive(Clone, Copy, Debug)]
enum Symbol {
Num(usize),
Op(Op),
}
#[derive(Clone, Copy, Debug)]
enum Op {
Add,
Multiply,
}
pub fn solve(input: &str) -> usize {
input
.lines()
.map(|line| {
let line = line.replace("(", "( ").replace(")", " )");
let expr: Vec<... |
#![feature(panic_implementation)]
#![no_std]
#![cfg_attr(not(test), no_main)]
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
#[macro_use]
extern crate blog_os;
extern crate x86_64;
#[macro_use]
extern crate lazy_static;
use core::panic::PanicInfo;
#[cfg(not(test))] // only compile when the test ... |
use std::any::{type_name, Any};
use crate::{
ChangeViewState, CompositeShape, CompositeShapeIter, CompositeShapeIterMut, Model, Node, Shape, SystemMessage,
Transform,
};
pub trait AsAny: Any {
fn into_any(self: Box<Self>) -> Box<dyn Any>;
fn as_any(&self) -> &dyn Any;
fn as_any_mut(&mut self) -> &... |
use ranges::Ranges;
use std::collections::{HashMap, HashSet};
struct Thing {
ident: String,
associated_things: HashMap<String, String>,
properties: HashMap<String, String>,
}
impl Thing {
pub fn new(ident: &str) -> Thing {
Thing {
ident: ident.to_owned(),
associated_thi... |
use serenity::client::Context;
use serenity::futures::StreamExt;
use serenity::model::{channel::Message, id::UserId};
use std::collections::HashMap;
use std::result::Result;
pub mod card;
pub mod hand;
pub mod player;
pub mod playground;
type CommandResult<T> = Result<(), T>;
pub enum Status {
Building,
Star... |
#![allow(unreachable_code, unconditional_recursion)]
extern crate rand;
fn main() {
diverge();
func(0);
bar(0);
}
fn diverge() -> ! {
if rand::random() {
diverge()
} else {
panic!()
}
}
fn func (a: i32) -> ! {
if a > 0 {
func(a + 1)
} else if a < 0 {
fu... |
#![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)]
GetLocations(#[from] get_locations::E... |
use near_sdk::json_types::U128;
use near_sdk::serde_json::json;
use near_sdk_sim::{init_simulator, to_yocto, UserAccount, DEFAULT_GAS};
const ACA_ID: &str = "aca";
const FLUXAGGREGATOR_ID: &str = "flux_aggregator";
const LINKTOKEN_ID: &str = "link";
const EAC_ID: &str = "eac";
const EAC_WITHOUT_ACCESS_CONTROLLER_ID: &... |
/*
* Datadog API V1 Collection
*
* Collection of all Datadog Public endpoints.
*
* The version of the OpenAPI document: 1.0
* Contact: support@datadoghq.com
* Generated by: https://openapi-generator.tech
*/
use reqwest;
use crate::apis::ResponseContent;
use super::{Error, configuration};
/// struct for typ... |
use std::convert::TryInto;
use subspace_codec::Spartan;
use subspace_core_primitives::{Piece, PIECE_SIZE};
// CUDA accepts multiples of 1024 pieces, and any remainder piece will be handled on CPU
// this test aims to process 1024 pieces in GPU, and 2 pieces in CPU, hence 1026 pieces.
#[test]
fn test_1026_piece() {
... |
/* -*- Mode: rust; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- */
#![allow(unused_parens)]
extern crate rand;
use std::cmp;
static NAO_SAMPLES: u32 = 8;
static NSUBSAMPLES: u32 = 2;
mod vector3 {
use std::ops::{Add, Sub};
pub struct Vector3 {
pub x: f32,
pub y: f32,
... |
use super::*;
use crate::{
mock::*,
utils::keys::{Commitment, ScalarData},
};
use bulletproofs::{r1cs::Prover, BulletproofGens, PedersenGens};
use bulletproofs_gadgets::{
fixed_deposit_tree::builder::FixedDepositTreeBuilder,
poseidon::{
builder::{Poseidon, PoseidonBuilder},
PoseidonSbox, Poseidon_hash_2,
},
s... |
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(transparent)]
pub struct MethodAttributes(pub(crate) u32);
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[repr(transparent)]
pub struct TypeAttributes(pub(crate) u32);
impl MethodAttributes {
pub fn special(&self) -> bool {
self.0 & 0b1000_0000_0000 != 0... |
fn main() {
let mut input = std::fs::read_to_string("input").unwrap();
input.pop();
part1(&input);
part2(&input);
}
fn part1(input: &str) {
let floor = input
.chars()
.fold(0, |acc, c| if c == '(' { acc + 1 } else { acc - 1 });
println!("{}", floor);
}
fn part2(input: &str) {... |
use exonum::encoding::Field;
use currency::assets::AssetBundle;
use currency::error::Error;
encoding_struct! {
/// Wallet data.
#[derive(Eq, PartialOrd, Ord)]
struct Wallet {
balance: u64,
assets: Vec<AssetBundle>,
}
}
impl Wallet {
/// Create new wallet with zero balance and no ... |
use serde::{Deserialize, Serialize};
use super::link_asset::*;
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct Banner {
img: String,
link: Option<LinkAsset>,
ext: Option<BannerExt>,
}
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct BannerExt {}
|
// Copyright 2018 PingCAP, Inc.
//
// 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 i... |
/*
* MinIO Rust Library for Amazon S3 Compatible Cloud Storage
* Copyright 2019 MinIO, Inc.
*
* 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/LICE... |
#[doc = "Reader of register MDMA_C8IFCR"]
pub type R = crate::R<u32, super::MDMA_C8IFCR>;
#[doc = "Writer for register MDMA_C8IFCR"]
pub type W = crate::W<u32, super::MDMA_C8IFCR>;
#[doc = "Register MDMA_C8IFCR `reset()`'s with value 0"]
impl crate::ResetValue for super::MDMA_C8IFCR {
type Type = u32;
#[inline(... |
use anyhow::Result;
use nom::{
branch::alt,
bytes::complete::tag,
character::complete::{digit1, line_ending, one_of, space1},
combinator::{map, opt, recognize, value},
multi::separated_list1,
sequence::pair,
IResult,
};
use std::{fs, str::FromStr};
#[derive(Clone, Debug)]
enum Operation {
... |
// The MIT License (MIT)
//
// Copyright (c) 2015 Johan Johansson
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use,... |
//! Line-level syntactic constructs.
//!
//! An [`Atom`] represents the simplest single instruction that the assembler
//! can understand. There are fundamentally four kinds of atoms:
//! - [Instructions](../code/index.html), the most interesting kind of atom.
//! - Labels, which consist of a symbol (or a single digit)... |
//! The parser module implements a nock syntax parser.
// Copyright (2017) Jeremy A. Wall.
//
// 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... |
// This file is part of rdma-core. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/rdma-core/master/COPYRIGHT. No part of rdma-core, including this file, may be copied, modified, propagated, or distributed ... |
use bytes;
use bytes::BytesMut;
use tokio_util::codec:: {Decoder, Encoder};
#[derive(Ord, PartialOrd, Eq, PartialEq)]
pub struct Frame {
meta : Vec<String>,
data : String,
}
impl Decoder for Frame {
type Item = Frame;
type Error = std::io::Error;
fn decode(&mut self, src: &mut BytesMut) -> Result... |
//! # General-Purpose file loader
//!
//! This is the original entry point to the FDB loading API. A [`SchemaLoader`] wraps
//! an implementation of [`BufRead`] and loads the data from the file into an
//! instance of [`Schema`].
//!
//! This uses the methods defined in the `reader` module and produces the data
//! str... |
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
if nums.len() <= 1 {
return nums.len() as i32
}
let mut pointer = 1;
for i in 1..nums.len() {
if nums[i] > nums[pointer-1] {
nums[pointer] = nums[i];
pointer += 1;
}
}
pointer as i32
}
#[test... |
#[cfg(feature = "arbitrary")]
use quickcheck::{Arbitrary, Gen};
use num::One;
use rand::{Rng, Rand};
use alga::general::Real;
use alga::linear::Rotation as AlgaRotation;
use core::ColumnVector;
use core::dimension::{DimName, U1, U2, U3, U4};
use core::allocator::{OwnedAllocator, Allocator};
use core::storage::OwnedS... |
#[cfg(test)]
#[path = "../../../tests/unit/solver/objectives/total_unassigned_jobs_test.rs"]
mod total_unassigned_jobs_test;
use super::*;
use crate::algorithms::nsga2::Objective;
use crate::models::problem::Job;
use crate::utils::compare_floats;
use std::ops::Deref;
use std::sync::Arc;
/// A type which allows to con... |
use canrun::{any, unify, var, Goal};
use canrun_collections::{example::Collections, lmap};
use criterion::Criterion;
macro_rules! goal_bench {
($c:ident $name:literal ($($v:ident),+) $goal:block) => {
$c.bench_function(&format!("{} goal", $name), |b| {
$(let $v = var();)+
b.iter(|| ... |
// right rotate
fn rotate_64(val: u64, shift: i64) -> u64 {
return if shift == 0 { val } else { ( val >> shift ) | ( val << ( 64 - shift ) ) };
}
fn shift_mix_64() -> u64 {
return val ^ ( val >> 47 );
}
pub fn city_hash() {
let k0 = 0xc3a5c85c97cb3127u64;
let k1 = 0xb492b66fbe98f273u64;
let k2... |
use super::{definition::Definition, expression::Expression};
use std::sync::Arc;
#[derive(Clone, Debug, PartialEq)]
pub struct LetRecursive {
definitions: Vec<Definition>,
expression: Arc<Expression>,
}
impl LetRecursive {
pub fn new(definitions: Vec<Definition>, expression: impl Into<Expression>) -> Self... |
use crate::types::{BlsPublic, Public};
use serde::{Deserialize, Serialize};
/// The ledger type returned from contract calls.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Ledger {
/// Name of the ledger
#[serde(rename = "ledgerName")]
pub name: String,
/// ID of the ledger
... |
use anyhow::Result;
use netkitten::{connect, listen, scan, Options};
use structopt::StructOpt;
fn main() -> Result<()> {
let opt = Options::from_args();
match opt {
Options::Listen(listen_opts) => listen(&listen_opts),
Options::Connect(connect_opts) => connect(&connect_opts),
Options::... |
fn main() {
println!("{}", zoom(103));
}
fn zoom(n: i32) -> String {
let k = n as usize;
let mut state: Vec<Vec<String>> = vec![vec!["□".to_string(); k]; k];
let mut tl = n / 2;
let mut rb = n / 2;
state[k / 2][k / 2] = "■".to_string();
while tl >= 0 {
for c in tl..rb + 1 {
state[tl as usize][c as usiz... |
use antlr::int_stream::IntStream;
use antlr::misc::interval::Interval;
pub trait CharStream: IntStream {
fn text(&self, interval: Interval) -> str;
}
|
use rtm::{File, Message};
use timestamp::Timestamp;
/// Pins an item to a channel.
///
/// Wraps https://api.slack.com/methods/pins.add
#[derive(Clone, Debug, Serialize)]
#[serde(rename = "snake_case")]
pub enum Pinnable {
/// File to pin or unpin
File(::FileId),
/// Timestamp of the message to pin or unp... |
use super::regex::Regex;
use super::*;
const WEASELS: &str = r"\b(many|various|very|fairly|several|extremely|exceedingly|quite|remarkably|few|surprisingly|mostly|largely|huge|tiny|((are|is) a number)|excellent|interestingly|significantly|substantially|clearly|vast|relatively|completely)\b";
pub struct Weasel {}
impl... |
#![doc = "generated by AutoRust 0.1.0"]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(unused_imports)]
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub mod operations {
use crate::models::*;
use reqwest::StatusCode;
use snafu::{ResultExt, Snafu};
pub async f... |
#[doc = "Register `RPR2` reader"]
pub type R = crate::R<RPR2_SPEC>;
#[doc = "Register `RPR2` writer"]
pub type W = crate::W<RPR2_SPEC>;
#[doc = "Field `RPIF2` reader - Rising edge event pending for configurable line 34"]
pub type RPIF2_R = crate::BitReader<RPIF2R_A>;
#[doc = "Rising edge event pending for configurable ... |
use alloc::{vec, vec::Vec};
// page size in bytes
pub const PAGE_SIZE: usize = 16 * 1024;
// different memory blocks size's
pub const SIZE_16K: usize = PAGE_SIZE;
pub const SIZE_32K: usize = PAGE_SIZE * 2;
pub const SIZE_48K: usize = PAGE_SIZE * 3;
pub const SIZE_128K: usize = PAGE_SIZE * 8;
// count of all memory blo... |
use actix_web::{web, HttpResponse, Responder};
use askama::Template;
use crate::db_connection::SqlitePool;
use crate::models::user::{User, NewUser};
use crate::models::product::NewProduct;
use crate::templates::user::{UserTemplate, UsersTemplate, AddUserTemplate};
use crate::handlers::pool_handler::pool_handler;
use st... |
use core::future::Future;
/// Wait for a pin to become high.
pub trait WaitForHigh {
type Future<'a>: Future<Output = ()> + 'a;
/// Wait for a pin to become high.
///
/// If the pin is already high, the future completes immediately.
/// Otherwise, it completes when it becomes high.
fn wait_for... |
trait Mediator {
fn create_colleagues(&self);
fn colleague_changed(&self);
}
struct LoginFrame {
title: String,
}
impl LoginFrame {
fn new(title: String) -> LoginFrame {
let lf = LoginFrame {
title: title,
};
lf.create_colleagues();
lf.colleague_changed();
... |
use color_eyre::Report;
use core::convert::TryFrom;
use std::fmt::Display;
use daggy::{Dag, NodeIndex, Walker};
use tracing::instrument;
use crate::{
errors::SpideogError,
kraken::{ReportRecord, Taxon},
parser::parse_ident_organism_name,
};
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct IndentedTaxon ... |
extern crate ndarray;
extern crate ndarray_rand;
extern crate rand;
use crate::meshgrid::meshgrid;
use ndarray::{arr2, stack, Array, Array2, Axis};
use ndarray_rand::RandomExt;
use rand::distributions::Uniform;
use std::f64::consts::PI;
use std::iter::FromIterator;
/// A struct storing information about an antenna ar... |
mod utils;
mod fraction_normal;
mod fraction_big;
mod continued_fraction;
mod continued_fraction_big;
pub use self::utils::*;
pub use self::fraction_normal::Fraction;
pub use self::fraction_big::FractionBig;
pub use self::continued_fraction::ContinuedFraction;
pub use self::continued_fraction_big::ContinuedFractionBig... |
#![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-artifacts-2021-07-01-preview")]
pub mod package_artifacts_2021_07_01_preview;
#[cfg(all(feature = "package-artifacts... |
use crate::listnode::ListNode;
pub fn reverse_list(head: Option<Box<ListNode>>) -> Option<Box<ListNode>> {
if let Some(mut head) = head {
let mut reversed = None;
let mut tail = head.next.take();
while let Some(mut t) = tail {
head.next = reversed;
reversed = Some(he... |
use super::DispatchQueue;
use crate::core::{Arc, ObjectType};
use std::{cell::UnsafeCell, ffi::c_void, panic::RefUnwindSafe, ptr::NonNull};
/// The base type for dispatch objects.
///
/// Documentation:
/// [Swift](https://developer.apple.com/documentation/dispatch/dispatchobject) |
/// [Objective-C](https://developer... |
#![allow(non_snake_case)]
#![doc(include = "../../docs/range-proof-protocol.md")]
extern crate alloc;
#[cfg(feature = "std")]
extern crate rand;
#[cfg(feature = "std")]
use self::rand::thread_rng;
use alloc::vec::Vec;
use core::iter;
use curve25519_dalek::ristretto::{CompressedRistretto, RistrettoPoint};
use curve2... |
use hive_ddl_parser;
use std::io::stdin;
use std::io::BufRead;
fn main() {
let ddl: String = stdin().lock().lines().map(|l| l.unwrap()).collect();
println!(
"{:?}",
hive_ddl_parser::parse_hive_create_table(&ddl).unwrap()
);
}
|
use ndarray::Array2;
use std::str;
use self::solution::Solution;
// semantic newtype
pub type Sequence<'a> = &'a [u8];
pub type Coordinates = (usize, usize);
pub struct Problem<'a> {
match_: i32,
mismatch: i32,
gap_extend: i32,
seq_x: Sequence<'a>,
seq_y: Sequence<'a>,
}
impl<'a> Problem<'a> {
pub fn new(
m... |
use crate::game::utils::Coord;
use crate::game::Drawable;
use std::io::{Error, Write};
use rand::{thread_rng, Rng};
pub struct Food {
pos: Coord,
}
impl Food {
pub fn new(win_size: &Coord) -> Food {
let mut rng = thread_rng();
let (x, y) = (rng.gen_range(1..win_size.x), rng.gen_range(1..win_... |
use std::sync::Arc;
use std::collections::HashMap;
use sdl2::surface::Surface;
type SurfaceArc<'a> = Arc<Surface<'a>>;
pub struct SurfaceLoader<'a> {
surfaces : HashMap<String, SurfaceArc<'a>>
}
impl<'a> SurfaceLoader<'a> {
pub fn new<'b> () -> SurfaceLoader<'b> {
SurfaceLoader {
surfac... |
pub mod as_pb;
pub mod common;
pub mod gw;
#[cfg(feature = "grpc_support")]
pub mod fuota;
#[cfg(feature = "grpc_support")]
pub mod geo;
#[cfg(feature = "grpc_support")]
pub mod nc;
#[cfg(feature = "grpc_support")]
pub mod ns;
|
#[doc = "Reader of register DYN_RECONFIG"]
pub type R = crate::R<u32, super::DYN_RECONFIG>;
#[doc = "Writer for register DYN_RECONFIG"]
pub type W = crate::W<u32, super::DYN_RECONFIG>;
#[doc = "Register DYN_RECONFIG `reset()`'s with value 0"]
impl crate::ResetValue for super::DYN_RECONFIG {
type Type = u32;
#[i... |
//! # CKB AppConfig
//!
//! Because the limitation of toml library,
//! we must put nested config struct in the tail to make it serializable,
//! details https://docs.rs/toml/0.5.0/toml/ser/index.html
use path_clean::PathClean;
use std::fs;
use std::path::{Path, PathBuf};
use serde::{Deserialize, Serialize};
use ckb... |
use regex::Regex;
use std::collections::HashSet;
use std::fs::{read_dir, DirEntry};
use vt::types::*;
pub fn get_paths(dir: &String) -> MyResult<Vec<Path>> {
let path = std::path::Path::new(&dir);
let entries = read_dir(path).or_else(|e| error(format!("Error getting paths: {}", e)))?;
let mut dir_entries... |
#[derive(Debug)]
pub struct Account {
pub client: u16,
pub available: u64,
pub held: u64,
pub locked: bool,
}
impl Account {
pub fn new_with_client(client: u16) -> Account {
Account {
client,
available: Default::default(),
held: Default::default(),
... |
//! Iron handlers for our remote camera systems.
use {Error, Paginate, Result};
use cameras::{CameraConfig, Config, camera, image};
use glacio::Image;
use iron::{IronResult, Request, Response, status};
use iron::headers::Location;
use json;
use router::Router;
/// A multi-route handler for camera-based requests.
///
... |
struct Solution;
impl Solution {
pub fn get_permutation(n: i32, mut k: i32) -> String {
let n = n as usize;
let fractorial = Self::gen_factorial(n);
k -= 1; // 从 0 开始的
// 标记是否被用过了
let mut valid = vec![1; n + 1];
let mut ans = String::with_capacity(n);
for ... |
use super::super::atom::{
btn::{self, Btn},
common::Common,
dropdown::{self, Dropdown},
file_catcher::{self, FileCatcher},
header::{self, Header},
marker::Marker,
table::{self, Table},
text::Text,
};
use super::super::organism::{
modal_chat_user::{self, ModalChatUser},
modal_dice... |
// Traits used by subte
use fourthrail::*;
pub trait Agent {
fn act(&self) -> Force;
}
pub trait Position {
fn pos(&self) -> Coord;
fn move_in(&mut self, Direction);
fn move_to(&mut self, Coord);
}
pub trait Display {
fn display(&self) -> Icon;
}
pub trait Named {
fn nym(&self) -> &str;
}
|
use std;
use crate::ast::MacroIdentifier;
use crate::lexer;
use crate::parser;
use std::path::Path;
use crate::ast::{
Statements,
Statement,
Directive,
ByteValue,
IncludeType,
ArgType,
MacroStatement,
SpriteType
};
use crate::expression::{EvaluationError,Expr,Arg};
use std::collections:... |
pub fn get_cutlery() {} |
use std::collections::HashSet;
/// Representing a subnet with a certain state
#[derive(Debug, Eq, PartialEq)]
pub(crate) struct Subnet {
state: SubnetState,
}
impl Subnet {
pub(crate) fn new() -> Self {
Self {
state: SubnetState::Floating,
}
}
pub(crate) fn val(&self) ... |
extern crate bitreader;
extern crate bitstream_io;
extern crate bitstream_reader;
use std::collections::HashMap;
use std::time::{Duration, Instant};
use bitstream_reader::BitStream;
type TestFn = fn(Vec<u8>, usize) -> u32;
fn main() {
let vec = vec![1u8; 1024 * 1024];
let sizes = [
(1, 1048576),
... |
#[doc = "Reader of register FM_ADDR"]
pub type R = crate::R<u32, super::FM_ADDR>;
#[doc = "Writer for register FM_ADDR"]
pub type W = crate::W<u32, super::FM_ADDR>;
#[doc = "Register FM_ADDR `reset()`'s with value 0"]
impl crate::ResetValue for super::FM_ADDR {
type Type = u32;
#[inline(always)]
fn reset_va... |
// Copyright 2021 Contributors to the Parsec project.
// SPDX-License-Identifier: Apache-2.0
mod common;
use crate::common::{SO_PIN, USER_PIN};
use common::init_pins;
use cryptoki::error::{Error, RvError};
use cryptoki::mechanism::Mechanism;
use cryptoki::object::{Attribute, AttributeInfo, AttributeType, KeyType, Obje... |
#[macro_use]
extern crate once_cell;
extern crate crossbeam_utils;
use crossbeam_utils::thread::scope;
use std::{
mem,
thread,
ptr,
cell::Cell,
sync::atomic::{AtomicUsize, Ordering::SeqCst},
};
use once_cell::{sync, unsync};
fn go<F: FnOnce() -> ()>(mut f: F) {
struct Yolo<T>(T);
unsafe i... |
use azure_core::prelude::*;
use azure_storage::blob::prelude::*;
use azure_storage::core::prelude::*;
use chrono::{Duration, Utc};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
// First we retrieve the account name and master key from environment variables.
... |
extern crate jni;
use jni::{
objects::JClass,
sys::jint,
JNIEnv
};
/// Returns the result of substraction of two integers
fn sub_internal(a: i32, b:i32) -> i32 {
a - b
}
/// Returns the sum of two integers
pub fn sum(a1: i32, a2: i32) -> i32 {
a1 + a2
}
// **********************************
// ... |
// This file is part of Substrate.
// Copyright (C) 2020-2022 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
// 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 F... |
#![feature(const_fn)]
#![feature(used)]
#![no_std]
// version = "0.2.2", default-features = false
extern crate cast;
#[macro_use]
extern crate cortex_m;
// version = "0.2.0"
extern crate cortex_m_rt;
// version = "0.1.0"
#[macro_use]
extern crate cortex_m_rtfm as rtfm;
extern crate f3;
use cast::{u8, usize};
use ... |
#[doc = "Register `DTS_ITR1` reader"]
pub type R = crate::R<DTS_ITR1_SPEC>;
#[doc = "Register `DTS_ITR1` writer"]
pub type W = crate::W<DTS_ITR1_SPEC>;
#[doc = "Field `TS1_LITTHD` reader - TS1_LITTHD"]
pub type TS1_LITTHD_R = crate::FieldReader<u16>;
#[doc = "Field `TS1_LITTHD` writer - TS1_LITTHD"]
pub type TS1_LITTHD... |
use crate::WyRand;
use core::{
cell::UnsafeCell,
ops::{Deref, DerefMut},
};
thread_local! {
static WYRAND: UnsafeCell<WyRand> = UnsafeCell::new(WyRand::new());
}
#[doc(hidden)]
pub struct TlsWyRand(*mut WyRand);
impl Deref for TlsWyRand {
type Target = WyRand;
/// Safety: [`TlsWyRand`] is neither [Send] nor [S... |
//! DNS lookup utils
//!
//!
//! ## Example
//!
//! ```rust
//! extern crate actix;
//! extern crate futures;
//! use futures::{future, Future};
//! use actix::prelude::*;
//! use actix::actors::dns;
//!
//! fn main() {
//! let sys = System::new("test");
//!
//! let addr = SyncArbiter::start(3, || dns::DnsResol... |
#[doc = "Register `WUCR` reader"]
pub type R = crate::R<WUCR_SPEC>;
#[doc = "Register `WUCR` writer"]
pub type W = crate::W<WUCR_SPEC>;
#[doc = "Field `WUPEN1` reader - enable wakeup pin WUPx These bits are set and cleared by software. Note: an additional wakeup event is detected if WUPx pin is enabled (by setting the ... |
#[doc = "Register `PCR` reader"]
pub type R = crate::R<PCR_SPEC>;
#[doc = "Register `PCR` writer"]
pub type W = crate::W<PCR_SPEC>;
#[doc = "Field `ETTXE` reader - ETTXE"]
pub type ETTXE_R = crate::BitReader;
#[doc = "Field `ETTXE` writer - ETTXE"]
pub type ETTXE_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, O>;
... |
// --------------------------------------------------------------------------
//
// Rusty Kong
// Copyright (C) 2018 Jeff Panici
// All rights reserved.
//
// This software source file is licensed according to the
// MIT License. Refer to the LICENSE file distributed along
// with this source file to learn more.
//
//... |
use crate::{
compass::{Compass, InvalidCompass},
effects::LinearFadeOutBuilder,
note::{Note, NoteGroup, NoteKind},
num::{DurationExt, Natural, NaturalRatio, Real},
pitch::{Key, Pitch},
source::Source,
tempo::{Dot, NoteTime, NoteValue, TimeSignature},
wave::{Wave, WaveBuilder},
};
use num... |
use std::cmp::Reverse;
use std::collections::BTreeSet;
use rand::seq::SliceRandom;
use crate::nhlapi;
use crate::nhlapi::schedule::Game;
use crate::nhlapi::standings::TeamRecord;
use crate::nhlapi::teams::Team;
use crate::Api;
pub const TIMES: u32 = 50_000;
#[derive(Debug, Copy, Clone)]
struct Entry {
team_id: ... |
use ndarray::{Array, Array2};
use err_derive::Error;
use std::num::ParseIntError;
#[derive(Debug, Error)]
pub enum MatrixParseError {
#[error(display = "could not parse number due to error {}", _0)]
InvalidNumber(ParseIntError),
#[error(
display = "matrix is malformed, expected width and height ar... |
// Copyright 2018 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 futures::prelude::*;
use futures::task;
use futures::stream::Fuse;
pub struct GroupAvailable<S> where S: Stream {
stream: Fuse<S>,
error: Opti... |
// raii.rs
fn create_box() {
// Allocate an integer on the heap
let _box1 = Box::new(3);
// `_box1` is destroyed here, and memory gets freed
}
fn main() {
// Allocate an integer on the heap
let _box2 = Box::new(5);
// A nested scope:
{
// Allocate an integer on the heap
let ... |
#[doc = "Register `RCC_MP_APB5LPENCLRR` reader"]
pub type R = crate::R<RCC_MP_APB5LPENCLRR_SPEC>;
#[doc = "Register `RCC_MP_APB5LPENCLRR` writer"]
pub type W = crate::W<RCC_MP_APB5LPENCLRR_SPEC>;
#[doc = "Field `SPI6LPEN` reader - SPI6LPEN"]
pub type SPI6LPEN_R = crate::BitReader;
#[doc = "Field `SPI6LPEN` writer - SPI... |
// Copyright © 2015, Peter Atashian
extern crate gcc;
fn main() {
gcc::compile_library("liblz4.a", &["src/lz4.c"]);
}
|
use super::*;
#[derive(Debug)]
pub struct BTreeOverlay {
pub num_internal_nodes: usize,
pub num_leaf_nodes: usize,
pub first_node: usize,
pub next_node: usize,
offsets: Vec<usize>,
}
impl BTreeOverlay {
pub fn new<T>(item: &T, initial_offset: usize) -> Result<Self, Error>
where
T: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.