text stringlengths 8 4.13M |
|---|
pub mod concentrator;
pub mod client;
pub mod quic_tunnel;
pub mod shutdown;
use shutdown::Shutdown;
|
//#![deny(clippy::all)]
//#![warn(clippy::all)]
//#![allow(clippy::all)]
#![allow(dead_code)]
// Checks for comparisons where one side of the relation is either the
// minimum or maximum value for its type and warns if it involves a
// case that is always true or always false. Only integer and boolean types are checke... |
// the laborious task of writing the memory map, and it's many ranges and behaviour depending on the address being written to!
pub const STACK_START: usize = 0x100;
pub const STACK_END: usize = 0x1FF;
pub const INTERNAL_RAM_START: usize = 0x0;
pub const INTERNAL_RAM_END: usize = 0x7FF;
pub const INTERNAL_RAM_MIRROR_... |
pub mod component;
pub mod ball_system;
pub mod bounce_system;
pub mod trajectory_system;
|
use std::cmp::min_by;
use std::f64::MAX;
use rayon::prelude::*;
use crate::common::types::Weight;
use crate::common::utils::{cmp, read_lines, to_edges, vertices};
use crate::week1::types::ShortestPathsBF;
use crate::week1::{bellman_ford, floyd_warshall};
/// Computes the solution to the problem for the file
/// loca... |
pub(crate) mod comment;
pub(crate) mod comment_vote;
pub(crate) mod comments;
pub(crate) mod frontpage;
pub(crate) mod recent;
pub(crate) mod story;
pub(crate) mod story_vote;
pub(crate) mod submit;
pub(crate) mod user;
use futures::Future;
use my;
use my::prelude::*;
pub(crate) fn notifications(
c: my::Conn,
... |
use ::cpu::op::Op;
use ::softfloat::Sf64;
use std::mem::size_of;
/// Statuses with which virtual CPU execution may stop.
///
/// Some of these may be recovered from. For all errors, the effects are documented.
#[derive(Clone,Copy,Debug,Eq,PartialEq)]
pub enum CpuError {
/// Tried to branch or jump to an unaligned ... |
use std::collections::BTreeSet;
use std::collections::HashMap;
use std::convert::TryFrom;
use std::iter::FromIterator;
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
pub enum Move {
Up(usize),
Down(usize),
Left(usize),
Right(usize),
}
pub fn parse_moves(input: &str) -> Result<Vec<Move>, std::num::... |
use liblumen_alloc::erts::term::prelude::*;
#[native_implemented::label]
fn result(
apply_returned: Term,
// Having event_listener as an argument ensures it is not dropped while the apply/3 is running.
_event_listener: Term,
) -> Term {
apply_returned
}
|
// Copyright 2021 Chiral Ltd.
// Licensed under the Apache-2.0 license (https://opensource.org/licenses/Apache-2.0)
// This file may not be copied, modified, or distributed
// except according to those terms.
mod config;
mod element;
mod bond;
mod atom;
mod molecule;
mod extendable_hash;
mod local_symmetry;
mod workfl... |
mod with_process;
use super::*;
// `without_process_returns_false` in integration tests
|
use std::collections::HashMap;
fn compute_spoken_number(starting: &Vec<usize>, turn: usize) -> usize {
let mut history = HashMap::new();
let mut spoken = starting[0];
let mut next_spoken;
for i in 1..turn {
if i < starting.len() {
next_spoken = starting[i];
} else {
... |
#[doc = "Reader of register CFG1"]
pub type R = crate::R<u32, super::CFG1>;
#[doc = "Writer for register CFG1"]
pub type W = crate::W<u32, super::CFG1>;
#[doc = "Register CFG1 `reset()`'s with value 0x0007_0007"]
impl crate::ResetValue for super::CFG1 {
type Type = u32;
#[inline(always)]
fn reset_value() ->... |
extern crate mio;
use mio::tcp::*;
const SERVER: mio::Token = mio::Token(0);
struct Pong {
server: TcpListener,
connections: Slab<Connection>,
}
struct Connection {
socket: TcpStream,
token: mio::Token,
state: State,
}
enum State {
Reading(Vec<u8>),
Writing(Take<Cursor<Vec<u8>>>),
}
im... |
#![allow(unused_unsafe)]
#![allow(dead_code)]
#![allow(non_camel_case_types)]
use super::dx_pub_use::*;
use super::unsafe_util::*;
use winapi::_core::mem;
use winapi::shared::basetsd::{SIZE_T, UINT16};
use winapi::shared::minwindef::{FALSE, INT, TRUE};
pub trait CD3DX12_CPU_DESCRIPTOR_HANDLE {
fn offset(
... |
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)]
#![allow(
clippy::approx_constant,
clippy::type_complexity,
clippy::unreadable_literal
)]
extern ... |
//! Module for low-level BAPS3 protocol manipulation.
//!
//! This module contains two items of note: the function `pack`, which converts
//! a command word and arguments into a BAPS3 protocol line; and `Unpacker`,
//! which can be fed bytes or strings from a BAPS3 client or server and will
//! unpack them into command... |
// 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::collections::HashMap;
use std::{borrow::Cow, sync::Arc};
use chrono::{DateTime, Utc};
use crate::{ctx::SpanContext, TraceCollector};
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum SpanStatus {
Unknown,
Ok,
Err,
}
/// A `Span` is a representation of a an interval of time spent performing ... |
use std::{error::Error, io};
use diesel::{prelude::*, r2d2};
use rand::{rngs::SmallRng, Rng, SeedableRng};
use tokio::task::spawn_blocking;
use super::ser::{Fortune, Fortunes, World};
type DbResult<T> = Result<T, Box<dyn Error + Send + Sync + 'static>>;
#[derive(Clone)]
pub struct DieselPool {
pool: r2d2::Pool<... |
fn main() {
read_instruction();
}
fn read_instruction() {
println!("Enter instruction (Create, Read, Delete)");
let mut s = get_input();
parse_instruction(s.trim().to_string());
}
fn parse_instruction(instr: String) {
match instr.as_ref() {
"create" => {
println!("Enter path:")... |
use futures::Future;
use tokio::prelude::*;
use tokio_channel::mpsc;
use std::fmt::Debug;
pub struct ChatBox<M> {
store: Vec<M>,
ch_r:mpsc::Receiver<Request<M>>,
}
pub enum Request<M> {
Put(M),
}
impl<M: Debug> ChatBox<M> {
pub fn new()->(Self, mpsc::Sender<Request<M>>) {
let (ch_s, ch_r) =... |
extern crate serde;
mod test_utils;
use flexi_logger::LoggerHandle;
use hdbconnect::{time::HanaTime, Connection, HdbResult, ToHana};
use log::{debug, info};
use time::{format_description::FormatItem, macros::format_description, Time};
#[test] // cargo test --test test_023_secondtime
pub fn test_023_secondtime() -> H... |
//! This module contains the different solvers for the Sudoku puzzle
//!
//! Currently implemented:
//! Backtracing solver (single threaded)
use board::Board;
/// The recursive backtracking algorithm functions as follows:
/// Each time it's run it'll look for an empty space and then try to fill this
/// space wit... |
use crate::api::v1::ceo::option_group::model::{
Delete, Get, GetList, New, SimpleOptionGroup, Update,
};
use crate::errors::ServiceError;
use crate::models::option_group::OptionGroup as Object;
use crate::models::DbExecutor;
use crate::schema::option_group::dsl::{deleted_at, id, name, option_group as tb, shop_id};
... |
mod yaml_collections;
mod yaml_rolling_stocks;
mod yaml_wish_lists;
use crate::domain::collecting::{
collections::Collection, wish_lists::WishList,
};
use serde_yaml;
use std::fs;
use yaml_collections::YamlCollection;
use yaml_wish_lists::YamlWishList;
#[derive(Debug)]
pub struct DataSource {
filename: String... |
#[doc = r"Value read from the register"]
pub struct R {
bits: u8,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u8,
}
impl super::RXCSRH7 {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'... |
mod with_bitstring;
use std::convert::TryInto;
use std::sync::Arc;
use proptest::strategy::Just;
use proptest::test_runner::TestCaseResult;
use proptest::{prop_assert, prop_assert_eq};
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::*;
use crate::erlang::binary_part_3::result;
... |
use crate::backend::{CodeGenSession, TranslatedCodeSection};
use crate::error::Error;
use crate::function_body;
use crate::microwasm::{MicrowasmConv, Type as MWType};
use crate::module::{ModuleContext, SimpleContext};
use cranelift_codegen::{binemit, ir};
#[allow(unused_imports)] // for now
use wasmparser::{
CodeSe... |
mod with_reference;
use std::convert::TryInto;
use std::sync::Arc;
use proptest::prop_oneof;
use proptest::strategy::{BoxedStrategy, Just, Strategy};
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::*;
use liblumen_alloc::erts::time::Milliseconds;
use crate::erlang::read_timer_2:... |
#[doc = "Reader of register VLANTG"]
pub type R = crate::R<u32, super::VLANTG>;
#[doc = "Writer for register VLANTG"]
pub type W = crate::W<u32, super::VLANTG>;
#[doc = "Register VLANTG `reset()`'s with value 0"]
impl crate::ResetValue for super::VLANTG {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use instruction::*;
use binaryen::*;
use cfg;
use error::*;
use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Opts {
pub optimize: bool,
pub print: bool,
}
impl Default for Opts {
fn default() -> Opts {
Opts {
optimize: true,
print: false,
}
}
... |
fn main() {
let accumulated = (1..100).fold(0, |acc, n| acc + (n * 100));
println!("{}", accumulated);
}
|
use libc;
use alloc::borrow::ToOwned;
pub mod scope;
pub mod vnode;
#[derive(Debug)]
pub enum KAuthResult {
ALLOW = 1,
DENY = 2,
DEFER = 3,
}
#[derive(Debug)]
pub struct KAuth(*const libc::c_void);
impl KAuth {
pub fn new(cred: *const libc::c_void) -> Self {
KAuth(cred)
}
pub fn uid... |
use std::fmt;
#[derive(Debug, Clone)]
pub struct Puzzle {
pub size: usize,
pub board: Vec<usize>,
pub tiles: Vec<usize>,
}
impl fmt::Display for Puzzle {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"size = {}, board= {:?} , tiles = {:?}",
... |
pub fn fib(n: i32) -> i32 {
const SQRT5: f64 = 2.23606797749979;
const PHI: f64 = (1.0 + SQRT5) / 2.0;
const PSI: f64 = 1.0 - PHI;
((PHI.powf(n as f64) - PSI.powf(n as f64)) / SQRT5) as i32
}
#[cfg(test)]
mod fib_tests {
use super::*;
#[test]
fn fib_test_one() {
// arrange
... |
use pattern::*;
use haystack::Span;
use slices::slice::{TwoWaySearcher, SliceChecker, SliceSearcher};
use std::ops::Range;
unsafe impl<'p> Searcher<str> for TwoWaySearcher<'p, u8> {
#[inline]
fn search(&mut self, span: Span<&str>) -> Option<Range<usize>> {
let (hay, range) = span.into_parts();
... |
//给定一个没有重复数字的序列,返回其所有可能的全排列。
//
// 示例:
//
// 输入: [1,2,3]
//输出:
//[
// [1,2,3],
// [1,3,2],
// [2,1,3],
// [2,3,1],
// [3,1,2],
// [3,2,1]
//]
// Related Topics 回溯算法
//leetcode submit region begin(Prohibit modification and deletion)
impl Solution {
pub fn permute(nums: Vec<i32>) -> Vec<Vec<i32>> {
fn ... |
use crate::helpers::handler;
use crate::config::Config;
use crate::services::system::controller::SystemController;
use actix_web::{web, HttpResponse, Scope};
use std::sync::Arc;
#[derive(Clone, Debug)]
pub struct SystemRest {
pub cnfg: Arc<Config>,
pub system_cnr: Arc<SystemController>,
}
pub fn... |
use std::process::Command;
fn main() {
let output = Command::new("sh")
.arg("-c")
.arg("echo hello")
.output()
.expect("failed to execute process");
let hello = output.stdout;
println!("{:?}", hello);
}
|
extern crate bbb_core;
use bbb_core::parser::*;
use bbb_core::expr::Expr::*;
use bbb_core::numeral::Numeral::*;
use bbb_core::ops::*;
use bbb_core::ops::UnOp::*;
#[test]
fn number_parse_test() {
let e = "1";
assert_eq!(
parse(e),
Ok(Num(Int(1)))
);
let e = "-1";
assert_eq!(
... |
use std::{
path::Path,
collections::HashSet,
marker::PhantomData,
time::{Instant, Duration},
};
use ocl::{self, prm, builders::KernelBuilder};
use ocl_include::{Hook, MemHook, ListHook};
use crate::{
prelude::*,
scene::Scene,
view::View,
Context,
process::Program,
buffer::Re... |
pub use self::connection::AvCaptureConnection;
pub use self::delegate::AvCaptureVideoDataOutputSampleBufferDelegate;
pub use self::device::AvCaptureDevice;
pub use self::input::{AvCaptureDeviceInput, AvCaptureInput, AvCaptureInputPort};
pub use self::output::{AvCaptureOutput, AvCaptureVideoDataOutput};
pub use self::se... |
extern crate montcart;
fn main() {
montcart::executar();
}
|
use txp::*;
use structopt::StructOpt;
use anyhow::*;
use std::path::PathBuf;
#[derive(Debug, StructOpt)]
#[structopt(name = "example", about = "An example of StructOpt usage.")]
struct Opt {
/// Input file
#[structopt(parse(from_os_str))]
input: PathBuf,
ext: Option<String>,
}
use std::fs::File;
use... |
pub mod strategies;
pub mod structs;
pub mod map; |
use tipb::expression::{Expr, ExprType};
use util::codec::Datum;
use util::xeval::evaluator;
use super::Result;
pub fn build_aggr_func(expr: &Expr) -> Result<Box<AggrFunc>> {
match expr.get_tp() {
ExprType::Count => Ok(box 0),
ExprType::First => Ok(box None),
ExprType::Sum => Ok(box Sum {... |
/*!
Part 1:
Count all valid passwords, example:
For the input "1-3 a: aabbcc"
`a` must appear `1` to `3` time in the password `aabbcc`
For this input, the result is false.
Part 2:
Count all valid passwords, example:
For the input "1-3 a: aabbcc"
`a` must appear in index `1` or `3` but not both of the password `aabbcc`... |
// Demonstrate adding a View to the draw-geometry example
// The camera can be controlled with the arrow keys
extern crate quicksilver;
use quicksilver::{
Result,
geom::{Circle, Line, Rectangle, Shape, Transform, Triangle, Vector},
graphics::{Background::Col, Color, View},
input::{Key},
lifecycle::... |
extern crate proc_macro;
extern crate proc_macro2;
#[macro_use]
extern crate quote;
#[macro_use]
extern crate syn;
use proc_macro::TokenStream;
mod euclid_matrix;
#[proc_macro_derive(EuclidMatrix)]
pub fn derive_euclid_matrix(input: TokenStream) -> TokenStream {
let input = syn::parse(input).unwrap();
euclid... |
#![feature(await_macro, async_await)]
#![feature(futures_api)]
mod consts;
pub mod listen;
mod heads;
mod codec;
mod client;
pub mod socks;
pub use self::consts::Command;
pub use self::client::connect_socks_to;
pub use self::client::udp::Socks5Datagram;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
... |
//! Internal macros for the Varisat SAT solver.
#![recursion_limit = "128"]
use std::fmt::Write;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{
parse_quote, punctuated::Punctuated, Attribute, Fields, Ident, Lit, LitStr, Meta,
MetaNameValue, Token,
};
use synstructure::decl_derive;
/// Get the doc ... |
#[doc = "Reader of register MMC_RX_INTERRUPT_MASK"]
pub type R = crate::R<u32, super::MMC_RX_INTERRUPT_MASK>;
#[doc = "Writer for register MMC_RX_INTERRUPT_MASK"]
pub type W = crate::W<u32, super::MMC_RX_INTERRUPT_MASK>;
#[doc = "Register MMC_RX_INTERRUPT_MASK `reset()`'s with value 0"]
impl crate::ResetValue for super... |
/*!
An application that list the month name of the selected locale. If you need inspiration see
https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
Requires the following features: `cargo run --example month_name_d --features "winnls textbox"`
*/
extern crate native_windows_gui as nwg;
extern crate nati... |
#[doc = "Reader of register CPUPR2"]
pub type R = crate::R<u32, super::CPUPR2>;
#[doc = "Writer for register CPUPR2"]
pub type W = crate::W<u32, super::CPUPR2>;
#[doc = "Register CPUPR2 `reset()`'s with value 0"]
impl crate::ResetValue for super::CPUPR2 {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use super::{
action_button::{ActionButton, ActionMsg, ActionType}, constants::IMAGE_PATH, styles::CustomButton,
};
use libkoompi::session::PowerManager;
use num_traits::FromPrimitive;
use std::path::PathBuf;
use std::ops::SubAssign;
use std::time::{Duration, Instant};
use iced::{
button, Align, Application, But... |
use std::io;
use std::io::prelude::*;
use std::collections::HashMap;
fn read_wire(wire: &Vec<String>) -> HashMap<(isize, isize), (u8, usize)> {
let mut map = HashMap::new();
let mut x = 0;
let mut y = 0;
let mut steps = 0;
for i in wire {
let mut chars = i.chars();
let d = chars.nex... |
use sdl2::pixels::Color;
use sdl2::rect::{Point, Rect};
use sdl2::render::{Canvas, Texture};
use sdl2::video::Window;
use vector2d::Vector2D;
use crate::sprite::Sprite;
pub struct Obstacle {
pub name: String,
pub width: u32,
pub height: u32,
pub position: Vector2D<f64>,
}
impl Obstacle {
pub fn ... |
fn main() {
let target = std::env::var("TARGET").unwrap();
if target.contains("darwin") {
println!("cargo:rustc-link-lib=framework=AppKit");
}
// if std::env::var("TARGET").unwrap().contains("-ios") {
// println!("cargo:rustc-link-lib=framework=UIKit");
// } else {
// print... |
use rocket::http::Status;
use rocket::request::Request;
use rocket::response;
use rocket::response::status;
use rocket::response::Responder;
use rocket_contrib::json::Json;
use serde_json::json;
use result::Error::*;
use result::{Error, ErrorPayload, ValidationError};
impl<'r> Responder<'r> for Error {
fn respond... |
use assert_cmd::Command;
use predicates::prelude::*;
use std::time::Duration;
#[tokio::test]
async fn test_logging() {
// Testing with all-in-one mode because it has the least amount of setup needed.
Command::cargo_bin("influxdb_iox")
.unwrap()
.args(["run", "all-in-one", "--log-filter", "info"... |
// Copyright 2017 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 super::envelope::Envelope;
use serde::{Deserialize, Serialize};
const DUTY_CYCLE: [[u8; 8]; 4] = [
[0u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8],
[0u8, 1u8, 1u8, 0u8, 0u8, 0u8, 0u8, 0u8],
[0u8, 1u8, 1u8, 1u8, 1u8, 0u8, 0u8, 0u8],
[1u8, 0u8, 0u8, 1u8, 1u8, 1u8, 1u8, 1u8],
];
#[derive(Serialize, Deserial... |
use rskafka_wire_format::error::ParseError;
use rskafka_wire_format::prelude::*;
pub trait KafkaResponse: WireFormatParse {
fn from_bytes(input: &[u8]) -> Result<Self, ParseError> {
Self::from_wire_bytes(input)
}
}
|
//! A module for downloading & finding repository urls for packages
//! from [package.elm-lang.org](https://package.elm-lang.org).
//!
//! For example, if we wanted to iterate over all elm library url's we could
//! do something like this:
//!
//! ```
//! get_elm_libs()?
//! .into_iter()
//! .map(|r| find_git_u... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
pub const ALTNUMPAD_BIT: u32 = 67108864u32;
pub const ATTACH_PARENT_PROCESS: u32 = 4294967295u32;
#[cfg(feature = "Win32_Foundation")]
#[inline]
pub unsafe fn AddConsoleAliasA<'a, Param0: ::w... |
#[macro_use]
pub mod emscripten;
pub mod console;
pub mod gl; |
use image::{Rgb, RgbImage};
use imageproc::drawing::draw_text_mut;
use rusttype::Font;
use rusttype::Scale;
pub fn text2image(text: String) -> image::RgbImage {
let font = Vec::from(include_bytes!("../assets/font/VL-Gothic-Regular.ttf") as &[u8]);
let font = Font::try_from_vec(font).unwrap();
let x_font_s... |
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
pub fn remquo(mut x: f64, mut y: f64) -> (f64, i32) {
let ux: u64 = x.to_bits();
let mut uy: u64 = y.to_bits();
let mut ex = ((ux >> 52) & 0x7ff) as i32;
let mut ey = ((uy >> 52) & 0x7ff) as i32;
let sx = (ux >> 63) != 0;
let sy = (uy >... |
use std::{env, fs::{self, ReadDir}, process, sync::{Arc, Mutex}, thread};
#[derive(Debug)]
pub struct Config {
pub query: String,
pub dir: ReadDir,
pub concurrently: bool,
}
impl Config {
pub fn new(mut args: env::Args) -> Result<Config, &'static str> {
args.next();
let query = mat... |
fn main() {
let number = 3;
if number != 0 {
println!("number was somthing other than zero");
}
next();
three();
four();
loop_example();
loop_print();
loop_iterator();
loop_revert();
}
fn next() {
let number = 6;
if number % 4 == 0 {
println!("number is... |
//! Test suite for the Web and headless browsers.
#![cfg(target_arch = "wasm32")]
extern crate wasm_bindgen_test;
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen_test]
fn pass() {
assert_eq!(ajrust::add(1, 1), 2);
}
#[wasm_bindgen_test]
fn simple() {
assert_eq!(ajrust... |
#[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::FMC {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... |
/*!
Provides `StackPtr`, an owned pointer to stack-allocated data. This lets you cast a value to an unsized type (e.g. trait object) while maintaining ownership and without doing a heap allocation with `Box`.
# Example Usage
```
#[macro_use]
extern crate stack_ptr;
use stack_ptr::StackPtr;
fn main() {
declare_st... |
use std::fs;
use std::fs::File;
use std::fs::OpenOptions;
use std::path::Path;
use super::Result;
use super::Luxo;
use std::path::PathBuf;
use std::io::Cursor;
use std::io::Read;
use std::io::Write;
use std::io;
use serde_json;
extern crate core;
extern crate fs2;
extern crate memmap;
extern crate byteorder;
use self... |
#[doc = "Reader of register ATCR2"]
pub type R = crate::R<u32, super::ATCR2>;
#[doc = "Writer for register ATCR2"]
pub type W = crate::W<u32, super::ATCR2>;
#[doc = "Register ATCR2 `reset()`'s with value 0"]
impl crate::ResetValue for super::ATCR2 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Sel... |
use data_types::{CompactionLevel, ParquetFile};
use parquet_file::ParquetFilePath;
/// A file classification specifies the parameters for a single compaction branch.
///
/// This may generate one or more new Parquet files. It includes the target [`CompactionLevel`],
/// the specific files that should be compacted toge... |
#[doc = "Reader of register EEFBR1"]
pub type R = crate::R<u32, super::EEFBR1>;
#[doc = "Writer for register EEFBR1"]
pub type W = crate::W<u32, super::EEFBR1>;
#[doc = "Register EEFBR1 `reset()`'s with value 0"]
impl crate::ResetValue for super::EEFBR1 {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
use crossterm::{style::Color, terminal::ClearType};
use std::ops::Range;
use std::{cell::RefCell, collections::VecDeque, rc::Rc};
use crate::{buffer::Buffer, Result};
mod cursor;
mod writer;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone)]
pub struct Printer<W: std::io::Write> {
pub writer: writer::Writer<W>,
... |
use eframe::egui::*;
/// Trait shared by everything that can be plotted.
pub trait PlotItem {
/// Function to turn the drawable item into Shapes.
fn paint(self, painter: &mut Painter, transform: &dyn Fn(&Pos2) -> Pos2);
}
/// Text positioned on the plot.
pub struct Text {
position: Pos2,
_rotation: f3... |
use super::{
IterStatus, PositionIterInternal, PyGenericAlias, PyIntRef, PyTupleRef, PyType, PyTypeRef,
};
use crate::common::lock::{PyMutex, PyRwLock};
use crate::{
class::PyClassImpl,
convert::ToPyObject,
function::OptionalArg,
protocol::{PyIter, PyIterReturn},
types::{Constructor, IterNext, I... |
fn main() {
let mut x = String::from("Hello");
let y = &mut x;
let z = &x; // NOT OK, y is alive
world(y);
f(z)
}
fn f(s : &String) {
println!("Length: {}", s.len())
}
fn world(s : &mut String) {
s.push_str(", world")
}
|
//* We represent pointers to Scheme values as static references. This has a few
//* implications:
//* 1. simple implementation
//* 2. naive allocation (=no GC) will leak lots of memory
//* 3. using an explicit garbage collector may be unsound if there is
//* nothing that prevents such references to be p... |
use regex::Regex;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
pub fn read_source(path: &str) -> Vec<String> {
let src_file = File::open(path).expect("Cannot read file");
let src_content = BufReader::new(src_file);
let mut fragments = Vec::new();
for line in src_content.lines() ... |
use std::io::{Read, Result as IOResult};
use crate::PrimitiveRead;
pub struct ModelHeader {
pub lods_count: i32,
pub lod_offset: i32
}
impl ModelHeader {
pub fn read(read: &mut dyn Read) -> IOResult<Self> {
let lods_count = read.read_i32()?;
let lod_offset = read.read_i32()?;
Ok(Self {
lods_c... |
use input_i_scanner::InputIScanner;
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
macro_rules! scan {
(($($t: ty),+)) => {
($(scan!($t)),+)
};
($t: ty) => {
_i_i.scan::<$t>() as $t
};
(($($t: ty),... |
#[macro_use]
extern crate clap;
#[macro_use]
extern crate maplit;
#[macro_use]
extern crate quick_error;
use structopt;
#[cfg(test)]
extern crate assert_fs;
use std::collections::HashMap;
use std::collections::HashSet;
use std::ffi::OsStr;
use std::io::Write;
use std::path::Path;
use std::process::exit;
use std::str... |
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io;
use std::io::Read;
fn main() {
let mut input = String::new();
io::stdin().read_to_string(&mut input).unwrap();
let mut joltages: HashSet<u8> = input.lines().map(|x| x.parse().unwrap()).collect();
let device_joltage = joltages.... |
use input_i_scanner::{scan_with, InputIScanner};
fn main() {
let stdin = std::io::stdin();
let mut _i_i = InputIScanner::from(stdin.lock());
let (n, m) = scan_with!(_i_i, (usize, usize));
let mut b = vec![vec![]; n];
for i in 0..n {
b[i] = scan_with!(_i_i, u64; m);
}
let ok = (0..... |
extern crate steerning;
use steerning::*;
use commons::math::*;
use geo::Point;
use ggez::conf::WindowMode;
use ggez::event::{self, EventHandler, KeyCode, KeyMods, MouseButton};
use ggez::graphics::Color;
use ggez::{graphics, timer, Context, ContextBuilder, GameResult};
use nalgebra::{Point2, Vector2};
use rand::prelu... |
pub fn build_shared_info(host: &str, path: &str) -> Vec<u8> {
let mut shared_info = vec![];
shared_info.extend_from_slice(&"hash_request_binding".as_bytes());
shared_info.extend_from_slice(&host.as_bytes());
shared_info.extend_from_slice(&path.as_bytes());
shared_info
}
|
#[doc = "Reader of register COUNT"]
pub type R = crate::R<u32, super::COUNT>;
impl R {}
|
use helpers::{HelperDef};
use registry::{Registry};
use context::{Context};
use render::{RenderContext, RenderError, Helper};
#[derive(Clone, Copy)]
pub struct RawHelper;
impl HelperDef for RawHelper {
fn call(&self, _: &Context, h: &Helper, _: &Registry, rc: &mut RenderContext) -> Result<(), RenderError> {
... |
use piston_window::{rectangle, Context, G2d};
use piston_window::types::Color;
use utils::*;
pub fn draw_pixel(color: Color, x_cord:i32, y_cord:i32, con:&Context, graphics:&mut G2d) {
let gui_x = i32_to_f64(x_cord);
let gui_y = i32_to_f64(y_cord);
rectangle(
color,
[gui_x, gui_y, PIXEL_S... |
/*
* Copyright (c) 2019 Jill Enke <jill.enke@gmail.com>
* All rights reserved.
* 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 limitatio... |
// This file is our crate root
// We need to link to these other crates
extern crate image;
extern crate num;
extern crate sdl2;
extern crate sdl2_sys;
extern crate sdl2_image;
extern crate sdl2_ttf;
// We export all these modules
// These are the modules we want main.rs to be able to access as public symbols
pub mod... |
use specs::World;
#[derive(Default)]
pub struct DeltaTime(pub f32);
pub fn add_delta_time_resource(world: &mut World) {
world.add_resource::<DeltaTime>(DeltaTime(0.05));
}
|
//! Byte sequence reader.
//!
//! Type Reader provides convenient functions to reading numbers and slices from a byte sequence.
extern crate byteorder;
use std::mem;
use std::io::{Cursor, Error, ErrorKind, Result};
use self::byteorder::{ByteOrder, ReadBytesExt};
use super::range::Range;
pub trait ByteReader<T> {
... |
use crate::context::*;
use crate::position::*;
use crate::types::*;
use crate::util::*;
use itertools::Itertools;
use jsonrpc_core::Params;
use lsp_types::*;
use std::collections::HashSet;
pub fn publish_diagnostics(params: Params, ctx: &mut Context) {
let params: PublishDiagnosticsParams = params.parse().expect("... |
// 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.
#[macro_use]
extern crate zerocopy;
fn main() {}
//
// Generic errors
//
#[derive(FromBytes)]
#[repr("foo")]
struct Generic1;
#[derive(FromBytes)]
#[re... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.