text stringlengths 8 4.13M |
|---|
use std::net::{ TcpStream, Shutdown };
use std::io::{ BufRead, BufReader };
use std::str;
fn main() {
let mut stream = TcpStream::connect("127.0.0.1:8888")
.expect("Error connecting to the server");
println!("Connected to server");
let mut buffer: Vec<u8> = Vec::new();
let mut reader = BufReade... |
// Copyright © 2018–2019 Trevor Spiteri
// This library is free software: you can redistribute it and/or
// modify it under the terms of either
//
// * the Apache License, Version 2.0 or
// * the MIT License
//
// at your option.
//
// You should have recieved copies of the Apache License and the MIT
// License al... |
use crate::xml::read_xml;
use azure_core::headers::{date_from_headers, request_id_from_headers};
use azure_core::prelude::NextMarker;
use azure_core::RequestId;
use bytes::Bytes;
use chrono::{DateTime, Utc};
use std::convert::TryFrom;
#[derive(Debug, Clone, PartialEq)]
pub struct ListBlobsByTagsResponse {
pub max_... |
use super::phys::GRAVITY;
use crate::{
comp::{
ActionState::*, CharacterState, Controller, Mounting, MovementState::*, Ori, PhysicsState,
Pos, Stats, Vel,
},
state::DeltaTime,
terrain::TerrainGrid,
};
use specs::prelude::*;
use std::time::Duration;
use vek::*;
pub const ROLL_DURATION: D... |
// Finger trees for Rust
extern crate monoid;
|
//! Provides definitions of the vertex format for the game's
//! the vertex attributes. Each vertex attribute will be stored
//! in a Vertex Buffer Object (either by itself or interleaved
//! with others).
//!
//! This module provides the strongly-typed storage ``struct``s
//! that are employed to represent a vertex.
... |
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
#[allow(dead_code)]
struct Scanner<'a> {
cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
fn new(cin: StdinLock<'a>) -> Scanner<'a> {
Scanner { cin: cin }
}
fn read<T: FromStr>(&mut self) -> Option<T> {
let t... |
use std::collections::HashMap;
use prometheus::{CounterVec, Encoder, Opts, Registry, TextEncoder};
pub struct Metrics {
registry: Registry,
request_counter: CounterVec,
}
impl Metrics {
pub fn new(id: u64) -> Metrics {
let request_counter_opts = Opts::new("bayard_requests_total", "Total number of... |
use std::collections::HashMap;
use ggez::graphics::{Mesh, MeshBuilder, DrawMode, Drawable, Rect, Color, TextFragment, Scale, Text};
use std::rc::Rc;
use ggez::{Context, GameResult, graphics};
use crate::{DPPoint, point};
pub struct Renderer {
width: f32,
height: f32,
mesh_cache: HashMap<String, Rc<Mesh>>
}... |
/// ARINC653P1-5 3.7.2.2
pub mod blackboard;
/// ARINC653P1-5 3.7.2.1
pub mod buffer;
/// ARINC653P1-5 3.8
pub mod error;
/// ARINC653P1-5 3.7.2.4
pub mod event;
/// ARINC653P2-4 3.2
pub mod file_system;
/// ARINC653P2-4 3.13
pub mod interrupt;
/// Hypervisor dependent limits
pub mod limits;
/// ARINC653P2-4 3.5
pub mo... |
use crate::rbatis::Rbatis;
use crate::Error;
use rbs::Value;
/// sql intercept
pub trait SqlIntercept: Send + Sync {
/// do intercept sql/args
/// is_prepared_sql: if is run in prepared_sql=ture
fn do_intercept(
&self,
rb: &Rbatis,
sql: &mut String,
args: &mut Vec<Value>,
... |
use crate::config::Config;
use clap::crate_version;
use clap::crate_authors;
use clap::{Arg, App, SubCommand, AppSettings};
pub fn boot() -> Result<Config, Box<dyn std::error::Error>> {
let verbose_arg = Arg::with_name("verbose")
.long("verbose")
.possible_values(&["info", "warn", "error"... |
// src/main.rs
mod db;
mod logger;
mod models;
mod routes;
type StdErr = Box<dyn std::error::Error>;
#[actix_web::get("/")]
async fn hello_world() -> &'static str {
"Hello, world!"
}
#[actix_web::main]
async fn main() -> Result<(), StdErr> {
dotenv::dotenv().ok();
#[cfg(debug_assertions)]
logger::ini... |
pub mod auth;
pub mod error;
pub mod models;
pub mod utils;
use crate::error::ServiceError;
use async_trait::async_trait;
use deadpool::managed::Object;
use deadpool_postgres::{ClientWrapper, Pool};
use std::ops::Deref;
use tokio_postgres::{
types::{BorrowToSql, ToSql, Type},
Error, Row, RowStream, Statement, ... |
use std::time::Duration;
use crate::echo_server::{Echo, EchoServer};
use crate::greeter_server::{Greeter, GreeterServer};
use tokio::sync::mpsc;
use tokio_stream::wrappers::ReceiverStream;
use tonic::{transport::Server, Request, Response, Status};
tonic::include_proto!("helloworld");
tonic::include_proto!("grpc.examp... |
pub mod hash;
pub mod os;
#[cfg(test)]
mod tests;
|
#![allow(bad_style, unused_variables)]
extern crate winapi;
mod sqltypes;
mod sql;
mod sqlext;
use sqltypes::*;
use sql::*;
#[no_mangle]
pub extern fn SQLAllocHandle(
handleType: SQLSMALLINT,
inputHandle: SQLHANDLE,
outputHandlePtr: *mut SQLHANDLE) -> SQLRETURN {
return SQL_SUCCESS;
}
#[no_mangle]
pub extern f... |
use std::cmp;
use std::collections::HashMap;
use minhashes::KmerCount;
use statistics::hist;
/// Used to pass around filter options for sketching
#[derive(Debug)]
pub struct FilterParams {
pub filter_on: Option<bool>,
pub abun_filter: (Option<u16>, Option<u16>),
pub err_filter: f32,
pub strand_filter... |
extern crate colored;
use colored::*;
#[allow(dead_code)]
const EMPTY_STRING: &'static str = "";
pub const DEFAULT_PATTERN: &'static str = ".*";
pub const DEFAULT_TARGET: &'static str = ".";
#[derive(Clone, Debug)]
pub struct SearchArgs<'a> {
pub highlight: bool,
pattern: &'a str,
pub target: &'a str,
... |
#[derive(Default)]
pub struct State {
pub characters: Vec<Character>,
pub selected_index: usize,
pub log_messages: Vec<String>,
}
pub struct Character {
pub name: String,
pub hp: String,
pub notes: Option<String>,
}
impl Character {
fn new(name: &str, hp: &str) -> Self {
Character ... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Cluster GPIO%s, containing GPIO*_STATUS, GPIO*_CTRL"]
pub gpio: [GPIO; 30],
#[doc = "0xf0 - Raw Interrupts"]
pub intr0: INTR0,
#[doc = "0xf4 - Raw Interrupts"]
pub intr1: INTR1,
#[doc = "0xf8 - Raw Interrupts"]
... |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
use std::env;
extern crate prost_build;
fn main() {
let protopkg = vcpkg::find_package("protobuf").unwrap();
let protobuf_path = protopkg.link_paths[0].parent().unwrap();
let protobuf_bin_path = protobu... |
use std::time::{Duration, Instant};
// NOTE: Rust doesn't have a built-in random number generator so I did need to use a package for that
use rand::distributions::{Distribution, Uniform};
fn main() {
let min = 1_000_000;
let max = 10_000_000;
let step = 1_000_000;
let mut durations = Vec::new();
... |
use std::ffi::{CString, CStr};
use std::os::raw::{c_int, c_char};
use std::slice;
use raw::{aw, vp};
use attributes::{AttribValue, Attrib};
use instance::Instance;
fn vp_string(instance: &mut Instance, vp_attribute: vp::string_attribute_t) -> CString {
unsafe {
CStr::from_ptr(vp::string(instance.vp, vp_at... |
//! Uses a trait that has general page table managing functions.
use super::frame_allocator::FRAME_ALLOCATOR;
use super::page_table::{Level1, Level2, Level4, PageTable};
use super::page_table_entry::{PageTableEntry, PageTableEntryFlags, PRESENT};
use super::{Page, PageFrame};
use core::ops::{Deref, DerefMut};
use memo... |
extern crate fuse;
extern crate libc;
extern crate time;
extern crate hyper;
extern crate rustc_serialize;
extern crate clap;
use std::collections::BTreeMap;
use std::path::Path;
use std::env;
use std::io::prelude::Read;
use libc::{ENOENT, ENOSYS};
use time::Timespec;
use fuse::{FileAttr, FileType, Filesystem, Request... |
use futures::stream::TryStreamExt;
use crate::{
bson::doc,
error::ErrorKind,
options::{CommitQuorum, CreateIndexOptions, IndexOptions},
test::{
log_uncaptured,
util::{EventClient, TestClient},
},
IndexModel,
};
// Test that creating indexes works as expected.
#[cfg_attr(feature... |
/// Check a Luhn checksum.
pub fn is_valid(code: &str) -> bool {
let code = code.replace(" ", "");
if code.chars().any(|c| !c.is_digit(10)) {
return false;
}
if code.chars().count() <= 1 {
return false;
}
let total = code
.chars()
.rev()
.map(|c| c.to_digit(10).unwrap())
.enumerate()... |
mod compiler;
use compiler::lifetime_elision::*;
//Same scope for references everything is nice!
fn main() {
let city = City::new(54);
let city2 = City::new(30);
let result = compare_size_with_lifetimes(&city, &city2);
println!("{}", result.size_in_sqm);
}
// Calling this means that city2 i... |
#![feature(vec_remove_item)]
use std::collections::HashMap;
use std::collections::HashSet;
type NodeID = &'static str;
type Graph = HashMap<NodeID, &'static str>;
type Group = HashSet<NodeID>;
fn main() {
let input = include_str!("input.txt");
let graph = parse_graph(input);
println!("Answer #1: {}", ge... |
use std::fs;
use std::io::Error as IOError;
use std::path::Path;
pub struct Reader {
underlying_buffer: Vec<u8>,
}
impl Reader {
pub fn new<T: Into<Vec<u8>>>(buffer: T) -> Reader {
Reader {
underlying_buffer: buffer.into(),
}
}
pub fn new_from_path<T: AsRef<Path>>(path: T)... |
use std::ffi::CStr;
use std::mem::forget;
use std::os::raw::c_char;
use crate::parser::Parser;
use crate::rasterbackend::RasterBackend;
use std::time::Duration;
#[repr(C)]
pub struct PictureBuffer {
/// data in rgba8888 format
data: *const u8,
/// length of the buffer
len: u32,
/// stride of the b... |
// Copyright 2019 Steven Bosnick
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE-2.0 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 accord... |
mod cpu;
mod debugger;
mod file;
mod instruction;
mod state;
use crate::debugger::Debugger;
use crate::state::State;
use std::error::Error;
pub fn run(filename: String, debug: bool) -> Result<(), Box<dyn Error>> {
let mut rom = file::read_rom(filename)?;
let mut state = State::new();
state.load_rom(&mut r... |
use crate::utils::copy_string;
use crate::{check_status, Error};
use std::ffi::CString;
use std::os::raw::c_int;
use std::ptr;
/// Information from the EEPROM of a daughter board
pub struct DaughterBoardEeprom(uhd_sys::uhd_dboard_eeprom_handle);
impl DaughterBoardEeprom {
pub fn id(&self) -> Result<String, Error>... |
#![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 OperationListResult {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub value: Vec<OperationValu... |
pub mod transistor;
pub mod and_gate;
pub mod wire;
pub use crate::components::transistor::Transistor;
pub use crate::components::and_gate::AndGate;
pub use crate::components::wire::wiring; |
use crate::commands::wallet::wallet_query;
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use clap::Clap;
use ic_utils::interfaces::wallet::AddressEntry;
/// Print wallet's address book.
#[derive(Clap)]
pub struct AddressesOpts {}
pub async fn exec(env: &dyn Environment, _opts: Addresses... |
use super::range_wrapper::RangeStartWrapper;
use crate::std_ext::*;
use std::collections::BTreeMap;
use std::fmt::{self, Debug};
use std::ops::Range;
/// A map whose keys are stored as (half-open) ranges bounded
/// inclusively below and exclusively above `(start..end)`.
///
/// Contiguous and overlapping ranges that ... |
use lazy_static::lazy_static;
use regex::Regex;
use std::collections::{HashMap, HashSet};
fn parse_line(line: &str) -> (String, Vec<(usize, String)>) {
const KEY_STR: &str = r"^(?P<color>\w+ \w+)";
const VAL_RE_STR: &str = r"(?P<amount>\d+) (?P<color>\w+ \w+) bags?";
lazy_static! {
static ref KEY_R... |
pub use amethyst::core::nalgebra::{
Point1, Point2, Point3, UnitQuaternion, Rotation, Rotation2, Rotation3, Vector1, Vector2, Vector3,
Vector4,
};
pub use std::f32::consts::PI;
pub const TAU: f32 = ::std::f32::consts::PI * 2.0;
pub trait Clamp {
fn clamp(self, min: Self, max: Self) -> Self;
}
impl Clamp ... |
use log::error;
use mpd::{Client, Stats};
use serenity::{
framework::standard::{macros::command, CommandResult},
model::channel::Message,
prelude::*,
};
use std::process::Command;
#[command]
#[description = "How much music does Phate have?"]
fn hmm(ctx: &mut Context, msg: &Message) -> CommandResult {
l... |
pub use system::error::*;
pub use system::syscall::*;
use arch::regs::Regs;
use arch::context::context_switch;
pub mod execute;
pub mod fs;
pub mod memory;
pub mod process;
pub mod time;
pub fn name(number: usize) -> &'static str {
match number {
// Redox
SYS_SUPERVISE => "supervise",
//... |
#[doc = "Reader of register OA_RES1_CTRL"]
pub type R = crate::R<u32, super::OA_RES1_CTRL>;
#[doc = "Writer for register OA_RES1_CTRL"]
pub type W = crate::W<u32, super::OA_RES1_CTRL>;
#[doc = "Register OA_RES1_CTRL `reset()`'s with value 0"]
impl crate::ResetValue for super::OA_RES1_CTRL {
type Type = u32;
#[i... |
use std::fs::File;
use std::io::{BufReader, BufWriter};
use serde::{Deserialize, Serialize};
use dmc::Dmc;
use noise::Noise;
use square::Square;
use triangle::Triangle;
use crate::decay::Decay;
use crate::filters::{Filter, HighPass, LowPass};
use crate::savable::Savable;
// http://wiki.nesdev.com/w/index.php/APU_Le... |
use quote::quote_spanned;
use syn::parse_quote;
use super::{
FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, WriteContextArgs,
RANGE_1,
};
/// > 2 input streams of type S and T, 1 output stream of type (S, T)
///
/// Forms the cross-join (Cartesian product) of the items in the input st... |
#[aoc(day1, part1)]
pub fn day_1_p1(input: &str) -> u64 {
input
.lines()
.map(|n| n.parse::<u64>().unwrap())
.map(|n| n / 3 - 2)
.sum()
}
#[aoc(day1, part2)]
pub fn day_1_p2(input: &str) -> u64 {
fn calc_fuel(mass: u64) -> u64 {
let mut additional_fuel = mass / 3 - 2;
... |
use std::cell::RefCell;
use std::collections::{HashMap, HashSet};
use std::ffi::OsStr;
use std::io::Cursor;
use std::path::{Path, PathBuf};
use ::image::{
codecs::png::{PngDecoder, PngEncoder},
ColorType, GenericImage, GenericImageView, ImageBuffer, ImageDecoder, Rgba, RgbaImage,
};
use serde::{Deserialize, Se... |
//! Improved cross-platform clipboard library
//!
//! Fork of https://github.com/aweinstock314/rust-clipboard with better error handling
#[cfg(target_os="windows")]
extern crate clipboard_win;
#[cfg(any(target_os="linux", target_os="openbsd"))]
extern crate x11_clipboard;
#[cfg(target_os="macos")]
#[macro_use]
extern ... |
use crate::bus::Bus;
pub struct Cpu {
pc: u32,
regs: [u32; 32],
rom: Vec<u8>,
bus: Bus,
}
impl Cpu {
pub fn new(rom: Vec<u8>) -> Cpu {
Cpu {
pc: 0,
regs: [0; 32],
rom: rom,
bus: Bus::new(),
}
}
pub fn can_run(&self) -> bool {... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - low interrupt status register"]
pub lisr: LISR,
#[doc = "0x04 - high interrupt status register"]
pub hisr: HISR,
#[doc = "0x08 - low interrupt flag clear register"]
pub lifcr: LIFCR,
#[doc = "0x0c - high interru... |
mod cd;
mod ls;
mod echo;
mod set;
mod pwd;
mod exit;
use std::collections::HashMap;
use rsh::State;
pub use self::cd::cd;
pub use self::ls::ls;
pub use self::echo::echo;
pub use self::set::{set, unset, get};
pub use self::pwd::pwd;
pub use self::exit::exit;
pub type Builtin = fn(&mut State) -> i32;
pub fn load() ... |
// use super::*;
use rocket::http::Status;
use rocket::local::Client;
// In order to get your test module to run, you need to add a mod <file.rs>.
// Note that .rs files in this directory are each given their own "module" that
// is named appropriately, so by adding a .rs file you add a module. You
// should really ... |
pub mod algor;
pub struct RSAKey
{
pub p: u128, pub q: u128, pub phi: u128,
pub n: u128, pub e: u128, pub d: u128
}
impl RSAKey
{
pub fn create() -> RSAKey {
RSAKey { p: 0, q: 0, phi: 0, n: 0, e: 0, d: 0 }
}
}
pub struct RSASystem
{
pub key: RSAKey
}
impl RSASystem
{
pub fn create() ... |
use crypto::pbkdf2;
use mnemonic::Mnemonic;
use std::fmt;
/// The secret value used to derive HD wallet addresses from a [`Mnemonic`][Mnemonic] phrase.
///
/// Because it is not possible to create a [`Mnemonic`][Mnemonic] instance that is invalid, it is
/// therefore impossible to have a [`Seed`][Seed] instance that i... |
use stm32f407;
use crate::hal::pin::*;
// Macro for PIOA, PIOB, PIOC, PIOD generation
macro_rules! add_control_pio {
($TARGET:ident, $PIOX:ident) => {
impl<'a, ENABLED, DIRECTION> PinConfigure<stm32f407::$PIOX, ENABLED, DIRECTION>
for Pin<'a, $TARGET::$PIOX, ENABLED, DIRECTION>
{
... |
/**
--- Day 1: Report Repair ---
After saving Christmas five years in a row, you've decided to take a vacation at a nice resort on a tropical island. Surely, Christmas will go on without you.
The tropical island has its own currency and is entirely cash-only. The gold coins used there have a little picture... |
use crate::datastructures::{
Entailment,
Pure::{And, True},
Rule,
Spatial::{Emp, SepConj},
};
pub struct Cleanup;
impl Rule for Cleanup {
fn predicate(&self, _goal: &Entailment) -> bool {
true
}
fn premisses(&self, goal: Entailment) -> Option<Vec<Entailment>> {
... |
#![no_std]
//! A simple compile-time derive macro to create type-to-value maps.
//!
//! This approach in contrast to crates such as [`typemap`](https://crates.io/crates/typemap/)
//! or [`type-map`](https://crates.io/crates/type-map/) that perform run-time lookup.
//! The static typing brings compile-time safety and f... |
use std::cmp::Ordering;
use std::collections::BinaryHeap;
/// Solves the Day 15 Part 1 puzzle with respect to the given input.
pub fn part_1(input: String) {
let risks = parse_input(input);
let adjs = make_adjacency_list(&risks);
let risk = shortest_path(&adjs, 0, adjs.len() - 1).unwrap();
println!("{}... |
use crate::grammar::ast::{eq::AstEq, BooleanLit, Expression};
use crate::grammar::model::{HasSourceReference, WrightInput};
use crate::grammar::parsers::with_input;
use crate::grammar::tracing::parsers::alt;
use crate::grammar::tracing::parsers::tag;
use crate::grammar::tracing::{parsers::map, trace_result};
use nom::c... |
//! The repr module is concerned with the representation of parsed regular expressions. A Pattern
//! is compiled by the `compile` module into a state graph defined in `state`.
#![allow(dead_code)]
/// A Pattern is either a repeated pattern, a stored submatch, an alternation between two patterns,
/// two patterns foll... |
use proconio::{fastout, input};
#[fastout]
fn main() {
input! {
x_vec: [i64; 5],
}
for (i, x) in x_vec.iter().enumerate() {
if *x == 0 {
println!("{}", i + 1);
return;
}
}
}
|
use super::DType;
pub type Scm = &'static ScmValue;
#[derive(Debug, Clone)]
pub enum ScmValue {
Int(i64),
Flt(f64),
Vec(Vec<Scm>),
}
impl DType for Scm {
fn int(i: i64) -> Self {
Box::leak(Box::new(ScmValue::Int(i)))
}
fn flt(f: f64) -> Self {
Box::leak(Box::new(ScmValue::Flt(... |
pub fn run() {
let mut i: i32 = 0;
println!("{0} and {0}", i);
loop {
i += 1;
if i == 5 {
continue;
} else if i >= 10 {
break;
}
println!("value i now {}", i);
}
let mut n = 1;
while n <= 30 {
n += 1;
println!("{0... |
//! Attributes implementation.
use crate::Attribute;
use arctk::{
err::Error,
img::Gradient,
ord::{Link, Set},
};
use arctk_attr::input;
/// Surface attribute setup.
#[input]
pub enum AttributeLinker {
/// Opaque coloured surface.
Opaque(String),
/// Partially reflective mirror, absorption fra... |
struct ValidationInfo {
password: String,
required_char: char,
chars_allowed: (usize, usize),
}
fn get_num_range(s: &str) -> (usize, usize) {
// expects strings in the format of "X-Y"
let bounds: Vec<&str> = s.split("-").collect();
(
bounds[0].parse::<usize>().unwrap(),
bounds[1... |
use std::collections::HashMap;
#[derive(Default, Debug, Clone)]
pub struct ReadOnly {
req_status: HashMap<u64, Vec<Vec<u8>>>,
}
impl ReadOnly {
pub fn new() -> ReadOnly {
ReadOnly {
req_status: HashMap::default(),
}
}
pub fn reset(&mut self) {
self.req_status.clear... |
// 8.2.1
use std::cell::RefCell;
use std::sync::Arc;
use std::thread;
use rustc_serialize::json;
use std::str;
use mio::*;
use mio::udp::*;
use std::net::ToSocketAddrs;
use mio::buf::{RingBuf, SliceBuf, MutSliceBuf};
use std::collections::VecDeque;
use std::net::SocketAddr;
use std::thread::sleep_ms;
type SeqNum = u6... |
#[doc = "Register `SR` reader"]
pub type R = crate::R<SR_SPEC>;
#[doc = "Register `SR` writer"]
pub type W = crate::W<SR_SPEC>;
#[doc = "Field `UIF` reader - Update interrupt flag"]
pub type UIF_R = crate::BitReader<UIFR_A>;
#[doc = "Update interrupt flag\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, E... |
quick_error! {
#[derive(Debug)]
pub enum X11Error {
OperationFailed(operation: &'static str) {
from()
}
}
}
|
use bevy::math::Vec3;
struct Spherical {
pub r: f32,
pub φ: f32,
pub θ: f32,
}
impl From<Vec3> for Spherical {
fn from(p: Vec3) -> Self {
let r = p.length();
Self {
r,
θ: (p.z / r).acos(),
φ: (p.x/p.y).atan() + if p.x < 0.0 { std::f32::consts::PI } e... |
pub mod player_movement;
pub mod asset_loading; |
#![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)]
ListOperations(#[from] list_operation... |
// file: iterlimit.rs
//
// Copyright 2015-2017 The RsGenetic 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 req... |
use super::*;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[repr(transparent)]
pub struct KeysLowActive(u16);
impl KeysLowActive {
const_new!();
bitfield_bool!(u16; 0, a_released, with_a_released, set_a_released);
bitfield_bool!(u16; 1, b_released, with_b_released, set_b_released);
bitfield_bool!(u16... |
use std::rc::Rc;
use std::cell::RefCell;
use failure::Error;
use smpl::{parse_module, UnparsedModule};
use smpl::interpreter::*;
pub const STATE_RUN: i32 = 0;
pub const STATE_END: i32 = 1;
const RT_CHOICE: &'static str = "choice";
const RT_CLEAR_CHOICES: &'static str = "clear_choices";
const RT_INIT_CTXT: &'static... |
pub fn run() {
greeting("hello", "naveen");
println!("Value of 10+10 is {} ", add(10, 10));
// Closure
let add_nums = |n1: i32, n2: i32| n1 + n2;
println!("C Sum:{}", add_nums(3, 3));
}
fn greeting(greet: &str, name: &str) {
println!("{} {}, nice to meet you", greet, name);
}
fn add(num1: i32... |
use crate::commands::WholeStreamCommand;
use crate::errors::ShellError;
use crate::prelude::*;
use std::path::PathBuf;
pub struct LS;
#[derive(Deserialize)]
pub struct LsArgs {
path: Option<Tagged<PathBuf>>,
}
impl WholeStreamCommand for LS {
fn name(&self) -> &str {
"ls"
}
fn signature(&sel... |
pub mod ast;
use ast::AssignmentLHS;
use ast::EnumAlternative;
use ast::EnumDefinition;
use ast::EnumDestructure;
use ast::EnumItem;
use ast::Expr;
use ast::FunctionCall;
use ast::FunctionDefinition;
use ast::FunctionSignature;
use ast::Identifier;
use ast::IfElse;
use ast::Match;
use ast::MatchArm;
use ast::MatchPatt... |
use quote::quote_spanned;
use super::{
FlowProperties, FlowPropertyVal, OperatorCategory, OperatorConstraints, OperatorInstance,
OperatorWriteOutput, WriteContextArgs, RANGE_0, RANGE_1,
};
/// Filter outputs a subsequence of the items it receives at its input, according to a
/// Rust boolean closure passed in... |
use crate::kind::Kind;
use crate::resource::Resource;
#[derive(Clone)]
pub struct Structure {
pub name: String,
pub resources: Vec<Resource>,
}
impl Structure {
pub fn new(name: &str, resources: Vec<(Kind, f64)>) -> Structure {
Structure {
name: name.to_string(),
resources:... |
#![allow(dead_code, non_camel_case_types)]
use libc::size_t;
pub type Enum_Unnamed1 = ::libc::c_uint;
pub static GIT_CAP_THREADS: ::libc::c_uint = 1;
pub static GIT_CAP_HTTPS: ::libc::c_uint = 2;
pub static GIT_CAP_SSH: ::libc::c_uint = 4;
pub type git_cap_t = Enum_Unnamed1;
pub type Enum_Unnamed2 = ::libc::c_uint;
p... |
use crate::ast;
use std::collections::HashSet;
use syn;
use syn::parse::Result as ParseResult;
use syn::spanned::Spanned;
use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use heck::SnakeCase;
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd)]
struct PropertyId(usize);
/*struct Property {
name: syn::Ide... |
use apllodb_shared_components::ApllodbResult;
use apllodb_sql_parser::apllodb_ast;
use apllodb_storage_engine_interface::ColumnName;
use crate::ast_translator::AstTranslator;
impl AstTranslator {
pub fn column_name(ast_column_name: apllodb_ast::ColumnName) -> ApllodbResult<ColumnName> {
ColumnName::new(as... |
use crate::common::CodegenCx;
use crate::coverageinfo;
use crate::llvm;
use llvm::coverageinfo::CounterMappingRegion;
use rustc_codegen_ssa::coverageinfo::map::{Counter, CounterExpression, FunctionCoverage};
use rustc_codegen_ssa::traits::ConstMethods;
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};... |
/// constraints represent
/// the various type relationships
/// that must be preserved.
mod heeren;
mod heeren_tests;
mod unification;
mod unification_tests;
pub use self::unification::*;
|
//! Solver configuration.
#![allow(missing_docs)]
#[cfg(test)]
#[path = "../../../tests/unit/extensions/solve/config_test.rs"]
mod config_test;
extern crate serde_json;
use serde::Deserialize;
use std::io::{BufReader, Read};
use std::sync::Arc;
use vrp_core::models::common::SingleDimLoad;
use vrp_core::models::Prob... |
use crate::EntityWithMetadata;
use azure_core::{
headers::{etag_from_headers, get_str_from_headers, CommonStorageResponseHeaders},
prelude::Etag,
util::HeaderMapExt,
};
use bytes::Bytes;
use http::Response;
use serde::de::DeserializeOwned;
use std::convert::{TryFrom, TryInto};
use url::Url;
#[derive(Debug,... |
use bson::{RawDocument, RawDocumentBuf};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use super::wire::Message;
use crate::{
bson::{rawdoc, Document},
bson_util::extend_raw_document_buf,
client::{options::ServerApi, ClusterTime, HELLO_COMMAND_NAMES, REDACTED_COMMANDS},
error::{Error, Erro... |
// box pointer
fn box_pointer() {
fn add_one( num: Box<i32>) {
*num += 1;
}
let p = Box::new(1i32);
add_one(p);
// equivilent to following C code:
//
// {
// int *x = malloc(sizeof(int));
// add_one(x);
// free(x);
// }
// println!("{}", p); // `p` has been moved.
}
fn bo... |
use assert_cmd::prelude::*; // Add methods on commands
use std::{env, process::Command, path::Path};
#[test]
fn positive_question_mark() {
let mut cmd = Command::cargo_bin("cargo-hacspec").expect("Error getting cargo hacspec command");
cmd.envs(env::vars());
cmd.args(&["-e", "fst"]);
cmd.args(&["--dir"... |
//! This module contains everything related to graphics.
#![allow(missing_docs)]
pub mod window;
pub mod canvas;
pub mod image;
pub mod font;
pub mod text;
pub mod sprite;
pub mod drawable;
pub mod color;
pub mod shape; |
use tokio::stream::{Stream, StreamExt};
use pin_project::pin_project;
use std::pin::Pin;
use std::task::{Context, Poll};
#[pin_project]
pub struct StreamReader<R> {
source: Vec<R>,
buffer_length: usize,
ptr_location: usize,
window_size: usize
}
use tokio::net::TcpListener;
impl <R> StreamReader<R> ... |
#[allow(unused_parens)]
pub fn raindrops(n: u32) -> String {
let mut result : String = String::new();
if ( n%3 == 0) {result+="Pling"}
if ( n%5 == 0) {result+="Plang"}
if ( n%7 == 0) {result+="Plong"}
if result.is_empty() {
result = format!("{}", n);
}
result
}
|
use crate::{content::PostDirMetadata, markdown, paths::AbsPath, util};
use camino::{Utf8Path, Utf8PathBuf};
use chrono::Utc;
use colored::Colorize;
use eyre::{eyre, Result};
use regex::Regex;
use serde::Deserialize;
use std::fs;
use tracing::info;
use yaml_front_matter::{Document, YamlFrontMatter};
pub fn new_post(tit... |
#[doc = "Register `APB3ENR` reader"]
pub type R = crate::R<APB3ENR_SPEC>;
#[doc = "Register `APB3ENR` writer"]
pub type W = crate::W<APB3ENR_SPEC>;
#[doc = "Field `SBSEN` reader - SBS clock enable Set and reset by software."]
pub type SBSEN_R = crate::BitReader;
#[doc = "Field `SBSEN` writer - SBS clock enable Set and ... |
pub mod tokens;
use self::tokens::{get_operator_table, get_token_table, Keyword, Token, TokenType};
use crate::utils::AsExclusiveTakeWhile;
use std::collections::HashMap;
use std::fmt;
use std::iter::{FromIterator, IntoIterator, Iterator, Peekable};
use std::string::String;
use std::vec;
// ---------- Lexer --------... |
use crate::net::SignerID;
use crate::rpc::TapyrusApi;
use crate::signer_node::{is_master, master_index, NodeParameters, NodeState};
use tapyrus::blockdata::block::Block;
pub fn process_completedblock<T>(
sender_id: &SignerID,
block: &Block,
prev_state: &NodeState,
params: &NodeParameters<T>,
) -> NodeS... |
//! Abstraction and functions for walking the i3-node tree.
extern crate i3ipc;
use super::structures::*;
struct TreeWalker<T> {
// rootnode: i3ipc::reply::Node,
nextnode: Option<i3ipc::reply::Node>,
output: Option<i3ipc::reply::Node>,
workspace: Option<i3ipc::reply::Node>,
parent_containers: Vec<... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.