text stringlengths 8 4.13M |
|---|
// 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.
use {
failure::{Error, ResultExt},
fidl::endpoints::ClientEnd,
fidl_fuchsia_io::FileMarker,
fidl_fuchsia_netemul_guest::{
CommandLi... |
use serde::{
Deserialize,
Serialize,
};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Basic {
pub length: usize,
pub md5: String,
}
|
use std::{os};
fn main() {
let args: ~[~str] = os::args();
let mut it = args.iter().skip(1);
for it.advance() |e| {
print(*e+" ");
}
println("");
}
|
use crate::prelude::*;
#[repr(C)]
#[derive(Debug)]
pub struct VkPipelineColorBlendAttachmentState {
pub blendEnable: VkBool32,
pub srcColorBlendFactor: VkBlendFactor,
pub dstColorBlendFactor: VkBlendFactor,
pub colorBlendOp: VkBlendOp,
pub srcAlphaBlendFactor: VkBlendFactor,
pub dstAlphaBlendFa... |
/*
Copyright 2020 Timo Saarinen
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 in writing, software
d... |
use course4::week4::solution::solve;
fn main() {
solve();
}
|
extern crate chrono;
extern crate hyper;
extern crate retry_after;
use chrono::{Duration, UTC};
use hyper::header::Headers;
use retry_after::RetryAfter;
fn retry_after_delay() {
let mut headers = Headers::new();
headers.set(RetryAfter::Delay(Duration::seconds(300)));
// Should print "Retry-After: 300"
... |
// 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 ... |
//! Optimize query routing.
use std::collections::HashMap;
// use crate::{Error, Result};
use lp_modeler::dsl::{lp_sum, BoundableLp, LpContinuous, LpObjective, LpOperations, LpProblem};
use lp_modeler::solvers::{CbcSolver, SolverTrait};
use ndarray::{Array2, ArrayView2};
/// Represents techniques optimizing routing ... |
#![feature(custom_attribute)]
#[cfg(target_family = "unix")]
#[macro_use]
extern crate diesel;
#[cfg(target_family = "unix")]
#[macro_use]
extern crate diesel_codegen;
#[cfg(target_family = "unix")]
extern crate dotenv;
#[cfg(target_family = "unix")]
use diesel::prelude::*;
#[cfg(target_family = "unix")]
use diesel... |
// Copyright 2020-2021, The Tremor Team
//
// 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 agr... |
use aoc_runner_derive::{aoc, aoc_generator};
#[aoc_generator(day9)]
fn parse_input(input: &str) -> Vec<u64> {
input.lines().map(|v| v.parse::<u64>().unwrap()).collect()
}
fn has_sum(numbers: &[u64], target: u64) -> bool {
for i in 0..numbers.len() {
for j in 1..numbers.len() {
if i == j {
... |
//==============================================================================
// Notes
//==============================================================================
// mcu::input.rs
// Watcher and handler for a GPIO pin defined as an input
//=======================================================================... |
use std::collections::HashMap;
fn main() {
let mut number_list = vec![1,4,77,2,2,5,12,32,13,235,12,2,245,432,532,1,23,45,324,23,5,234,23,5,32];
number_list.sort(); // sort this to work out the median later
let mut total:f32 = 0 as f32;
let mut number_counts= HashMap::new();
// get the total
... |
use std::sync::Arc;
use proptest::strategy::Just;
use liblumen_alloc::erts::term::prelude::*;
use liblumen_alloc::erts::Node;
use crate::runtime::distribution::nodes;
use crate::erlang::list_to_pid_1::result;
use crate::test::strategy;
use crate::test::with_process;
#[test]
fn without_list_errors_badarg() {
ru... |
use core::fmt::{self, Debug, Display};
macro_rules! with_backtrace { ($($i:item)*) => ($(#[cfg(all(feature = "backtrace", feature = "std"))]$i)*) }
macro_rules! without_backtrace { ($($i:item)*) => ($(#[cfg(not(all(feature = "backtrace", feature = "std")))]$i)*) }
without_backtrace! {
/// A `Backtrace`.
///
... |
use actix_web::HttpResponse;
use actix_web::ResponseError;
use bigneon_db::utils::errors::DatabaseError;
use diesel::result::Error as DieselError;
use errors::AuthError;
use errors::*;
use lettre::smtp::error::Error as SmtpError;
use payments::PaymentProcessorError;
use reqwest::Error as ReqwestError;
use serde_json::E... |
pub use core::task::Waker as RawWaker;
use atomic::{Atomic, Ordering};
use intrusive_collections::{LinkedList, LinkedListLink};
use object_id::ObjectId;
use crate::prelude::*;
/// A waiter.
///
/// `Waiter`s are mostly used with `WaiterQueue`s. Yet, it is also possible to
/// use `Waiter` with `Waker`.
pub struct Wa... |
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 according to those terms.
use super::{DeclarationLi... |
use std::env;
use std::fs::read_to_string;
use std::io::BufReader;
use openaip::parse;
fn main() {
let args: Vec<_> = env::args().collect();
let content = read_to_string(&args[1]).unwrap();
let file = parse(&content).unwrap();
for airspace in file.airspaces.unwrap() {
println!("{:?}", airspac... |
extern crate strip_ansi_escapes;
use std::io;
use strip_ansi_escapes::Writer;
pub fn work() -> io::Result<()> {
let stdin = io::stdin();
let mut in_lock = stdin.lock();
let stdout = io::stdout();
let out_lock = stdout.lock();
let mut writer = Writer::new(out_lock);
io::copy(&mut in_lock, &mut ... |
extern crate cc;
use std::path::PathBuf;
fn main() {
let mut cxx = cc::Build::new();
cxx.cpp(true);
cxx.include("vendor/Horde3D/Source/Horde3DEngine");
cxx.include("vendor/Horde3D/Source/Shared");
cxx.include("vendor/Extensions");
cxx.warnings(false);
cxx.define("PLATFORM_MAC", "1");
... |
use actix;
use database::db::PgConnection;
pub struct AppState {
pub db: actix::Addr<PgConnection>,
} |
use crate::prelude::*;
#[repr(C)]
#[derive(Debug, Clone)]
pub struct VkSubresourceLayout {
pub offset: VkDeviceSize,
pub size: VkDeviceSize,
pub rowPitch: VkDeviceSize,
pub arrayPitch: VkDeviceSize,
pub depthPitch: VkDeviceSize,
}
|
/*
Primitive Types:
Integers: u8, i8, u16, i16, u32, i32, u64, i64, u128, i128
(these are different because they allocate the
number of bits of memory they take in)
( u = unsigned: no negative values )
( i = integers: can be pos and neg )
Floats: f32, f6... |
//! Caching of [`NamespaceSchema`].
mod memory;
pub use memory::*;
mod sharded_cache;
pub use sharded_cache::*;
pub mod metrics;
mod read_through_cache;
pub use read_through_cache::*;
use std::{collections::BTreeMap, error::Error, fmt::Debug, sync::Arc};
use async_trait::async_trait;
use data_types::{ColumnsByNam... |
use super::{utils::heap_object_impls, HeapObjectTrait};
use crate::heap::{
object_heap::HeapObject, DisplayWithSymbolTable, Heap, InlineObject, OrdWithSymbolTable,
SymbolTable,
};
use derive_more::Deref;
use itertools::Itertools;
use rustc_hash::FxHashMap;
use std::{
cmp::Ordering,
fmt::{self, Debug, Fo... |
use lazy_static::lazy_static;
pub use lighthouse_metrics::*;
lazy_static! {
pub static ref SLASHER_DATABASE_SIZE: Result<IntGauge> = try_create_int_gauge(
"slasher_database_size",
"Size of the LMDB database backing the slasher, in bytes"
);
pub static ref SLASHER_RUN_TIME: Result<Histogram>... |
use crate::grid::{Grid, Point};
use std::collections::{HashMap, HashSet};
use std::fs::File;
use std::io::{BufReader, Lines};
use std::str::FromStr;
pub fn part_1(input: &str) -> usize {
let mut grid = parse_to_grid(input);
println!("search for distance from 0,0 to {} {}", grid.xmax, grid.ymax);
let start ... |
use crate::quic_tunnel::connection;
use crate::Shutdown;
use anyhow::Result;
use std::net::SocketAddr;
use tokio::net::{TcpListener, TcpStream};
use tokio::sync::{broadcast, mpsc};
use tokio::time::{self, Duration};
use tracing::{error, trace};
/// TCP Server listener state.
/// which performs the TCP listening and in... |
use screeps_foreman::planner::*;
use screeps_foreman::visual::*;
use screeps_foreman::location::*;
use screeps_foreman::*;
use log::*;
use std::fs::File;
use std::path::Path;
use std::io::Read;
use serde::*;
use std::convert::*;
use image::*;
use std::time::*;
use std::collections::HashMap;
#[cfg(not(feature = "profile... |
/// Error created when initializing the Executor.
use failure::Fail;
#[derive(Debug, Fail)]
pub enum InitError {
#[fail(display = "must be compiled with --feature=cuda to use cuda")]
NeedsCudaFeature,
}
|
//! Optimizations are a necessity for Candy code to run reasonably fast. For
//! example, without optimizations, if two modules import a third module using
//! `use "..foo"`, then the `foo` module is instantiated twice completely
//! separately. Because this module can in turn depend on other modules, this
//! approach... |
use std::collections::HashMap;
const INPUT: &str = include_str!("./input");
fn part_1(input: &str) -> usize {
let sorted_arr = sort_input(input);
let (ones, threes) =
sorted_arr
.windows(2)
.fold((0, 0), |(ones, threes), w| match w[1] - w[0] {
1 => (ones + 1, th... |
use crate::stream::{Buf, BufMut, CodedInputStream, CodedOutputStream};
use crate::Result;
use std::cell::UnsafeCell;
use std::fmt::{self, Debug};
pub trait Message {
fn merge_from(&mut self, input: &mut CodedInputStream<impl Buf>) -> Result<()>;
fn write_to(&self, output: &mut CodedOutputStream<impl BufMut>) -... |
mod common;
#[test]
fn basic() {
let name = "my-app";
let cmd = common::basic_command(name);
common::assert_matches_path(
"tests/snapshots/basic.zsh",
clap_complete::shells::Zsh,
cmd,
name,
);
}
#[test]
fn feature_sample() {
let name = "my-app";
let cmd = common... |
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[cfg(feature = "Storage_AccessCache")]
pub mod AccessCache;
#[cfg(feature = "Storage_BulkAccess")]
pub mod BulkAccess;
#[cfg(feature = "Storage_Compression")]
pub mod Compression;
#[cfg(feature = "Storage... |
use regex::Regex;
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
pub fn count(input: impl BufRead) -> HashMap<String, usize> {
let re = Regex::new(r"\w+").unwrap();
let mut freqs = HashMap::new();
for line in input.lines() {
let line =... |
mod empty;
mod field;
pub trait Lens<T, U> {
fn with<V, F: FnOnce(&U) -> V>(&self, data: &T, f: F) -> V;
fn with_mut<V, F: FnOnce(&mut U) -> V>(&self, data: &mut T, f: F) -> V;
}
pub use empty::NoLens;
pub use field::Field;
|
pub struct Solution;
use self::Token::*;
use std::iter::Peekable;
use std::str::Bytes;
enum Token {
Plus,
Minus,
Times,
Divide,
Number(i32),
}
struct Tokens<'a> {
bytes: Peekable<Bytes<'a>>,
}
impl<'a> Tokens<'a> {
fn new(s: &'a str) -> Self {
Self {
bytes: s.bytes().... |
use crate::utils::{read_u16_vec, write_u16_vec};
use mila::{BinArchiveReader, BinArchiveWriter};
type Result<T> = std::result::Result<T, mila::ArchiveError>;
pub struct FE14CharacterView {
pub address: usize,
pub bitflags: Vec<u8>,
pub pid: String,
pub fid: Option<String>,
pub aid: Option<String>,... |
use std::io::Write;
use std::path::Path;
use std::process::{Child, Command, Stdio};
use std::{env, io};
fn main() {
loop {
print!("\u{279c} ");
io::stdout().flush().unwrap();
// Read line input
let mut input = String::new();
io::stdin().read_line(&mut input).unwrap();
... |
// Computes a^n by the right-to-left binary exponentiation algorithm
// Input: A number a and a list b(n) of binary digits b_I, ..., b_0
// in the binary expansion of a nonnegative integer n
// Output: The value of a^n
fn rl_binary_exponentiation(a: u8, b: &[u8]) -> u64 {
let mut term: u64 = a as u64; // initia... |
use scanner_proc_macro::insert_scanner;
#[insert_scanner]
fn main() {
let s = scan!(String);
let mut s: Vec<char> = s.chars().collect();
s.sort();
for ch in s {
print!("{}", ch);
}
println!();
}
|
use super::{
not::Not, passthrough::Passthrough, ActiveFilter, DynamicFilter, FilterResult, GroupMatcher,
LayoutFilter,
};
use crate::internals::{query::view::Fetch, storage::component::ComponentTypeId, world::WorldId};
/// A filter which always matches `true`.
#[derive(Debug, Clone, Default)]
pub struct Any;
... |
//! A `Constant` holds a single value.
use crate::Error;
use num_bigint::{BigInt, BigUint, ToBigInt};
use num_traits::{FromPrimitive, One, ToPrimitive, Zero};
use serde::{Deserialize, Serialize};
use std::cmp::Ordering;
use std::fmt;
use std::ops::*;
/// A constant value for Falcon IL
///
/// IL Constants in Falcon a... |
enum State {
/// Interpret characters as normal
Normal,
/// A backslash escape was detected
Escape,
/// \x was detected
Hex1,
/// First digit was parsed
Hex2,
}
fn decode(source: &[u8]) -> Vec<u8> {
use State::*;
let mut state = Normal;
let mut buf = Vec::new();
let mut ... |
use std::future::Future;
use std::pin::Pin;
#[cfg(feature = "sgx")]
use std::prelude::v1::*;
use std::sync::atomic::{AtomicU64, Ordering};
#[cfg(not(feature = "sgx"))]
use std::sync::Mutex;
#[cfg(feature = "sgx")]
use std::sync::SgxMutex as Mutex;
use std::task::{Context, Poll, Waker};
/// A counter for wait and wakeu... |
use std::os::unix::io::AsRawFd;
/// Is this stream an TTY?
#[cfg(not(target_os = "redox"))]
pub fn is_tty<T: AsRawFd>(stream: T) -> bool {
use libc;
unsafe { libc::isatty(stream.as_raw_fd()) == 1}
}
/// This will panic.
#[cfg(target_os = "redox")]
pub fn is_tty<T: AsRawFd>(_stream: T) -> bool {
unimpleme... |
#![recursion_limit = "1024"]
use std::env::var_os;
use std::sync::Arc;
use futures::try_join;
mod engine;
use engine::engine_builder::*;
use engine::resources::resource_manager::ResourceManager;
const WEB_SERVICE_ADDR: &str = "0.0.0.0";
const TICKS_PER_SECOND: u8 = 30;
const DEFAULT_PORT: &str = "8000";
#[tokio::ma... |
extern crate declarative_dataflow;
extern crate differential_dataflow;
extern crate timely;
use std::time::Instant;
use timely::Configuration;
use differential_dataflow::operators::Count;
use declarative_dataflow::plan::Join;
use declarative_dataflow::server::{Register, RegisterSource, Server};
use declarative_data... |
use memory::*;
pub struct Bus<'a> {
pub memory: &'a mut Memory,
}
impl Bus<'_> {
pub fn new(memory: &mut Memory) -> Bus {
Bus { memory: memory }
}
pub fn read_u8(&self, addr: u32) -> u8 {
self.memory.read_u8(addr.wrapping_sub(0x8000_0000) as u64)
}
pub fn read_... |
// error handling
use std::io;
use std::result;
use std::error;
use std::fmt;
pub type Result<T> = result::Result<T, CustomError>;
#[derive(Debug)]
pub enum CustomError {
Io(io::Error),
}
impl fmt::Display for CustomError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
... |
use crate::*;
const URL: &str = "https://api.zoom.us/v2/metrics/meetings?type=past&page_size=300";
#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
iss: String,
exp: usize,
}
pub fn get_ms_time() -> usize {
let start = SystemTime::now();
let since_the_epoch = start
.duration_since... |
use json_utils::json::JsMap;
use json_utils::json::JsValue;
pub fn js_value_eq(left: &JsValue, right: &JsValue) -> bool {
match (left, right) {
(JsValue::Null, JsValue::Null) => true,
(JsValue::Bool(left), JsValue::Bool(right)) => left == right,
(JsValue::String(left), JsValue::String(right... |
use gtk::*;
pub fn create_image() -> Image {
let image = Image::new();
image.set_halign(gtk::Align::Start);
image.set_valign(gtk::Align::Start);
image
}
pub fn create_window(application: &Application) -> ApplicationWindow {
let window = ApplicationWindow::new(application);
window.set_title("Mo... |
pub mod channel;
pub mod mutex;
pub mod rwlock;
pub mod atomic_counters; |
pub mod clippycheck;
|
//!
//! Create attribute objects using the `Attribute` enum.
//!
//!
//! Example
//! -------
//! ```
//! use proffer::*;
//!
//! let a = Attribute::from("#![be_cool]");
//!
//! let src_code = a.generate();
//! let expected = "#![be_cool]";
//! assert_eq!(norm_whitespace(expected), norm_whitespace(&src_code))
//! ```
u... |
// 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
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::GString;
use glib_sys;
use std::box... |
use crate::prelude::*;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Position {
pub x: f32,
pub y: f32,
pub rotation: euclid::Angle::<f32>,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Renderable {
pub index: usize,
pub template: Template,
}
#[derive(Clone, Copy, Debug, PartialEq)]... |
use std::cmp::{min, max};
impl Solution {
pub fn max_profit(prices: Vec<i32>) -> i32 {
if prices.len() <= 1 {
return 0;
}
let mut minum = prices[0];
let mut maxium = 0;
for v in prices {
maxium = maxium.max(v - minum);
minum = minum.min(v);... |
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
use std::time;
use md5;
use sha1::Sha1;
use crate::http::Context;
pub use self::ip_util::*;
mod ip_util;
/// Generate user's pwd. It's use SHA1 algorithm
pub fn pwd<P: Into<String>>(p: P) -> String {
let mut s = Sha1::new();
s.up... |
use fs_extra::dir::create;
use fs_extra::file::write_all;
use super::fixtures::{get_app_content, get_package_json, get_rollup, get_main, get_index_html, get_global_css, get_component_content, get_component_test, get_babel, get_jest};
use super::utils::{update_values_in_files};
pub fn generate_new_application(name: &st... |
use proconio::{input, marker::Bytes};
fn main() {
input! {
s: Bytes,
};
for b in s {
print!("{}", 1 - (b - b'0'));
}
println!();
}
|
use sdl2::pixels::Color as SdlColor;
use std::ops::{Add, AddAssign, Mul};
#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
pub struct Color {
r: u8,
g: u8,
b: u8,
}
impl Color {
#[allow(non_snake_case)]
pub const fn RGB(r: u8, g: u8, b: u8) -> Color {
Color { r, g, b }
}
pub const fn z... |
extern crate clap;
extern crate term_size;
#[macro_use] extern crate quick_error;
extern crate users;
extern crate size;
extern crate time;
use clap::{App, Arg};
mod core;
mod meta;
use crate::core::Core;
#[derive(Debug)]
pub struct Options {
display_all: bool,
display_long: bool,
}
fn main() {
let app... |
#[test]
fn scan_test() {
let iter = (0..10).scan(0, |sum, item| {
*sum += item;
if *sum > 10 {
None
} else {
Some(item * item)
}
});
assert_eq!(iter.collect::<Vec<i32>>(), vec![0, 1, 4, 9, 16]);
}
|
use std::cmp::{Ordering, PartialEq, PartialOrd};
use std::ops::{Add, Neg};
///Struct representing a Complex number
#[derive(Debug)]
pub struct Complex<T> {
pub re: T,
pub im: T,
}
impl<T> PartialEq for Complex<T>
where
T: PartialEq,
{
fn eq(&self, other: &Complex<T>) -> bool {
self.re == other.... |
pub struct Solution;
impl Solution {
pub fn min_window(s: String, t: String) -> String {
let s = s.as_bytes();
let t = t.as_bytes();
let mut balance = vec![0_isize; 128];
let mut count = 0;
for i in 0..t.len() {
let n = &mut balance[t[i] as usize];
if... |
#[derive(juniper::ScalarValue)]
struct ScalarValue;
fn main() {}
|
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
#[derive(Debug, Serialize, Deserialize)]
pub struct Message {
pub content: HashMap<String, String>,
}
impl Message {
pub fn new() -> Self {
Message {
content: HashMap::new(),
}
}
pub fn put(&mut self, k: S... |
extern crate proconio;
use proconio::input;
use proconio::marker::Chars;
fn main() {
input! {
(R, C): (usize, usize),
(sy, sx): (usize, usize),
(gy, gx): (usize, usize),
a: [Chars; R],
}
let (sy, sx) = (sy - 1, sx - 1);
let (gy, gx) = (gy - 1, gx - 1);
let mut d = ve... |
//! Re-exports from the `gen` submodules.
pub mod associated_types;
pub mod attribute;
pub mod r#enum;
pub mod field;
pub mod function;
pub mod generics;
pub mod r#impl;
pub mod module;
pub mod r#struct;
pub mod r#trait;
pub use associated_types::*;
pub use attribute::*;
pub use field::*;
pub use function::*;
pub use... |
//! Terminal I/O.
use std::mem::MaybeUninit;
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::thread;
use anyhow::{Context, Error};
use libc::STDOUT_FILENO;
use log::*;
use nix::ioctl_read_bad;
use terminfo::{capability as cap, expand};
use tokio::fs::File;
use tokio::io::{self, AsyncWriteExt, BufWriter};... |
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
fn main() {
let n: usize = parse_line().unwrap();
let pp: Vec<u64> = parse_line().unwrap();
let qq: Vec<u64> = parse_line().unwrap();
let mut a = 0;
let mut b = 0;
for (i, ... |
use std::io::Stdout;
use grapl_observe::{
metric_reporter::{
tag,
MetricReporter,
},
timers::{
time_fut_ms,
TimedFutureExt,
},
};
use rusoto_core::RusotoError;
use rusoto_s3::PutObjectError as InnerPutObjectError;
use rusoto_sqs::{
DeleteMessageError as InnerDeleteMe... |
//! Myers' diff algorithm.
//!
//! * time: `O((N+M)D)`
//! * space `O(N+M)`
//!
//! See [the original article by Eugene W. Myers](http://www.xmailserver.org/diff2.pdf)
//! describing it.
//!
//! The implementation of this algorithm is based on the implementation by
//! Brandon Williams.
//!
//! # Heuristics
//!
//! At ... |
use ::json_to_final_ast;
use ::spec_type_to_final_ast;
use ::backend::javascript::size_of::generate_size_of;
use super::super::builder::ToJavascript;
fn test_size_of(spec: &str, data: &str, result: &str) {
let ir = spec_type_to_final_ast(spec).unwrap();
let size_of = generate_size_of(ir).unwrap();
let mut... |
use actix_web::{get, post, web, App, HttpResponse, HttpServer};
use serde::{Serialize, Deserialize};
use hello_world::customer_service::CustomerService;
use std::sync::Arc;
use hello_world::event_publishing::DomainEventPublisher;
use hello_world::mysql_util::new_connection_pool;
#[derive(Serialize, Deserialize)]
stru... |
#[doc = "Reader of register AHB4ENR"]
pub type R = crate::R<u32, super::AHB4ENR>;
#[doc = "Writer for register AHB4ENR"]
pub type W = crate::W<u32, super::AHB4ENR>;
#[doc = "Register AHB4ENR `reset()`'s with value 0"]
impl crate::ResetValue for super::AHB4ENR {
type Type = u32;
#[inline(always)]
fn reset_va... |
use super::atom;
use crate::error::Error;
use std::io::{Cursor, Read};
use tokio::io::AsyncReadExt;
#[derive(Debug, Eq, PartialEq)]
pub enum Packet {
Handshake(Handshake),
HandshakeRequest(HandshakeRequest),
Ping(Ping),
}
pub async fn read<S: AsyncReadExt + Unpin>(source: &mut S) -> Result<Packet, Error... |
use crate::ecmult::ECMultContext;
use crate::field::Field;
use crate::group::{Affine, Jacobian};
use crate::{util, Error, Message, PublicKey, Scalar, ECMULT_CONTEXT};
use digest::{Digest, Input};
use sha2::Sha256;
/// A Schnorr signature.
pub struct SchnorrSignature {
pub r: Scalar,
pub s: Scalar,
}
impl Schn... |
use rand::{random, Rng};
use std::sync::Arc;
pub type SimTime = u64;
pub const TICKS_PER_SECOND: SimTime = 1;
pub const MS_PER_TICK: SimTime = 1000 / TICKS_PER_SECOND;
pub trait SimRng {
fn random(&self) -> f64;
fn random_from_range(&self, low_inclusive: i64, high_exclusive: i64) -> i64;
}
stru... |
#[allow(unused_imports)]
use crate::naive::solve_naive;
#[allow(unused_imports)]
use crate::util::{read_data, bench};
#[allow(unused_imports)]
use crate::xsort::xsort_par;
#[allow(unused_imports)]
use crate::boxing::boxing_ser;
mod util;
mod naive;
mod xsort;
mod boxing;
fn main() {
println!("Welcome to Rust gym ... |
use crate::extractors::amp_spectrum;
pub fn compute(signal: &Vec<f64>) -> Vec<f64> {
let amp_spec: Vec<f64> = amp_spectrum::compute(signal);
let pow_spec: Vec<f64> = amp_spec.iter().map(|bin| bin.powi(2)).into_iter().collect();
return pow_spec;
}
#[cfg(test)]
mod tests {
use super::compute;
use ... |
use color_eyre::{
eyre::{eyre, Report, Result, WrapErr},
Section,
};
use reqwest::header::{HeaderMap, HeaderValue, ACCEPT};
use serde::{Deserialize, Serialize};
use tokio::{runtime::Handle, task};
use crate::nix::{NixLicense, NixPackage, NixPackageMeta};
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq, Se... |
extern crate uarc_emu as ue;
fn main() {
}
|
use super::minimax::*;
use super::alphabeta::*;
use super::types::*;
use crate::game::*;
pub fn next_turn(game: &Game, ai_config: &AIConfig) -> AITurnRes {
let start_time = instant::Instant::now();
let res = if ai_config.algorithm == Algorithm::AlphaBeta {
alphabeta(
&game,
0,
-f32::INFINITY... |
use test_win32_class_factory::*;
use windows::core::*;
use Windows::Foundation::*;
use Windows::Win32::Foundation::BOOL;
use Windows::Win32::System::Com::IClassFactory;
#[implement(Windows::Foundation::{IClosable, IStringable})]
struct Object();
#[allow(non_snake_case)]
impl Object {
pub fn ToString(&self) -> Res... |
use serde::{Deserialize, Serialize};
use std;
use std::fmt;
use std::sync::Arc;
use utils::*;
use crate::ir;
/// A fully specified size.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct Size {
factor: u32,
params: Vec<Arc<ir::Parameter>>,
max_val: u32,
}
impl Size {
/// Crea... |
use alloc::{string::String, sync::Arc, vec::Vec};
use core::sync::atomic::AtomicBool;
use serde::Deserialize;
use crate::{
commands::{Command, RunnableContext},
context::CommandRegistry,
error::ShellError,
evaluate::{CallInfo, Value},
parser::syntax_shape::SyntaxShape,
shell::Shell,... |
use cast::i8;
use encoding::{all::WINDOWS_1252, DecoderTrap, Encoding as _};
use enum_ordinalize::Ordinalize;
use raw_seeders::{Literal, LittleEndian, SerdeLike};
use serde::{de, ser};
use serde_seeded::{seed, seeded};
use std::{borrow::Cow, fmt::Display, marker::PhantomData};
#[derive(Debug, seed, seeded)]
pub struct... |
//! https://docs.microsoft.com/en-us/windows/desktop/power/battery-information-str
#![allow(non_snake_case, clippy::unreadable_literal)]
use std::default::Default;
use std::mem;
use std::ops;
use std::str::{self, FromStr};
use crate::Technology;
use winapi::shared::ntdef;
pub const BATTERY_CAPACITY_RELATIVE: ntdef:... |
use std::fmt;
use super::TimeFormatter;
use num_bigint::BigInt;
#[derive(Debug)]
pub struct SolverResult {
pub result: BigInt,
pub time_taken: u64,
}
impl fmt::Display for SolverResult {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} {}", self.result, self.time_taken.format_as_... |
use std::thread;
use std::time::Duration;
use std::sync::mpsc;
fn main() {
// thread1();
// thread2();
// thread3();
// thread4();
// thread5();
// thread6();
// thread7();
// thread8();
dead_lock();
}
fn thread1() {
// This thread gets killed when the main thread exits
thread::spawn(|| {
fo... |
///
/// Holds GUI widgets
///
use std::collections::HashMap;
use gtk;
use gui;
pub struct ComponentStore<'a> {
components: HashMap<String, Box<gtk::WidgetTrait + 'a>>,
}
impl <'a>ComponentStore<'a> {
pub fn new() -> ComponentStore<'a> {
ComponentStore {
components: HashMap::new()
}
}
}
impl gui::Component... |
#[macro_use]
pub mod tree;
pub use self::canonize::Canonizer;
pub use self::trace::Tracer;
pub use self::translate::Translator;
mod canonize;
mod trace;
mod translate;
#[cfg(test)]
mod tests;
|
#[macro_use]
extern crate scan_fmt;
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let filename = "src/input.txt";
let file = File::open(filename).unwrap();
let reader = BufReader::new(file);
let mut fabric = HashMap::new();
let mut all_claim_ids ... |
use std::rc::Rc;
use std::sync::Arc;
use futures::{Future, IntoFuture, Poll};
pub use void::Void;
mod and_then;
mod and_then_apply;
mod and_then_apply_fn;
mod apply;
mod apply_cfg;
pub mod blank;
pub mod boxed;
mod cell;
mod fn_service;
mod fn_transform;
mod from_err;
mod map;
mod map_err;
mod map_init_err;
mod then... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.