text stringlengths 8 4.13M |
|---|
#[derive(Copy, Clone, Eq, PartialEq)]
struct Edge(pub usize, pub usize, pub usize);
impl Ord for Edge {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
other.2.cmp(&self.2)
}
}
impl PartialOrd for Edge {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(... |
pub mod navtop;
pub mod landing_page_navtop;
pub mod sidebar; |
extern crate hex;
#[inline(always)]
pub fn u64to8(mut num: u64) -> [u8; 8] {
let mut out: [u8; 8] = [0; 8];
for i in 0..8 {
out[i] = (num & 0b11111111) as u8;
num >>= 8;
}
out
}
#[inline(always)]
pub fn u8to64(nums: [u8; 8]) -> u64 {
let mut res: u64 = 0;
for i in 0..8 {
... |
//! Testing whether Tokio doesn't display timeouts correctly on Windows
//!
//! # Examples
//!
//! ```
//! // tbi
//! ```
#![forbid(unsafe_code, future_incompatible, rust_2018_idioms)]
#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs, missing_doc_code_examples, unreachable_pub)]
use tok... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless ... |
// use crate::members;
use hdk::prelude::*;
pub fn get_admin_members() -> ZomeApiResult<Vec<Address>> {
let initial_members_json = hdk::property("initial_members")?;
let initial_members: Result<Vec<Address>, _> =
serde_json::from_str(&initial_members_json.to_string());
match initial_members {
... |
pub mod geometry;
pub mod parse;
pub mod render;
|
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Flash Memory Address"]
pub fma: FMA,
#[doc = "0x04 - Flash Memory Data"]
pub fmd: FMD,
#[doc = "0x08 - Flash Memory Control"]
pub fmc: FMC,
#[doc = "0x0c - Flash Controller Raw Interrupt Status"]
pub fcris: ... |
use crate::MessageType;
/// A method for obtaining the field ID a specified `MessageType` uses for its timestamp. Usually it's 253 but unfortunately not always.
pub fn get_message_timestamp_field(mt: MessageType) -> Option<usize> {
match mt {
MessageType::AccelerometerData => Some(253),
MessageType... |
use std::io;
use std::io::prelude::*;
use std::io::{BufRead, BufReader, BufWriter};
use std::net::TcpStream;
pub struct BufTcpStream {
pub input: BufReader<TcpStream>,
pub output: BufWriter<TcpStream>,
}
impl BufTcpStream {
pub fn new(stream: TcpStream) -> io::Result<Self> {
let input = BufReader:... |
use std::io;
use std::num::ParseIntError;
pub fn read_integer() -> Result<i32, ParseIntError> {
let mut input_text = String::new();
io::stdin().read_line(&mut input_text).expect("Failed to read from stdin.");
let trimmed = input_text.trim();
return trimmed.parse::<i32>();
}
|
use std::collections::HashMap;
fn evolve(prev_state: String, rules: &HashMap<String, char>) -> String {
let state = "....".to_owned() + &prev_state + "....";
let mut result = String::new();
for i in 2..(state.len() - 2) {
result.push(*rules.get(state[(i - 2)..(i + 3)].into()).unwrap_or(&'.'));
... |
pub trait Argmax {
type Maximum;
fn argmax(self) -> Option<(usize, Self::Maximum)>;
}
impl<I> Argmax for I
where
I: Iterator,
I::Item: std::cmp::PartialOrd,
{
type Maximum = I::Item;
fn argmax(mut self) -> Option<(usize, Self::Maximum)> {
let v0 = self.next()?;
Some(
... |
mod graph;
mod graph_traversal_algorithms;
pub use crate::{graph::DirectedLabelGraph, graph_traversal_algorithms::*}; |
use crate::{
Result,
backend::{Backend, ImageData, instance},
error::QuicksilverError,
file::load_file,
geom::{Rectangle, Transform, Vector},
};
use futures::{Future, future};
use std::{
error::Error,
fmt,
io::Error as IOError,
path::Path,
rc::Rc
};
///Pixel formats for use with... |
mod renderer;
pub use renderer::*;
pub use httpserver::*;
pub use database::*;
#[cfg(test)]
mod tests {
}
|
pub struct Math {}
impl Math {
pub fn clamp<T: PartialOrd>(v: T, min: T, max: T) -> T {
if v < min {
min
} else if v > max {
max
} else {
v
}
}
} |
extern crate inflector;
extern crate serde;
extern crate serde_yaml;
#[macro_use]
extern crate serde_derive;
extern crate try_from;
extern crate range;
extern crate rand;
#[macro_use]
extern crate lazy_static;
extern crate rustache;
// Keep the #[macro use] utils first
#[macro_use]
pub mod utils;
pub mod item;
pub mod... |
use crate::TimeTrackerError;
use std::convert::TryFrom;
use std::fmt;
use std::fmt::Display;
use std::fmt::Formatter;
#[derive(PartialEq, Debug)]
pub struct RawLog {
pub name: String,
pub timestamp: u64,
}
pub fn raw_logs_from(raw_data: &str) -> Result<Vec<RawLog>, TimeTrackerError> {
let mut raw_logs = v... |
use clap::{App, Arg};
use csvchk::{Config, MyResult};
// --------------------------------------------------
fn main() {
if let Err(err) = get_args().and_then(run) {
eprintln!("{}", err);
std::process::exit(1);
}
}
// --------------------------------------------------
pub fn get_args() -> MyRes... |
extern crate circular_buffer;
#[allow(unused_must_use)]
mod tests {
use circular_buffer::{CircularBuffer, Error};
#[test]
fn error_on_read_empty_buffer() {
let mut buffer = CircularBuffer::new(1);
assert_eq!(Err(Error::EmptyBuffer), buffer.read());
}
#[test]
#[ignore]
fn ... |
use md5::Digest;
fn zerohash(input: &str, zerocheck: impl Fn(&Digest) -> bool) -> i32 {
let mut num = 0;
let orig_len = input.len();
let mut hash_input = input.as_bytes().to_owned();
loop {
let _ = itoa::write(&mut hash_input, num);
let digest = md5::compute(&hash_input);
hash_i... |
use std::slice;
// Helper to forward slice-optimized iterator functions.
macro_rules! forward {
() => {
#[inline]
fn next(&mut self) -> Option<Self::Item> {
self.iter.next()
}
#[inline]
fn nth(&mut self, n: usize) -> Option<Self::Item> {
self.iter.nt... |
use std::io::BufRead;
#[derive(Debug)]
pub struct Tile(usize);
#[derive(Debug)]
pub struct Map {
pub width: u32,
pub height: u32,
tiles: Vec<Tile>,
}
impl Map {
pub fn get_tile(&self, x: u32, y: u32) -> Option<&Tile> {
self.tiles.get((y * self.width + x) as usize)
}
pub fn read<R: Bu... |
mod error;
use gstreamer::event::Step;
use gstreamer::format::Buffers;
use gstreamer::prelude::*;
use gstreamer::*;
use std::iter::Iterator;
/* Send seek event to change rate */
fn send_seek_event(pipeline: &Element, video_sink: &mut Option<Element>, rate: f64) {
/* Obtain the current position, needed for the see... |
#[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::NMIENSET {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... |
#![allow(dead_code)]
use chrono::{DateTime, Local};
use rand::{self, distributions::Uniform, Rng};
use crate::controller;
use crate::model_config::{self, Config};
use crate::model_gamemode::{self, BoardSaved, GameMode};
use crate::view::AlertFailure;
use crate::view::{self, ViewCommand};
use std::cell::Cell;
use std:... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
pub const ADMINDATA_MAX_NAME_LEN: u32 = 256u32;
pub const APPCTR_MD_ID_BEGIN_RESERVED: u32 = 57344u32;
pub const APPCTR_MD_ID_END_RESERVED: u32 = 61439u32;
pub const APPSTATUS_NOTDEFINED: u32... |
use super::ema::rma_func;
use super::VarResult;
use crate::ast::stat_expr_types::VarIndex;
use crate::ast::syntax_type::{FunctionType, FunctionTypes, SimpleSyntaxType, SyntaxType};
use crate::helper::{
ensure_srcs, float_abs, float_max, ge1_param_i64, move_element, pine_ref_to_bool,
pine_ref_to_f64, pine_ref_to... |
#[cfg_attr(rustfmt, rustfmt_skip)]
#[allow(nonstandard_style, non_upper_case_globals)]
pub mod atoms {
// During the build step, `build.rs` will output the generated atoms to `OUT_DIR` to avoid
// adding it to the source directory, so we just directly include the generated code here.
include!(concat!(env!("... |
use crate::context::RpcContext;
use crate::v04::types::TransactionWithHash;
crate::error::generate_rpc_error_subset!(PendingTransactionsError:);
pub async fn pending_transactions(
context: RpcContext,
) -> Result<Vec<TransactionWithHash>, PendingTransactionsError> {
let transactions = match context.pending_da... |
// Copyright 2016 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 ... |
extern crate math;
use math::round;
use std::vec::Vec;
// Sorts array a[0..n-1] by recursive mergesort
// Input: An array a[0..n-1] of orderable elements
// Output: Array a[0..n-1] sorted in nondecreasing order
fn mergesort(a: &mut Vec<u8>) {
let n = a.len();
if n > 1 {
let nh: usize = round::floor(n ... |
use diesel::mysql::MysqlConnection;
use hyper::{Body, Request, StatusCode, Chunk};
use futures::{future, Future, Stream};
use crate::types::response::*;
use crate::utils::{response::{create_response, create_error_message}, validator::parse_form};
use crate::consts::ErrorCode;
use crate::models::book::{Book, NewBook};
... |
extern crate cc;
fn main() {
cc::Build::new()
.file("src/unix/extern_seccomp.c")
.compile("seccomp");
cc::Build::new()
.file("src/unix/extern_open.c")
.compile("open");
}
|
use charter::chart::{HorizontalBarChart, BarData};
#[test]
fn plot_horizontal_bar_graph_internals() {
let mut hbc = HorizontalBarChart::new(false);
hbc.push(BarData("five".to_string(), 5));
hbc.push(BarData("nine".to_string(), 9));
hbc.push(BarData("three".to_string(), 3));
let plotted = hbc.plot_i... |
use std::collections::{HashMap, BTreeMap};
pub struct Version {
pub value: String,
pub dependencies: Vec<String>,
pub timestamp: i64,
}
pub struct Item {
versions: BTreeMap<i64, Version>,
current: i64
}
impl Item {
pub fn new() -> Item {
Item{ versions: BTreeMap::new(), current: 0 }
... |
use mav::{ChainType, WalletType, NetType};
pub trait Chain2WalletType {
fn chain_type(wallet_type: &WalletType,net_type:&NetType) -> ChainType;
/// 减少调用时把类型给错,而增加的方法,但不是每次都有实例,所以还保留了无 self的方法
//fn to_chain_type(&self, wallet_type: &WalletType) -> ChainType;
fn wallet_type(chain_type: &ChainType) -> Wa... |
use super::{types, util, Context};
use anyhow::{anyhow, Context as _, Result};
use ethers_core::abi::ParamType;
use ethers_core::{
abi::{Function, FunctionExt, Param, StateMutability},
types::Selector,
};
use inflector::Inflector;
use proc_macro2::{Literal, TokenStream};
use quote::quote;
use std::collections::... |
pub mod bitboard;
pub mod perceptron;
pub mod vec_math;
use {
bitboard::{Bitboard, ChessPiece},
perceptron::Perceptron,
rand,
};
fn main() {
bitboard_example();
perceptron_example();
}
fn bitboard_example() {
let mut bitboard = Bitboard::new();
let maybe_capture: Option<ChessPiece> = bitb... |
use std::collections::HashMap;
use std::hash::{Hash, Hasher};
use std::sync::{Arc, Mutex};
use std::cmp::Ordering;
use std::thread;
use std::usize;
use std::sync::mpsc;
#[derive(Debug, Clone, Copy)]
struct Pos {
no1: usize,
no2: usize,
}
impl PartialEq for Pos {
fn eq(&self, other: &Self) -> bool {
... |
//! Convert values to [`ArgReg`] and from [`RetReg`].
//!
//! System call arguments and return values are all communicated with inline
//! asm and FFI as `*mut Opaque`. To protect these raw pointers from escaping
//! or being accidentally misused as they travel through the code, we wrap
//! them in [`ArgReg`] and [`Ret... |
// https://mariadb.com/kb/en/library/resultset/#field-detail-flag
// https://dev.mysql.com/doc/dev/mysql-server/8.0.12/group__group__cs__column__definition__flags.html
bitflags::bitflags! {
pub struct FieldFlags: u16 {
/// Field cannot be NULL
const NOT_NULL = 1;
/// Field is **part of** a ... |
/*
* MIT License
*
* Copyright (c) 2018 Clément SIBILLE
*
* Permission is hereby Keycode::granted => Key::granted, free of Keycode::charge => Key::charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without Keycode::restriction => Key:... |
use std::convert::TryInto;
use std::io;
/// Read a u16 in little endian format from the beginning of the given slice.
/// This panics if the slice has length less than 2.
pub fn read_u16_le(slice: &[u8]) -> u16 {
u16::from_le_bytes(slice[..2].try_into().unwrap())
}
/// Read a u24 (returned as a u32 with the most ... |
use proconio::input;
macro_rules! chmax {
($a: expr, $b: expr) => {
$a = $a.max($b);
};
}
fn main() {
input! {
n: usize,
txa: [(usize, usize, i64); n],
};
let s = 1_000_00;
let mut bonus = vec![vec![0; 5]; s + 1];
for (t, x, a) in txa {
bonus[t][x] = a;
... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qdialog.h
// dst-file: /src/widgets/qdialog.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
/... |
// 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 ... |
use std::fmt::{Display, Formatter};
use std::fmt;
use crate::structs::dim::Dim;
use crate::structs::dim::Dim::Size;
use crate::structs::offset4::Offset4;
pub const NDIMS: usize = 4;
#[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)]
pub struct Shape4(Dim, Dim, Dim, Dim);
impl Shape4 {
pub fn vec4(x: usize,... |
use super::GameboyType;
use std::fmt;
use std::fmt::Debug;
use std::default::Default;
#[derive(Copy, Clone)]
pub enum Reg8 {
A,
F,
B,
C,
D,
E,
H,
L,
}
#[derive(Copy, Clone)]
pub enum Reg16 {
AF,
BC,
DE,
HL,
SP,
}
pub struct Registers {
pub a: u8,
pub b: u8,... |
use fileutil;
use std::collections::{HashMap, HashSet, BTreeSet};
use std::u32;
#[derive(Clone, Copy)]
struct Edge {
src: char,
dest: char
}
// Implementation of Kahn's algorithm for computing a topological sort.
fn kahns_algorithm(adj_orig: &HashMap<char, HashSet<char>>) -> Vec<char> {
let mut adj = adj_... |
use std::io;
use std::net::{TcpListener, TcpStream};
use std::sync::Arc;
use anyhow::Error;
use fehler::throws;
use log::{debug, info};
use threadpool::ThreadPool;
use crate::http_handler::{handle, Handler, Response};
#[throws]
fn handle_stream(stream: TcpStream, handler: Arc<impl Handler>) -> Response {
let mut... |
#[derive(Debug,Clone,Copy,PartialEq,Eq,PartialOrd,Ord,Hash)]
pub enum GoodEvil {
Evil,
Neutral,
Good,
}
impl GoodEvil {
pub fn opposite(self) -> Self {
use GoodEvil::*;
match self {
Evil => Good,
Good => Evil,
x => x,
}
}
}
#[derive(Debu... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
#[repr(C)]
pub struct GameControllerVersionInfo {
pub Major: u16,
pub Minor: u16,
pub Build: u16,
pub Revision: u16,
}
impl ::core::marker::Copy... |
use libc::stat;
use std::ffi::CStr;
use std::ffi::CString;
use std::os::raw::c_char;
use std::os::raw::c_int;
use std::cell::RefCell;
use std::fmt::Debug;
use std::path::Path;
use std::path::PathBuf;
use std::vec::Vec;
use crate::fs::constants::*;
use super::FileFinderTrait;
use crate::dir_entry::StandaloneDirEntry;... |
// Copyright (c) 2016 The Rouille developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be co... |
// Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
// SPDX-License-Identifier: MIT
use dialog::DialogBox;
fn main() -> dialog::Result<()> {
let input1 = dialog::Input::new("Please enter something").show()?;
let input2 = dialog::Input::new("Please enter something")
.title("Input form")
.... |
mod error_kind;
mod result;
pub use self::error_kind::ErrorKind;
pub use self::result::Result;
pub use failure::Error;
|
use std::ops::{Add, Sub, Neg, Mul};
use std::hash::{Hash, Hasher};
use utils::fpoint::FPoint;
use utils::irange::IRange;
use utils::point::Point;
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Error;
use std::fmt::Debug;
#[derive(Serialize, Deserialize, Clone, Copy)]
pub struct IPoint {
pub x: i32,
... |
//! Utilities for actor tests.
/// A pair of actors that send messages and increment message counters.
pub mod ping_pong {
use crate::actor::*;
use crate::*;
pub struct PingPongActor {
serve_to: Option<Id>,
}
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
pub enum PingPongMsg {
... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtWidgets/qlistwidget.h
// dst-file: /src/widgets/qlistwidget.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block be... |
use std::fmt;
use std::fmt::Debug;
use std::string::String;
use std::boxed::Box;
use super::mbc::Mbc;
use super::mbc::MbcType;
use super::mbc::RamInfo;
use super::mbc::MbcInfo;
use super::GameboyType;
pub struct Cart {
bytes: Box<[u8]>,
mbc: Box<Mbc>,
}
#[derive(Debug)]
pub enum DestinationCode {
Japanes... |
#![doc(html_root_url = "https://docs.rs/hyper/0.12.24")]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![cfg_attr(test, deny(warnings))]
#![cfg_attr(all(test, feature = "nightly"), feature(test))]
//! # hyper
//!
//! hyper is a **fast** and **correct** HTTP implementation written in and for Rust.
//!... |
use super::{
Entity, EntityShape, ResourceRegistry, RunSystemPhase, Service, ServicePhase, System,
SystemRunner,
};
use generational_arena::Arena;
use std::fmt;
pub struct ECS {
pub(crate) entities: Arena<Entity>,
systems: SystemRunner,
pub resources: ResourceRegistry,
}
impl fmt::Debug for ECS {
... |
use proconio::input;
fn main() {
input! {
_: usize,
s: String,
};
let t = s.replace("na", "nya");
println!("{}", t);
}
|
use failure::Error;
use std::io::BufRead;
// \r 13
// \n 10
fn find_new_line(data: &[u8]) -> Option<(usize, usize)> {
match memchr::memchr(b'\n', data) {
Some(i) => {
if i > 0 && data[i - 1] == b'\r' {
Some((i - 1, 2))
} else {
Some((i, 1))
... |
#[doc = "Reader of register TX_SINGLE_COLLISION_GOOD_PACKETS"]
pub type R = crate::R<u32, super::TX_SINGLE_COLLISION_GOOD_PACKETS>;
#[doc = "Reader of field `TXSNGLCOLG`"]
pub type TXSNGLCOLG_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - Tx Single Collision Good Packets"]
#[inline(always)]
pub fn tx... |
//game.rs
//game manager
use quicksilver::prelude::*;
pub mod game_map;
pub mod item_bag;
pub mod player;
pub mod store;
pub struct Game {
title: Asset<Image>,
pub map: game_map::Map,
pic: Asset<Image>,
tileset: Asset<std::collections::HashMap<char, Image>>,
pub player: player::Player, //vec playe... |
//! # Basic Sample
//!
//! This sample demonstrates how to create a toplevel `window`, set its title, size and position, how to add a `button` to this `window` and how to connect signals with actions.
#![crate_type = "bin"]
// Third party libraries used, every possible dependency should be defined in here
extern crat... |
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut dic = std::collections::HashMap::<i32, i32>::new();
for i in 0..nums.len() {
let v = nums[i];
let exp = target - v;
if let Some(ix) = dic.get(&exp) {
return vec![*ix,... |
use std::io::prelude::*;
use std::fs::File;
use std::env;
use std::io::BufReader;
use std::time::Instant;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 1 {
println!("No file specified.");
} else {
// let beginning = PreciseTime::now();
let beginning = Instant::now();
for a in 1... |
use gobble::*;
use std::collections::BTreeMap;
use std::io::Write;
fn p_int() -> impl Parser<i64> {
maybe(s_tag("-"))
.then(read_fs(is_num, 1))
.try_map(|(neg, ns)| {
let mut n = ns
.parse::<i64>()
.map_err(|_| ECode::SMess("Too long int"))?;
... |
use quote::quote;
use syn::{
parse::{Parse, ParseStream},
parse_macro_input,
spanned::Spanned,
Ident, Item, ItemImpl, ItemStruct, LitStr, Token,
};
struct Parsed {
items: Vec<Item>,
}
impl Parse for Parsed {
fn parse(input: ParseStream) -> syn::parse::Result<Self> {
let mut items = Vec... |
// Copyright 2019-2020 PolkaX. Licensed under MIT or Apache-2.0.
/// Type alias to use this library's [`BlockFormatError`] type in a `Result`.
pub type Result<T> = std::result::Result<T, BlockFormatError>;
/// Errors generated from this library.
#[derive(Debug, thiserror::Error)]
pub enum BlockFormatError {
/// T... |
#![recursion_limit = "1024"]
extern crate rss;
#[macro_use]
extern crate error_chain;
mod errors {
// Create the Error, ErrorKind, ResultExt, and Result types
error_chain!{}
}
error_chain!{
foreign_links {
Fmt(::std::fmt::Error);
Io(::std::io::Error) #[cfg(unix)];
//Reqwest(reqw... |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qlocale.h
// dst-file: /src/core/qlocale.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= m... |
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::fmt;
use std::time;
/// Summary statistics produced at the end of a search.
///
/// When statistics are reported by a printer, they correspond to all searches
/// executed with that printer.
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Se... |
// 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.
pub mod bitfields;
#[allow(missing_docs)]
pub mod block;
#[allow(missing_docs)]
pub mod block_type;
#[allow(missing_docs)]
pub mod constants;
|
use primes_iter;
pub fn new() -> PrimalityChecker {
PrimalityChecker::new()
}
pub struct PrimalityChecker {
pi: primes_iter::PrimesIter
}
impl PrimalityChecker {
pub fn new() -> PrimalityChecker {
PrimalityChecker {
pi: primes_iter::new()
}
}
pub fn is_prime(&mut self, num: u64) -> bool {
// Short-... |
/*
* Copyright 2020 Fluence Labs Limited
*
* 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... |
//! Exports the `Term` type which is a high-level API for the Grid.
use std::ops::{Index, IndexMut, Range};
use std::sync::Arc;
use std::{cmp, mem, ptr, slice, str};
use bitflags::bitflags;
use log::{debug, trace};
use unicode_width::UnicodeWidthChar;
use vte::ansi::{Hyperlink as VteHyperlink, Rgb as VteRgb};
use cr... |
use logos::Logos;
#[derive(Debug, Logos)]
enum Token<'a> {
#[regex("[a-zA-Z_][a-zA-Z0-9_]*")]
Ident(&'a str),
#[regex(r#""(?:\\"|[^"])*""#)]
InterpolatedString(&'a str),
#[regex(r#"'[^']*'"#)]
RawString(&'a str),
#[regex(r"\$\w+")]
DollarVariable(&'a str),
#[token("$")]
Doll... |
// Copyright (c) 2020 Sam Blenny
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
/// Panic Handler for no_std.
use core::panic::PanicInfo;
#[panic_handler]
pub fn panic(_panic_info: &PanicInfo) -> ! {
unsafe {
core::arch::wasm32::unreachable();
}
}
|
use std::{error::Error, fmt};
#[derive(Debug)]
pub enum NaiaServerError {
Wrapped(Box<dyn Error>),
}
impl fmt::Display for NaiaServerError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match self {
NaiaServerError::Wrapped(boxed_err) => fmt::Display::fmt(boxed_err.as_... |
#[doc = "Reader of register TXDLADDR"]
pub type R = crate::R<u32, super::TXDLADDR>;
#[doc = "Writer for register TXDLADDR"]
pub type W = crate::W<u32, super::TXDLADDR>;
#[doc = "Register TXDLADDR `reset()`'s with value 0"]
impl crate::ResetValue for super::TXDLADDR {
type Type = u32;
#[inline(always)]
fn re... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
pub type DXGI_ALPHA_MODE = u32;
pub const DXGI_ALPHA_MODE_UNSPECIFIED: DXGI_ALPHA_MODE = 0u32;
pub const DXGI_ALPHA_MODE_PREMULTIPLIED: DXGI_ALPHA_MODE = 1u32;
... |
#[doc = "Reader of register IMR2"]
pub type R = crate::R<u32, super::IMR2>;
#[doc = "Writer for register IMR2"]
pub type W = crate::W<u32, super::IMR2>;
#[doc = "Register IMR2 `reset()`'s with value 0xffff_ff87"]
impl crate::ResetValue for super::IMR2 {
type Type = u32;
#[inline(always)]
fn reset_value() ->... |
//! linux_raw syscalls supporting `rustix::pipe`.
//!
//! # Safety
//!
//! See the `rustix::backend` module documentation for details.
#![allow(unsafe_code)]
#![allow(clippy::undocumented_unsafe_blocks)]
use crate::backend::conv::{c_int, c_uint, opt_mut, pass_usize, ret, ret_usize, slice};
use crate::backend::{c, MAX_... |
#[doc = "Reader of register ITLINE12"]
pub type R = crate::R<u32, super::ITLINE12>;
#[doc = "Reader of field `ADC`"]
pub type ADC_R = crate::R<bool, bool>;
#[doc = "Reader of field `COMP1`"]
pub type COMP1_R = crate::R<bool, bool>;
#[doc = "Reader of field `COMP2`"]
pub type COMP2_R = crate::R<bool, bool>;
impl R {
... |
#![feature(asm, lang_items)]
#![crate_type="staticlib"]
#![no_std]
const GPFSEL3: u32 = 0x3F20_000C;
const GPFSEL4: u32 = 0x3F20_0010;
const GPSET1: u32 = 0x3F20_0020;
const GPCLR1: u32 = 0x3F20_002C;
const GPIO35: u32 = 1 << (35 - 32);
const GPIO47: u32 = 1 << (47 - 32);
extern {
fn dummy();
}
fn sleep(times: ... |
use std::env;
use std::io::{self, Write, StderrLock};
use std::process::{Command, exit};
use std::thread::{self, JoinHandle};
use std::sync::{Arc, Mutex};
/* TODO: Functionality can be increased to accept the following syntaxes from GNU Parallel:
- Stdin support is currently missing.
- Use a tokenizer for building c... |
#[cfg(x86_64)]
use std::arch::x86_64;
use std::ffi::CString;
use std::ptr;
use sys::*;
pub struct Device {
pub(crate) handle: RTCDevice,
}
impl Device {
pub fn new() -> Device {
// Set the flush zero and denormals modes from Embrees's perf. recommendations
// https://embree.github.io/api.html... |
use std::collections::{HashMap, HashSet};
use std::io::Write;
use crate::client::{CharacterRecipes, Client, Item, ItemId, Recipe, RecipeId, Listings};
use crate::error::Result;
pub struct Index {
pub recipes: HashMap<RecipeId, Recipe>,
pub recipes_by_item: HashMap<ItemId, Recipe>,
pub items: HashMap<ItemI... |
//! Provides methods for controlling process,
//! and gathering resource usages.
//!
use super::{result::*, util::*};
use sigar_sys::*;
/// Returns pid for current process
pub fn current_pid() -> SigarResult<u32> {
ffi_wrap_sigar_t!((|ptr_t| unsafe { sigar_pid_get(ptr_t) as u32 }))
}
// C: sigar_proc_kill
/// Ki... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(feature = "Win32_Security_AppLocker")]
pub mod AppLocker;
#[cfg(feature = "Win32_Security_Authentication")]
pub mod Authentication;
#[cfg(feature = "Win32_Security_Authorization")]
pub ... |
#![allow(unused)]
#![allow(unused_imports)]
#![allow(dead_code)]
pub mod reverse_resolver;
pub mod service;
pub mod upsert_util;
pub mod upserter;
|
use super::{PositionIterInternal, PyGenericAlias, PyStrRef, PyType, PyTypeRef};
use crate::common::{hash::PyHash, lock::PyMutex};
use crate::object::{Traverse, TraverseFn};
use crate::{
atomic_func,
class::PyClassImpl,
convert::{ToPyObject, TransmuteFromObject},
function::{ArgSize, OptionalArg, PyArithm... |
#[cfg(feature = "Win32_Foundation")]
::windows_targets::link ! ( "advapi32.dll""system" #[doc = "*Required features: `\"Win32_System_EventLog\"`, `\"Win32_Foundation\"`*"] fn BackupEventLogA ( heventlog : EventLogHandle , lpbackupfilename : ::windows_sys::core::PCSTR ) -> super::super::Foundation:: BOOL );
#[cfg(featur... |
// 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 ... |
#![allow(unused_imports)]
// Import everything from libc, but we'll add some stuff and override some
// things below.
pub(crate) use libc::*;
/// `PROC_SUPER_MAGIC`—The magic number for the procfs filesystem.
#[cfg(all(linux_kernel, target_env = "musl"))]
pub(crate) const PROC_SUPER_MAGIC: u32 = 0x0000_9fa0;
/// `NF... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.