text stringlengths 8 4.13M |
|---|
//! Rigid bodies.
pub use object::rigid_body::{RigidBody, Static, Dynamic, Deleted, Active, Inactive};
mod rigid_body;
|
// http://chrismorgan.info/blog/rust-ownership-the-hard-way.html
extern crate type_printer;
mod rule_1;
mod rule_2;
mod rule_3;
mod rule_4;
pub fn the_hard_way() {
rule_1::experiments();
rule_2::experiments();
rule_3::experiments();
rule_4::experiments();
}
|
use std::convert::{TryFrom, TryInto};
use anyhow::Result;
use super::ast::{Expr, Identifier, Node, Pair, Stmt};
pub fn modify<F>(node: Node, modifier: F) -> Result<Node>
where
F: Fn(Node) -> Result<Node> + Copy,
{
let node: Node = match node {
Node::Program(mut program) => {
program.state... |
use airhobot::*;
use cv::prelude::*;
use env_logger::{Builder, Env};
use log::*;
use std::{env, error, time::Duration, thread};
use structopt::StructOpt;
use airhobot::prelude::*;
mod args;
#[derive(Debug, Copy, Clone, PartialEq)]
enum Mode {
Play,
Pause,
PickColor,
}
fn main() -> Result<()> {
let ar... |
// The following was originally taken and adapated from exa source
// repo: https://github.com/ogham/exa
// commit: b9eb364823d0d4f9085eb220233c704a13d0f611
// license: MIT - Copyright (c) 2014 Benjamin Sago
//! System calls for getting the terminal size.
//!
//! Getting the terminal size is performed using an ioctl c... |
/*
* Slack Web API
*
* One way to interact with the Slack platform is its HTTP RPC-based Web API, a collection of methods requiring OAuth 2.0-based user, bot, or workspace tokens blessed with related OAuth scopes.
*
* The version of the OpenAPI document: 1.7.0
*
* Generated by: https://openapi-generator.tech
*... |
//! The module contains a [`PeekableGrid`] structure.
use core::borrow::Borrow;
use std::{
borrow::Cow,
cmp,
fmt::{self, Write},
};
use crate::{
color::{AnsiColor, Color},
colors::Colors,
config::spanned::{Formatting, Offset, SpannedConfig},
config::{AlignmentHorizontal, AlignmentVertical,... |
use std::error::Error as StdError;
use std::io::Error as IoError;
use serde_json::error::Error as SerdeError;
use std::fmt;
// ------------------------------------------------------------------------------
// Crate Error/Result
// ------------------------------------------------------------------------------
pub ty... |
use quote::{quote_spanned, ToTokens};
use syn::parse_quote;
use super::{
FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, OperatorWriteOutput,
Persistence, WriteContextArgs, RANGE_1,
};
use crate::diagnostic::{Diagnostic, Level};
use crate::graph::{OpInstGenerics, OperatorInstance};
///... |
use std::{
fmt::Debug,
future::Future,
pin::Pin,
task::{Context, Poll},
};
use tracing::Span;
pin_project_lite::pin_project! {
#[derive(Debug, Clone)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct InstrumentedErr<F> {
#[pin]
fut: F,
s... |
use kay::{
ActorSystem,
Networking,
Tuning,
// TypedID
};
use std::{thread::sleep, time::Duration};
use lib::actor::{setup, CounterActorID};
fn main() {
let mut system = ActorSystem::new(
Networking::new(
0,
vec!["localhost:9999".to_owned(), "wsclient".to_owned()],... |
// fn fetch64(input:&[u8]) -> u64 {
// u32::from_le_bytes([input[0], input[1], input[2], input[3], input[4], input[5], input[6], input[7]])
// }
// fn fetch32(input:&[u8]) -> u32 {
// u32::from_le_bytes([input[0], input[1], input[2], input[3]])
// }
// fn fetch8(input:&[u8]) -> u8 {
// input[0]
// }
mod xx_hasher_3... |
use std::fmt;
use std::iter::FromIterator;
use std::ops::{Add, Div, Mul, Sub};
use Result;
use num_traits::cast::ToPrimitive;
use num_traits::CheckedDiv;
use DataType;
use Tensor;
/// Partial information about any value.
pub trait Fact: fmt::Debug + Clone + PartialEq + Default {
type Concrete;
/// Tries to ... |
extern crate embed_lang;
use embed_lang::new_vm;
use embed_lang::vm::api::Pushable;
fn f(_: &'static str) { }
fn main() {
let vm = new_vm();
let f: fn (_) = f;
vm.define_global("test", f);
//~^ Error `vm` does not live long enough
}
|
pub const CARRY: u8 = 0b0001_0000;
pub const HALF_CARRY: u8 = 0b0010_0000;
pub const SUB: u8 = 0b0100_0000;
pub const ZERO: u8 = 0b1000_0000;
|
extern crate term;
use std::net::{ TcpListener, Shutdown };
use std::io::{ Read, Write };
fn main() {
let listener = TcpListener::bind("127.0.0.1:8888")
.expect("not bound");
let mut t = term::stdout().unwrap();
println!("127.0.0.1:8888 running");
for stream in listener... |
use crate::common::{Annot, Loc};
use std::error::Error as StdError;
use std::fmt;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum LexErrorKind {
InvalidChar(char),
Eof,
}
pub type LexError = Annot<LexErrorKind>;
impl LexError {
pub fn invalid_char(c: char, loc: Loc) -> Self {
Self::new(LexE... |
use actix_files as fs;
use actix_web::{
App, HttpServer, middleware,
};
use objc::{self, msg_send, sel, sel_impl};
use serde::Deserialize;
use serde_json;
use web_view;
use std::env;
use key::Modifier;
mod menu;
mod key;
fn main() {
// Serve todomvc example from https://github.com/DenisKolodin/yew/tree/ma... |
use std::io::prelude::*;
use std::rc::Rc;
use std::cell::RefCell;
type P<T> = Rc<RefCell<T>>;
fn P<T>(val: T) -> P<T> {
return Rc::new(RefCell::new(val));
}
#[derive(Debug, Clone)]
enum Cell {
Rock,
Empty,
Gold(u8),
Player(P<Player>),
Emu(P<Emu>),
Wall,
}
impl Cell {
fn is_player(&sel... |
pub struct Hash;
|
use super::{Context, Module, RootModuleConfig};
use crate::configs::elixir::ElixirConfig;
use crate::formatter::StringFormatter;
use crate::utils;
use regex::Regex;
const ELIXIR_VERSION_PATTERN: &str = "\
Erlang/OTP (?P<otp>\\d+)[^\\n]+
Elixir (?P<elixir>\\d[.\\d]+).*";
/// Create a module with the current Elixir v... |
// Copyright (c) 2019 - 2020 ESRLabs
//
// 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 ... |
// Copyright 2014 The Gfx-rs 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 ag... |
use indoc::formatdoc;
use libherokubuildpack::log::log_error;
use crate::CorepackBuildpackError;
pub(crate) fn on_error(err: libcnb::Error<CorepackBuildpackError>) {
match err {
libcnb::Error::BuildpackError(bp_err) => on_buildpack_error(bp_err),
libcnb_err => log_error(
"heroku/nodejs... |
mod multi_store;
mod tso;
mod types;
pub use multi_store::MultiStore;
pub use tso::TimestampOracle;
pub use types::{Column, DataValue, Key, LockValue, WriteValue};
|
use std::collections::HashMap;
// NB This was really slow
// I got my answer
// I tried to make it quicker
// It was even slower
// I might improve it further in the futureS
fn main() {
let list: Vec<&str> = include_str!("input.txt").lines().collect();
let mut g = Graph::from(list);
let p = g.get_paths();... |
use std::io;
use byteorder::{BigEndian, LittleEndian, ReadBytesExt, WriteBytesExt};
use crate::Deen;
macro_rules! deen_integer {
($name:ident, $type:ty, $wr:ident, $rd:ident, $endian:ident) => {
#[derive(Clone, Copy, Debug)]
pub struct $name;
impl Deen for $name {
type Item =... |
use std::f64;
use std::f64::NAN;
// rewritten 'as-is' from Go package github.com/asmarques/geodist
// https://github.com/asmarques/geodist/blob/master/vincenty.go
fn vincenty_distance(lat1: f64, lon1: f64, lat2: f64, lon2: f64) -> f64 {
let a: f64 = 6378137.0;
let f: f64 = 1.0/298.257223563;
let b: f64 = 6356752.3... |
use quote::quote_spanned;
use super::{
DelayType, FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints,
OperatorWriteOutput, Persistence, WriteContextArgs, RANGE_0, RANGE_1,
};
use crate::diagnostic::{Diagnostic, Level};
use crate::graph::{OpInstGenerics, OperatorInstance};
/// > 1 input str... |
use crate::util::{lines_from_file, strings_to_i32};
pub fn day1() {
println!("== Day 1 ==");
let input = strings_to_i32(lines_from_file("src/day1/input.txt"));
let a = part_a(&input);
println!("Part A: {}", a);
let b = part_b(&input);
println!("Part B: {}", b);
}
fn part_a(input: &Vec<i32>) -... |
use crate::gc::Gc;
use crate::rerrs::{ErrorKind, SteelErr};
use crate::rvals::SteelVal::*;
use crate::rvals::{Result, SteelVal};
use crate::stop;
use im_rc::Vector;
pub struct VectorOperations {}
impl VectorOperations {
pub fn vec_construct() -> SteelVal {
SteelVal::FuncV(|args: &[SteelVal]| -> Result<Stee... |
#![allow(dead_code)]
#![allow(unused_imports)]
#![allow(unused_variables)]
extern crate rand;
extern crate phrases;
mod sh;
mod ds;
mod array;
mod strings;
mod pm;
mod fns;
mod closures;
mod traits;
use phrases::greetings::french;
fn main() {
// let btw = 1 | 2;
// println!("Pi is {}", std::f64::consts::PI... |
#[doc = "Reader of register FC0_STATUS"]
pub type R = crate::R<u32, super::FC0_STATUS>;
#[doc = "Reader of field `DIED`"]
pub type DIED_R = crate::R<bool, bool>;
#[doc = "Reader of field `FAST`"]
pub type FAST_R = crate::R<bool, bool>;
#[doc = "Reader of field `SLOW`"]
pub type SLOW_R = crate::R<bool, bool>;
#[doc = "R... |
use serde::{Deserialize, Serialize};
use sqlx::FromRow;
#[derive(Serialize, Deserialize)]
pub struct TodoInsert {
pub user_id: uuid::Uuid,
pub cat_id: uuid::Uuid,
pub title: String,
pub description: String,
}
#[derive(Serialize, FromRow)]
pub struct Todo {
pub id: uuid::Uuid,
pub user_id: uuid... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2
use jsonrpc_derive::rpc;
pub use self::gen_client::Client as WalletClient;
use crate::FutureResult;
use starcoin_types::account_address::AccountAddress;
use starcoin_types::transaction::{RawUserTransaction, SignedUserTransaction};
us... |
extern crate irc;
use std::collections::HashMap;
use std::io;
pub struct ExampleClient {
karma: HashMap<String, i32>,
}
impl ExampleClient {
pub fn new () -> ExampleClient {
ExampleClient { karma: HashMap::new() }
}
}
impl irc::ClientCallbacks for ExampleClient {
fn on_rpl_welcome (&mut self... |
pub fn getcwd(buf: u64, size: u64) -> u64 {
let buf = buf as usize;
let size = size as usize;
println!("Syscall: getcwd buf={:x} size={:x}", buf, size);
::mem::copy_str_safe(buf, "/", size);
buf as u64
}
|
use card;
use std::fmt;
#[derive(Debug, Clone)]
pub struct Table {
cards_on_table: usize,
pub cards: [Option<card::Card>; 5],
}
impl Table {
pub fn new() -> Table {
Table {
cards_on_table: 0,
cards: [None, None, None, None, None],
}
}
pub fn add_card(&mut self, card: ca... |
fn main() {
println!("Main(): Hello!");
function(42);
another_function(123, String::from("duck"));
//An expression (no semi-colon)
let x = {
let y = 4;
y + 3
};
println!("The value of x is: {}", x);
//Return from function
let x = get_five();
println!("The new ... |
#[doc = "Reader of register HOST_EP2_RW1_DR"]
pub type R = crate::R<u32, super::HOST_EP2_RW1_DR>;
#[doc = "Writer for register HOST_EP2_RW1_DR"]
pub type W = crate::W<u32, super::HOST_EP2_RW1_DR>;
#[doc = "Register HOST_EP2_RW1_DR `reset()`'s with value 0"]
impl crate::ResetValue for super::HOST_EP2_RW1_DR {
type T... |
#[doc = "Register `DLYB_CR` reader"]
pub type R = crate::R<DLYB_CR_SPEC>;
#[doc = "Register `DLYB_CR` writer"]
pub type W = crate::W<DLYB_CR_SPEC>;
#[doc = "Field `DEN` reader - DEN"]
pub type DEN_R = crate::BitReader;
#[doc = "Field `DEN` writer - DEN"]
pub type DEN_W<'a, REG, const O: u8> = crate::BitWriter<'a, REG, ... |
use std::mem;
pub fn lower_bound<T: Ord>(slice: &[T], value: &T) -> usize {
let mut s = slice;
while !s.is_empty() {
let mid = s.len() / 2;
s = if &s[mid] < value {
&s[mid + 1..]
} else {
&s[..mid]
};
}
(s.as_ptr() as usize - slice.as_ptr() as usi... |
use hacspec_lib::*;
pub enum Baz {
CaseX,
CaseY(Result<u8, U8>),
}
pub enum Foo {
CaseX(Baz),
CaseY(u8, Seq<u32>),
}
pub struct Bar(pub u32);
pub fn baz(x: Foo) -> Bar {
let z: Bar = Bar(0u32);
let Bar(z) = z;
let y = match x {
Foo::CaseX(Baz::CaseY(Result::<u8, U8>::Ok(x))) => {... |
//! Core functionality for Netherrack
//!
//! Will be expanded dramatically in the future
pub mod logger;
|
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::{Document};
type Result<T> = std::result::Result<T, JsValue>;
pub fn set_panic_hook() {
// When the `console_error_panic_hook` feature is enabled, we can call the
// `set_panic_hook` function at least once during initialization, and then
... |
#![feature(test)]
extern crate test;
use roc_dec::RocDec;
use std::convert::TryInto;
use test::{black_box, Bencher};
#[bench]
fn dec_sub1(bench: &mut Bencher) {
let dec1: RocDec = "1.2".try_into().unwrap();
let dec2: RocDec = "3.4".try_into().unwrap();
bench.iter(|| {
black_box(dec1 - dec2);
... |
use common::console_utils::Timer;
use wasm_bindgen::prelude::*;
use web_sys::console;
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
const WIDTH: usize = 25;
const HEIGHT: usize = 6;
/// See: https://adventofcode.com/2019/day/8
#[wasm_bindgen]
pub fn part1(input: &str) -> Result<u... |
fn find_substr(input: &[u8]) -> &[u8] {
println!("{}", ::std::str::from_utf8(input).unwrap());
if input.len() < 1 {
return input;
}
let mut infos = vec![None; 26];
let mut cur = 0;
while input.len() > cur {
let index = (input[cur] - b'a') as usize;
if let Some(prev) = ... |
/// A phone contact.
#[derive(Debug,Deserialize)]
pub struct Contact {
/// The contact's phone number.
pub phone_number: String,
/// The contact's first name.
pub first_name: String,
/// The contact's last name.
pub last_name: Option<String>,
/// The contact's user identifier on Telegram.
... |
use std::convert::TryInto;
use std::str::FromStr;
use hex::FromHex;
use neon::prelude::{FunctionContext, JsNumber, JsObject, JsResult, JsString};
use uuid::Uuid;
use access::{VaultConfig, WrappedVault};
use emerald_vault::{
Address,
align_bytes,
to_arr,
to_even_str,
to_u64,
Transaction,
tr... |
//! Counter with [Mutex<T>]
//!
//! [mutex<t>]: https://doc.rust-lang.org/book/ch16-03-shared-state.html
use std::sync::Arc;
use std::thread::{self, Result};
use the_book::ch16::sec03::Counter;
fn main() -> Result<()> {
let mut handlers = Vec::with_capacity(100_000);
let counter = Arc::new(Counter::new(100u12... |
use crate::error::{NiaServerError, NiaServerResult};
use crate::protocol::Serializable;
use nia_protocol_rust::StartListeningRequest;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct NiaStartListeningRequest {}
impl NiaStartListeningRequest {
pub fn new() -> NiaStartListeningRequest {
NiaStartListeningR... |
use std::collections::HashMap;
pub fn run() {
let mut ferry = FerrySeats::from(include_str!("input.txt"));
while !ferry.stable {
ferry.next();
}
println!("Day11 - Part 1: {}", ferry.taken());
let mut ferry = FerrySeats::with_visability_from(include_str!("input.txt"));
while !ferry.s... |
use crate::{
config::Config, db::app_user::AppUser, model::auth::LoginError, model::auth::RegisterError,
util::random_string, util::validate_email,
};
use async_trait::async_trait;
use jwt::{DecodingKey, EncodingKey, Header, Validation};
use serde::{Deserialize, Serialize};
use slog::{error, Logger};
use sqlx::... |
use crate::prelude::*;
use azure_core::Request as HttpRequest;
#[derive(Debug, Clone, Default)]
pub struct GetUserOptions {
consistency_level: Option<ConsistencyLevel>,
}
impl GetUserOptions {
pub fn new() -> Self {
Self {
consistency_level: None,
}
}
setters! {
co... |
use super::{api_framework::ApiFramework, creative_subtype};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct Video {
mime: Vec<String>,
api: Vec<ApiFramework>,
ctype: Option<creative_subtype::Video>,
dur: Option<i32>,
adm: Option<String>,
curl:... |
struct Solution;
impl Solution {
pub fn can_visit_all_rooms(rooms: Vec<Vec<i32>>) -> bool {
let mut visited = vec![false; rooms.len()];
let mut visited_count = 0;
Self::dfs(&rooms, 0, &mut visited, &mut visited_count);
visited_count == rooms.len()
}
fn dfs(rooms: &Vec<Vec<i3... |
extern crate cursive;
use cursive::Cursive;
#[cfg(feature = "markdown")]
use cursive::utils::markup::MarkdownText;
use cursive::views::{Dialog, TextView};
// Make sure you compile with the `markdown` feature!
//
// cargo run --example markup --features markdown
fn main() {
let mut siv = Cursive::new();
#[cf... |
pub(crate) mod r_pos;
pub(crate) mod schema_index;
pub(crate) mod schema_name;
use std::collections::HashSet;
use crate::{ApllodbError, ApllodbResult, RPos};
use self::{schema_index::SchemaIndex, schema_name::SchemaName};
/// Schema defines structure of records / rows.
///
/// Main purpose of schema is to resolve f... |
#[doc = "Register `ETH_MACL3A11R` reader"]
pub type R = crate::R<ETH_MACL3A11R_SPEC>;
#[doc = "Register `ETH_MACL3A11R` writer"]
pub type W = crate::W<ETH_MACL3A11R_SPEC>;
#[doc = "Field `L3A11` reader - L3A11"]
pub type L3A11_R = crate::FieldReader<u32>;
#[doc = "Field `L3A11` writer - L3A11"]
pub type L3A11_W<'a, REG... |
use super::memory;
use crate::microvm::memory::address::AddressType;
pub struct MMU<Address: AddressType> {
space: memory::sparse::SparseAddressSpace<Address>
} |
use std::iter::FromIterator;
use std::ops::Deref;
use abin::{AnyBin, AnyStr, Bin, BinFactory, NewBin, NewStr, Str, StrFactory};
#[test]
fn usage_basics() {
// static binary / static string
let static_bin: Bin = NewBin::from_static("I'm a static binary, hello!".as_bytes());
let static_str: Str = NewStr::fr... |
use cocoa::base::{id, nil};
use cocoa::foundation::{NSString, NSUInteger};
use core_foundation::base::TCFType;
use core_foundation::number::CFNumber;
use core_foundation::string::CFString;
use objc::runtime::BOOL;
use objc_bringup::NSDictionary;
use std::collections::HashMap;
use std::convert::{From, Into};
use std::de... |
use std::cell::{Ref, RefCell};
use chiropterm::{Brush, CellSize};
use euclid::{rect, size2};
use smallvec::SmallVec;
use crate::{InternalWidgetDimensions, UI, Widget, WidgetMenu, Widgetlike, widget::{AnyWidget, LayoutHacks}};
// Smallvec size -- set this to "higher than most users will ever put in one column/row"
co... |
// Crate Dependencies ---------------------------------------------------------
// ----------------------------------------------------------------------------
extern crate cursive;
extern crate cursive_table_view;
//extern crate rand;
// STD Dependencies -----------------------------------------------------------
// ... |
use std::fmt::Display;
use once_cell::sync::Lazy;
use serde::{Deserialize, Deserializer};
use std::sync::Mutex;
use tracing::instrument;
use crate::errors::TaxRankParsingError;
static LAST_TAXONOMY_RANK_PARSED: Lazy<Mutex<Option<Rank>>> = Lazy::new(|| Mutex::new(None));
/// Taxonomy levels
///
/// the u32 offset re... |
use spell_selection::SpellSelectionWindow;
use flag_selection::FlagSelectionWindow;
use building_selection::BuildingSelectionWindow;
use color_selection_window::ColorSelectionWindow;
use sdl2;
use EventState;
use ImageLoader;
use ted_interface::*;
use std::sync::mpsc::*;
use *;
const WINDOW_SPRITE: u32=0;
pub struct Wi... |
#[doc(inline)]
pub use crate::list::{ActionDetail, ListIndex, SelectedDetail};
use crate::text_inputs::{
validity_state::ValidityStateJS, NativeValidityState, ValidityState, ValidityTransform,
};
use crate::utils::WeakComponentLink;
use crate::{bool_to_option, event_into_details, to_option_string};
use gloo::event... |
extern crate std;
use super::super::prelude::{
wapi ,
Application , Text , Cursor
};
/**
LoadCursor
**/
pub fn loadCursor(app : Option<Application> , name : Text) -> Cursor {
unsafe {
wapi::Cursor::LoadCursorW(app.unwrap_or(std::ptr::mut_null()) , name)
}
}
/**
LoadCursor
**/
pub fn load(name :Text) -> Curs... |
use std::cmp::Ordering;
use std::collections::HashSet;
use std::error::Error;
use std::fmt;
use std::io::{self, Read};
use std::mem;
use std::result;
use std::usize;
type Result<T> = result::Result<T, Box<Error>>;
enum Track {
Empty,
Vertical,
Horizontal,
Intersection,
CurveSlash,
CurveBacksla... |
/*
* 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
*/
/// UserListResponse : Array of Datadog users for a given organization.
#[derive(Clone, Debug, Partia... |
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
use crate::{js_object::JsObject, random_id::U128Id, resource::ResourceId};
use async_trait::async_trait;
use downcast_rs::{impl_downcast, Downcast};
use futures::future::join_all;
use js_sys::Date;
use std::{
cell::RefCell,
collections::{HashMap, HashSet},
hash::Hash,
iter::Iterator,
ops::{Deref, De... |
#![warn(missing_docs)]
#![allow(unknown_lints, while_let_on_iterator)]
//! Library for serializing the RSS web content syndication format.
//!
//! # Reading
//!
//! A channel can be read from any object that implements the `BufRead` trait.
//!
//! ## Example
//!
//! ```rust,no_run
//! use std::fs::File;
//! use std::i... |
/*!
# Number As
**Use** the trait `NumberAs` in the current scope to let all primitive number types have a `number_as` method.
```rust
use number_as::NumberAs;
let a: i32 = 2u16.number_as();
assert_eq!(2i32, a);
assert_eq!(2i32, 2u16.number_as());
assert_eq!(20i32, 20.6.number_as());
```
All implements for the `... |
#[cfg(test)]
pub mod test {
use super::*;
#[test]
fn test() {}
}
|
use std::collections::HashMap;
use crate::palette::Palette;
use crate::lcd::LCD;
const VIEWPORT_WIDTH: usize = 160;
const VIEWPORT_HEIGHT: usize = 144;
const SCREEN_WIDTH_IN_TILES: usize = 32;
const VRAM_SIZE: usize = 0x2000;
const VRAM_START_ADDR: usize = 0x8000;
const BG_TILEMAP_SZ: usize = 0x400;
const BG_TILEDAT... |
use std::ffi::CStr;
use std::fmt;
use std::marker::PhantomData;
use std::os::raw::{c_int, c_uchar, c_void};
use std::ptr;
use std::slice;
use itertools::Itertools;
use crate::error::{Error, Result};
use crate::panic;
/// The result of a successful MX lookup.
#[derive(Debug)]
pub struct MXResults {
mx_reply: *mut... |
use crate::domain::content_manager::ContentManagerId;
#[derive(Debug, Clone)]
pub enum Status {
Draft,
WaitingApproval,
Published { admin_id: ContentManagerId },
Rejected { admin_id: ContentManagerId },
}
impl ToString for Status {
fn to_string(&self) -> String {
match self {
S... |
use std::env;
use std::fs;
use std::io;
use std::time;
fn main() -> io::Result<()> {
// clean files before 14 days
let lifetime = 60 * 60 * 24 * 14;
let entries = fs::read_dir(env::var("FILE_BASE_PATH").unwrap_or("files".to_string()))?;
for entry in entries {
if let Ok(entry) = entry {
... |
use serde::{Deserialize, Serialize};
pub trait EntityFields {
type Fields;
}
#[derive(Clone, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(untagged)]
pub enum FieldsOrStr<Fields> {
Fields(Fields),
String(String),
}
|
/// An enum to represent all characters in the TaiXuanJingSymbols block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum TaiXuanJingSymbols {
/// \u{1d300}: '𝌀'
MonogramForEarth,
/// \u{1d301}: '𝌁'
DigramForHeavenlyEarth,
/// \u{1d302}: '𝌂'
DigramForHumanEarth,
/// \u{1d303}:... |
use std::fs::File;
use std::path::PathBuf;
use structopt::StructOpt;
use serde_xml_rs::from_reader;
use std::error::Error;
use std::io::Write;
mod resource;
use resource::Resource;
mod kdg;
use kdg::build_model;
#[derive(Debug, StructOpt)]
#[structopt(
name = "Project 2 - Solving Hard Compiler Problems",
a... |
#[doc = "Reader of register MT_DELAY_CFG"]
pub type R = crate::R<u32, super::MT_DELAY_CFG>;
#[doc = "Writer for register MT_DELAY_CFG"]
pub type W = crate::W<u32, super::MT_DELAY_CFG>;
#[doc = "Register MT_DELAY_CFG `reset()`'s with value 0"]
impl crate::ResetValue for super::MT_DELAY_CFG {
type Type = u32;
#[i... |
use std::fmt;
use std::collections::BTreeMap;
use config::Value;
pub fn parse_simple_toml_value(string: &str) -> Result<Value, &'static str> {
if string.is_empty() {
return Err("value is empty")
}
let value = if let Ok(int) = string.parse::<i64>() {
Value::Integer(int)
} else if let ... |
// Added as part the code review and testing
// by ChainSafe Systems Aug 2021
use super::*;
use frame_benchmarking::{benchmarks, account, impl_benchmark_test_suite};
use frame_system::RawOrigin;
use frame_support::dispatch::UnfilteredDispatchable;
use sp_runtime::traits::Bounded;
const SEED: u32 = 0;
const TEST_DE... |
use crate::ast;
use crate::{Parse, ParseError, Parser, Peek, Spanned, ToTokens};
/// A return statement `break [expr]`.
#[derive(Debug, Clone, ToTokens, Parse, Spanned)]
pub struct ExprBreak {
/// The return token.
pub break_: ast::Break,
/// An optional expression to break with.
#[rune(iter)]
pub ... |
use std::fs;
use std::path::Path;
use std::io::Write;
pub struct Theme {
name: String,
css: String
}
impl Theme {
pub fn default() -> Result<Theme, Box<dyn std::error::Error>> {
Ok(Theme {
name: String::from("default"),
css: String::from("body { font-size: 11px; }")
})
}
pub fn save_to... |
#[cfg(feature = "keystone")]
pub mod keystone;
|
// Copyright 2018 Mohammad Rezaei.
//
// 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. This file may not be copied, modified, or distributed
// except accordin... |
#[doc = "Register `TURCF` reader"]
pub type R = crate::R<TURCF_SPEC>;
#[doc = "Register `TURCF` writer"]
pub type W = crate::W<TURCF_SPEC>;
#[doc = "Field `NCL` reader - Numerator Configuration Low."]
pub type NCL_R = crate::FieldReader<u16>;
#[doc = "Field `NCL` writer - Numerator Configuration Low."]
pub type NCL_W<'... |
pub mod artifact;
pub mod buff_cli_config;
pub mod package_metadata;
pub mod protobuffers;
pub mod registry;
|
use ggez;
use ggez::event;
use ggez::graphics;
use ggez::input::keyboard::{self, KeyCode};
use ggez::nalgebra as na;
use ggez::{Context, GameResult};
use rand::{self, thread_rng, Rng};
const PADDING: f32 = 40.0;
const MIDDLE_LINE_W: f32 = 2.0;
const RACKET_HEIGHT: f32 = 100.0;
const RACKET_WIDTH: f32 = 20.0;
const RAC... |
use rusqlite;
use std::path::Path;
use krate::Src;
use serde_json;
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct Prefetch {
pub prefetch: Src,
pub path: PathBuf,
}
#[derive(Debug)]
pub struct Cache {
cache: rusqlite::Connection,
}
impl Cache {
pub fn new<P:AsRef<Path>>(file: P) -> Self {... |
use crate::owl::thick_triple as owl;
use serde_json::{Value};
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
// Object Properties
//;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
/// Given an OWL expressions owl
/// return its corresponding OFN S-expression.
pub fn translate(owl: &owl::OWL) ... |
//! Demostrates loading custom assets using the Amethyst engine.
// TODO: Add asset loader directory store for the meshes.
extern crate amethyst;
extern crate cgmath;
extern crate futures;
extern crate rayon;
use amethyst::{Application, Error, State, Trans};
use amethyst::assets::{AssetFuture, BoxedErr, Context, Form... |
//! The main entrypoint for the application. Contains the main function for initialisation
//! of the webserver.
#![forbid(unsafe_code)]
#![feature(plugin)]
#![plugin(phf_macros)]
extern crate handlebars;
extern crate handlebars_iron;
extern crate iron;
extern crate params;
extern crate persistent;
extern crate router... |
use image::GenericImageView;
use image::GenericImage;
use image::DynamicImage;
use image::Rgba;
use crate::base_module::common::PixelSumData;
use crate::base_module::common::Pixel;
use crate::base_module::common::PixelKind;
use crate::base_module::base_image_proc::GoImageProcessing;
pub struct GrayScale2Diff {}
impl ... |
/*!
```rudra-poc
[target]
crate = "sized-chunks"
version = "0.6.2"
[[target.peer]]
crate = "typenum"
version = "1.11.2"
[test]
cargo_flags = ["--release"]
[report]
issue_url = "https://github.com/bodil/sized-chunks/issues/11"
issue_date = 2020-09-06
rustsec_url = "https://github.com/RustSec/advisory-db/pull/381"
rus... |
mod fold;
mod fold_from;
mod multiset;
mod multiset2;
mod reduce;
mod set;
use std::collections::hash_map::Iter;
use std::slice;
pub use fold::HalfJoinStateFold;
pub use fold_from::HalfJoinStateFoldFrom;
pub use multiset2::HalfJoinStateMultiset;
pub use reduce::HalfJoinStateReduce;
pub use set::HalfSetJoinState;
use ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.