text stringlengths 8 4.13M |
|---|
use crate::graph::SearchResult;
use crate::pool::get_pool;
use mysql::QueryResult;
use serde::Serialize;
#[derive(Serialize)]
pub struct FormattedResult {
success: bool,
links: Vec<LinkDetails>,
visited_count: u32,
}
pub fn result_getter(search_result: SearchResult) -> FormattedResult {
let mut format... |
use actix_web::dev::Server;
use actix_web::middleware::Logger;
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
use std::net::TcpListener;
use url::Url;
struct AppState {
redirect_url: Url,
}
async fn health_check() -> impl Responder {
HttpResponse::Ok()
}
async fn redirect(data: web::Data<App... |
use anyhow::Result;
use pgnparse::parser::PgnInfo;
use regex::Regex;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::thread;
use std::thread::JoinHandle;
use crate::args::ScanOpts;
use crate::blunder::Blunder;
use crate::config::{ACCURATE_DEPTH, BLUNDER_CENTIPAWN_LOSS, DEFAULT_DEPTH, NUM_MOVES_TO_SKIP};
us... |
//! Module containing account-related notification code.
use super::{send_email, NotificationError};
use crate::database::accounts;
use crate::utils;
use chrono::{Duration, Utc};
const EXPIRATION_DAYS: i64 = 3;
const EMAIL_BASE_PATH: &str = "http://localhost:8001/api/verify_email/";
/// Sends an email verification ... |
use std::{
convert::{TryFrom, TryInto},
time::Duration,
};
use serde::{Deserialize, Serialize};
use crate::{
error::{Error, Result},
selection_criteria::{ReadPreference, ReadPreferenceOptions, TagSet},
test::run_spec_test,
};
use super::{TestServerDescription, TestTopologyDescription};
#[derive(... |
use lazy_static::lazy_static;
use std::collections::HashMap;
use std::option::Option;
use super::utils;
lazy_static! {
static ref CONFIG: HashMap<&'static str, String> = {
let config = utils::config::read_config();
// println!("config = {:?}", config);
let mut m = HashMap::new();
... |
#[doc = "Register `LTDC_SRCR` reader"]
pub type R = crate::R<LTDC_SRCR_SPEC>;
#[doc = "Register `LTDC_SRCR` writer"]
pub type W = crate::W<LTDC_SRCR_SPEC>;
#[doc = "Field `IMR` reader - IMR"]
pub type IMR_R = crate::BitReader;
#[doc = "Field `IMR` writer - IMR"]
pub type IMR_W<'a, REG, const O: u8> = crate::BitWriter<'... |
use actix_multipart::Field;
use actix_web::web;
use actix_web::web::BytesMut;
use bytes::buf::{Buf, BufMut};
use bytes::Bytes;
use futures::TryStreamExt;
use mime::Mime;
use serde_json::Value as JsonValue;
use serde_json::{from_slice, Error as JsonError};
use std::io::{Error as IoError, Write};
use std::path::{Path, Pa... |
//! Support for Raft and kvraft to save persistent
//! Raft state (log &c) and k/v server snapshots.
//!
//! we will use the original persister.rs to test your code for grading.
//! so, while you can modify this code to help you debug, please
//! test with the original before submitting.
use std::{
fs::OpenOptions... |
macro_rules! err {
($($arg:tt)*) => (Err(std::fmt::format(format_args!($($arg)*))));
}
/// TryFrom is currently only in nightly
/// https://github.com/rust-lang/rust/issues/33417
/// maybe in 1.33 or 1.34
pub trait TryFrom<T>: Sized {
fn try_from(value: T) -> Result<Self, String>;
}
impl TryFrom<i32> for ... |
use super::Queriable;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
#[serde(transparent)]
pub struct DownloadLink {
pub locations: Vec<Location>,
}
#[allow(non_snake_case)]
#[derive(Debug, Serialize, Deserialize)]
pub struct Location {
pub name: St... |
#![cfg_attr(docsrs, feature(doc_cfg))]
#![allow(clippy::needless_doctest_main)]
//! craftping provides a `ping` function to send Server List Ping requests to a Minecraft server.
//!
//! # Feature flags
//!
//! - `sync` (default): Enables synchronous, blocking [`ping`](crate::sync::ping) function.
//! - `async-tokio`: E... |
#[doc = "Register `CDR` reader"]
pub type R = crate::R<CDR_SPEC>;
#[doc = "Field `RDATA_MST` reader - Regular data of the master ADC"]
pub type RDATA_MST_R = crate::FieldReader<u16>;
#[doc = "Field `RDATA_SLV` reader - Regular data of the slave ADC"]
pub type RDATA_SLV_R = crate::FieldReader<u16>;
impl R {
#[doc = ... |
//! Classifiers working on the input stream.
//!
//! - [`quotes`] contains the low-level [`QuoteClassifiedIterator`](`quotes::QuoteClassifiedIterator`)
//! computing basic information on which characters are escaped or within quotes.
//! - [`structural`] contains the [`StructuralIterator`](`structural::StructuralIterat... |
//! This example shows an example of interacting with a
//! `bash` shell session. It opens a `bash` session,
//! sends some command (`echo` and `ls`), and waits for `bash`
//! to respond. Then it closes the stdin stream by
//! calling `close()`, and waits for `bash` to exit.
use interactive_process::InteractiveProcess... |
use std::rc::Rc;
use std::path::Path;
use polodb_bson::{Document, ObjectId};
use super::error::DbErr;
use crate::Config;
use crate::context::DbContext;
use crate::{DbHandle, TransactionType};
use crate::dump::FullDump;
fn consume_handle_to_vec(handle: &mut DbHandle, result: &mut Vec<Rc<Document>>) -> DbResult<()> {
... |
use rand::Rng;
use std::collections::HashMap;
// use std::cmp::Ordering;
// use std::io;
// =
// use std::{cmp::Ordering, io};
// use std::io;
// use std::io::Write;
// =
// use std::io::{self, Write};
// std::collections::*;
fn main() {
let mut map = HashMap::new();
map.insert(1, 2);
let _secret_numbe... |
mod sponge;
struct Pair<K, V> {
key: K,
val: V,
}
enum Node<K, V> {
Leaf(Pair<K, V>),
Branch(Table<K, V>),
}
impl Atomic<Node<K, V>> {
/// Insert a key-value pair into the node without squeezing the sponge.
fn insert(&self, pair: Pair<K, V>) -> Option<V> {
// If the entry was empty, w... |
use super::{Asset, Processor};
use crate::bundler::Emitter;
use anyhow::format_err;
use log::trace;
use std::fs::File;
use std::io::{Seek, SeekFrom};
use std::path::Path;
use tempfile::tempfile;
use xml::reader::EventReader;
use xml::writer::EmitterConfig;
use xml::writer::XmlEvent as WriterEvent;
/// Simply copy file... |
// https://projecteuler.net/problem=9
/*
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which
a + b + c = 1000. Find the product abc.
*/
fn main() {
// smaalest c is 33... |
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate diesel;
#[macro_use] extern crate rocket;
#[macro_use] extern crate rocket_contrib;
use diesel::prelude::*;
use rocket::http::Method;
use rocket::Rocket;
use rocket_cors::{AllowedHeaders, AllowedOrigins, Cors, CorsOptions};
pub mod elo;
pub mod er... |
use crate::backend::Backend;
use crate::{
backend::Token,
examples::{self, Examples},
index::Index,
pages,
spy::Spy,
};
use patternfly_yew::*;
use yew::prelude::*;
use yew_router::prelude::*;
#[derive(Switch, Debug, Clone, PartialEq)]
pub enum AppRoute {
#[to = "/spy"]
Spy,
#[to = "/exa... |
use drogue_client::Context;
use drogue_cloud_service_api::auth::user::authn::{AuthenticationRequest, Outcome};
use drogue_cloud_service_api::auth::user::authz::{AuthorizationRequest, Permission};
use drogue_cloud_service_api::auth::user::{authz, UserInformation};
use drogue_cloud_service_common::client::UserAuthClient;... |
pub mod multipart;
pub mod ctx;
pub mod types;
pub mod config; |
use std::collections::HashMap;
use super::FactionId;
use super::components::{AttackSensor, CollisionHandle, Color, Hp, Pos, Shape};
use scaii_defs::protos::{Action, State, Viz};
use specs::{Entity, World, WriteStorage};
pub mod collision;
pub use self::collision::*;
// Recommended by ncollide
pub const COLLISION_... |
#[doc = "Register `AHBENR` reader"]
pub type R = crate::R<AHBENR_SPEC>;
#[doc = "Register `AHBENR` writer"]
pub type W = crate::W<AHBENR_SPEC>;
#[doc = "Field `DMAEN` reader - DMA clock enable bit"]
pub type DMAEN_R = crate::BitReader<DMAEN_A>;
#[doc = "DMA clock enable bit\n\nValue on reset: 0"]
#[derive(Clone, Copy, ... |
use std::time;
use rand;
use rand::distributions::{Weighted, WeightedChoice, IndependentSample};
use super::types::{SiteId, PunterId};
use super::map::{River, RiversIndex};
use super::graph::{Graph, GraphCache, EdgeAttr, StepCommand};
#[derive(Default)]
pub struct MonteCarloCache {
claimed_rivers: RiversIndex<Pun... |
///// chapter 2 "using variables and types"
///// program section:
//
fn main () {
let mut n = 0;
let mut m = 1;
let t = m; m = n; n = t;
println!("{} {} {}", n, m, t);
}
///// output should be:
/*
1 0 1
*/// end of output
|
pub mod scale;
pub mod max_f64; |
$NetBSD: patch-vendor_rustc-ap-rustc__target_src_spec_aarch64__be__unknown__netbsd.rs,v 1.6 2023/01/23 18:49:04 he Exp $
Add aarch64_be NetBSD target.
--- /dev/null 2021-04-26 00:02:43.147970692 +0200
+++ vendor/rustc-ap-rustc_target/src/spec/aarch64_be_unknown_netbsd.rs 2021-04-26 00:07:44.657579025 +0200
@@ -0,0 +1... |
use crate::commands::{RawCommandArgs, WholeStreamCommand};
use crate::errors::ShellError;
use crate::prelude::*;
pub struct Autoview;
#[derive(Deserialize)]
pub struct AutoviewArgs {}
impl WholeStreamCommand for Autoview {
fn name(&self) -> &str {
"autoview"
}
fn signature(&self) -> Signature {
... |
fn main() {
let _number = 12;
}
|
// A helper macro to log implement From for things
#[doc(hidden)]
#[macro_export]
macro_rules! impl_froms {
($e:ident: $($v:ident), *) => {
$(
impl From<$v> for $e {
fn from(it: $v) -> $e {
$e::$v(it)
}
}
)*
};
($e:i... |
use crate::classification::{
structural::{BracketType, Structural},
QuoteClassifiedBlock,
};
use std::ops::Deref;
const SIZE: usize = 64;
pub(crate) struct StructuralsBlock<B> {
pub(crate) quote_classified: QuoteClassifiedBlock<B, u64, SIZE>,
pub(crate) structural_mask: u64,
}
impl<B> StructuralsBloc... |
use super::commonjs::build_require;
use super::error::Result;
use duktape::prelude::*;
use std::path::Path;
use std::str;
//pub fn push_require_function(ctx: &Context) -> Result<()> {}
pub fn push_module_object<'a, T: AsRef<Path>>(
ctx: &'a Context,
path: T,
main: bool,
) -> Result<Object<'a>> {
let p... |
//! Backs up user data.
//! ```
//! USAGE:
//! backr [FLAGS] [OPTIONS] --destination <DESTINATION_PATH>
//!
//! FLAGS:
//! -a, --backup-all
//! Backup all files found, overriding the regex. Because of this, it conflicts with the regex option.
//!
//! -h, --help
//! Prints help information
//... |
use specs::*;
use types::*;
use super::config::*;
use protocol::PlaneType;
use systems::handlers::packet::KeyHandler;
use SystemInfo;
pub struct PredatorSpecial;
#[derive(SystemData)]
pub struct PredatorSpecialData<'a> {
pub config: Read<'a, Config>,
pub plane: ReadStorage<'a, Plane>,
pub energy: ReadStorage<'a... |
use std::fs::OpenOptions;
use std::path::Path;
use chrono::{DateTime, Datelike, Local};
use filetime::FileTime;
use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape};
... |
use std::f64::consts::PI;
use crate::ray::Ray;
use crate::vec3::Vec3;
pub struct Camera {
origin: Vec3,
horizontal: Vec3, // Horizontal vector from the left edge to the right edge
vertical: Vec3, // Vertical vector from the bottom edge to the top edge
lower_left_corner: Vec3,
}
impl Camera {
pu... |
use crate::quadoctree::{QuadOctreeNode, CollisionObj, traverse_quadoctree};
use crate::math::{dot_product, cross_product, add_vector};
use crate::draw::Vertex;
const EPSILON: f32 = 0.000001;
const MAX_POLY_COLLIDE: usize = 4;
pub struct CollisionResult {
pub triangle: Option<[f32; 3]>,
pub polygons: Vec<[f32; 3]>
}... |
extern crate pdf;
extern crate pdf_extract;
extern crate lopdf;
use std::env::args;
use std::time::SystemTime;
use std::fs;
use std::io::Write;
use pdf::file::File;
use pdf::print_err;
use pdf::object::*;
use pdf::content::*;
use pdf::primitive::Primitive;
fn add_primitive(p: &Primitive, out: &mut String) {
// p... |
use std::collections::HashSet;
use std::fs::File;
use std::io::{BufRead, BufReader};
use crate::util::time;
pub fn day9() {
println!("== Day 9 ==");
let input = "src/day9/input.txt";
time(part_a, input, "A");
time(part_b, input, "B");
}
fn part_a(input: &str) -> usize {
let mut visited: HashSet<(... |
use azure_core::prelude::*;
use azure_storage::blob::prelude::*;
use azure_storage::core::prelude::*;
use chrono::{Duration, Utc};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
// First we retrieve the account name and master key from environment variables.
let source_ac... |
#![allow(non_upper_case_globals)]
extern crate quickcheck;
extern crate quickcheck_macros;
use quickcheck::TestResult;
use quickcheck_macros::quickcheck;
#[quickcheck]
fn min(x: isize, y: isize) -> TestResult {
if x < y {
TestResult::discard()
} else {
TestResult::from_bool(::std::cmp::min(x,... |
extern crate encoding;
use std::fs::OpenOptions;
use std::io::Write;
use std::io;
use gateway::Gateway;
mod gateway;
mod protocol;
fn main() {
let mut g = Gateway::new();
g.connect();
}
|
mod round2; // Round 1/2 submission version(BLAKE-{28, 32, 48, 64})
mod round3; // Round 3 submission version(BLAKE-{224, 256, 384, 512})
|
use std::env::{home_dir, var_os};
use std::path::PathBuf;
pub fn env_init_file() -> Option<PathBuf> {
var_os("INPUTRC").map(PathBuf::from)
}
pub fn system_init_file() -> Option<PathBuf> {
Some(PathBuf::from("/etc/inputrc"))
}
pub fn user_init_file() -> Option<PathBuf> {
home_dir().map(|p| p.join(".inputr... |
use std::mem;
pub enum State {
Pending,
Reading(Vec<u8>),
Writing(Vec<u8>),
Closed
}
impl State {
pub fn mut_read_buf(&mut self) -> &mut Vec<u8> {
match *self {
State::Reading(ref mut buf) => buf,
_ => unreachable!()
}
}
// pub fn read_buf(&self) ->... |
// Copyright (c) 2018 The predicates-rs Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distr... |
extern crate sha2;
mod block;
mod blockchain;
mod utils;
use block::Block;
use blockchain::Blockchain;
fn main() {
let block = Block::genesis();
println!("{}", block);
}
|
use APP_INFO;
use app_dirs::{AppDataType, app_dir};
use error::*;
use std::fs::{self, File};
use std::io::{Read, Write};
use std::path::PathBuf;
use std::sync::mpsc;
use std::sync::Arc;
use super::users::Users;
use types::*;
pub struct SoftConnection<S: Read + Write> {
root: Option<PathBuf>,
cwd: String,
s... |
#[doc = "Reader of register DDRCTRL_MSTR"]
pub type R = crate::R<u32, super::DDRCTRL_MSTR>;
#[doc = "Writer for register DDRCTRL_MSTR"]
pub type W = crate::W<u32, super::DDRCTRL_MSTR>;
#[doc = "Register DDRCTRL_MSTR `reset()`'s with value 0x0004_0001"]
impl crate::ResetValue for super::DDRCTRL_MSTR {
type Type = u3... |
use std::str;
use super::*;
use swc_common::{BytePos, Span};
use swc_ecmascript::parser::{token::{Token, TokenAndSpan}};
use dprint_core::formatting::tokens::{TokenFinder as CoreTokenFinder, TokenCollection};
pub struct TokenFinder<'a> {
inner: CoreTokenFinder<LocalTokenCollection<'a>>,
file_bytes: &'a [u8],
}... |
use cursive::{align::*, views::*, view::*, theme::*, utils::markup::StyledString};
use super::super::State;
use crate::model::*;
pub fn task(state: State, task: Task) -> impl View {
let git_project = state.git_project.borrow();
let project = &git_project.projects()[state.selected_project.get()];
let tags_l... |
use crate::input;
#[derive(Default)]
pub struct DeltaTime(pub f32);
#[derive(Default)]
pub struct InputResource(pub input::Input);
|
mod errors;
use std::sync::mpsc;
use std::io::{self, Write};
use flubber::proto::{Message, *};
use irc::client::prelude::*;
use crate::errors::Error;
fn send_init_info() {
// send a init info to stdout
let init_info = InitInfo {
plugin_name: "irc".to_owned(),
plugin_version: Version(0, 1, 0),
protocol_versi... |
#![feature(panic_info_message)]
#![feature(alloc)]
#![feature(alloc_error_handler)]
#![no_std]
extern crate linked_list_allocator_no_lock;
extern crate neutron_star_rt;
#[macro_use]
extern crate alloc;
//extern crate alloc;
pub mod syscalls;
#[macro_use]
pub mod testing;
pub mod logging;
pub mod storage;
use core::al... |
use crate::State;
use std::collections::HashMap;
pub use firestore_grpc;
use firestore_grpc::{
tonic::{
metadata::MetadataValue,
transport::{Channel, ClientTlsConfig},
Request, Response, Streaming,
},
v1::{
firestore_client::FirestoreClient,
run_query_request::Quer... |
fn main() {
use std::io::{self, BufRead};
let stdin = io::stdin();
let mut freq_changes = Vec::new();
for frequency in stdin.lock().lines() {
freq_changes.push(frequency.unwrap().parse::<i32>().unwrap());
}
println!("{}", freq_changes.iter().sum::<i32>());
}
|
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - TIM12 control register 1"]
pub tim12_cr1: TIM12_CR1,
_reserved1: [u8; 0x02],
#[doc = "0x04 - TIM12 control register 2"]
pub tim12_cr2: TIM12_CR2,
#[doc = "0x08 - TIM12 slave mode control register"]
pub tim12_smc... |
use std::ops::{Add, Sub, Mul, Div};
/// 2D Vector
#[derive(Copy, Clone)]
#[allow(dead_code)]
pub struct Vec2
{
pub x: f32,
pub y: f32,
}
#[allow(dead_code)]
impl Vec2
{
/// Create a new 2D Vector
fn new(x: f32, y: f32) -> Vec2 { Vec2 { x: x, y:y } }
/// Creates a new 2D Vector setting all fields t... |
use alloc::boxed::Box;
use collections::vec::Vec;
use core::mem;
use arch::context::context_switch;
use arch::memory::Memory;
use drivers::pci::config::PciConfig;
use drivers::io::{Io, Mmio, Pio, PhysAddr};
use fs::KScheme;
use super::{Hci, Packet, Pipe, Setup};
pub struct Uhci {
pub base: usize,
pub irq... |
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
extern crate survey_generator;
use survey_generator::options::*;
use std::env::args;
use std::env::Args;
use std::process;
use std::fs::File;
use std::io::Error;
use std::io::Read;
use std::default::Default;
//use std::fmt::Descripti... |
// Copyright (C) 2018-2019 O.S. Systems Sofware LTDA
//
// SPDX-License-Identifier: MIT
use slog::{o, Drain};
use std::str::FromStr;
#[derive(Debug)]
pub(crate) enum Output {
Human,
Json,
}
impl FromStr for Output {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
... |
#![feature(platform_intrinsics)]
#![feature(portable_simd)]
use core::arch::x86_64::{
__m128i,
_mm_aesenc_si128,
_mm_aesenclast_si128,
_mm_aesdec_si128,
_mm_aesdeclast_si128,
};
use core_simd::{LaneCount, Simd, SimdElement, SupportedLaneCount};
pub trait SimdAes {
fn aes_enc(self, key: Self) -... |
use std::ops::Sub;
use chrono::{DateTime, Duration, Utc};
use sqlx::{
postgres::{PgPool, PgQueryResult},
query, query_as,
};
pub struct Guild<'a> {
pool: &'a PgPool,
guild_id: i64,
}
#[derive(Debug)]
pub struct Member {
pub id: i64,
pub last_daily: DateTime<Utc>,
pub coins: i64,
pub g... |
/*!
```rudra-poc
[target]
crate = "late-static"
version = "0.3.0"
[report]
issue_url = "https://github.com/Richard-W/late-static/issues/1"
issue_date = 2020-11-10
rustsec_url = "https://github.com/RustSec/advisory-db/pull/611"
rustsec_id = "RUSTSEC-2020-0102"
[[bugs]]
analyzer = "SendSyncVariance"
bug_class = "SendSy... |
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 multiset cross-join (Cartesian product) of the (possibly du... |
pub mod model;
pub mod repository;
pub mod schema;
|
use std::{
fmt,
marker::PhantomData,
num::NonZeroU32,
time::{Duration, Instant},
};
use mpi::{
collective::{CommunicatorCollectives, Root, SystemOperation, UserOperation},
datatype::Equivalence,
environment::Universe,
point_to_point::{Destination, Source},
request::{CancelGuard, Req... |
#[doc = "Register `SECCFGR1` reader"]
pub type R = crate::R<SECCFGR1_SPEC>;
#[doc = "Register `SECCFGR1` writer"]
pub type W = crate::W<SECCFGR1_SPEC>;
#[doc = "Field `TIM2SEC` reader - TIM2SEC"]
pub type TIM2SEC_R = crate::BitReader;
#[doc = "Field `TIM2SEC` writer - TIM2SEC"]
pub type TIM2SEC_W<'a, REG, const O: u8> ... |
use apllodb_test_support::setup::setup_test_logger;
use ctor::ctor;
#[ctor]
fn test_setup() {
setup_test_logger();
}
#[test]
fn test_html_root_url() {
version_sync::assert_html_root_url_updated!("src/lib.rs");
}
|
use std::collections::HashMap;
use std::sync::Arc;
use failure::Fallible;
use rpdf_lopdf_extra::DocumentExt;
use crate::data::Name;
use crate::font::{FontMap, LoadedFont};
use super::GraphicsState;
pub struct TextState {
char_spacing: f32,
word_spacing: f32,
horizontal_scaling: f32,
text_font: Vec<... |
extern crate rustc_serialize;
extern crate serde;
extern crate chrono;
extern crate roaring;
extern crate byteorder;
#[macro_use]
extern crate bitflags;
pub mod term;
pub mod token;
pub mod doc_id_set;
pub mod schema;
pub mod document;
pub mod segment;
pub mod similarity;
pub mod query;
pub mod collectors;
pub use te... |
// Copyright 2015 Corey Farwell
//
// 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 wr... |
use crate::fardel_state::{
get_fardel_by_global_id, get_fardel_by_hash, get_fardel_img, get_fardel_owner, get_fardels,
get_global_id_by_hash, get_number_of_fardels, get_sealed_status, get_total_fardel_count,
is_fardel_hidden, Fardel, get_fardel_unpack_count, is_fardel_removed,
};
use crate::msg::{
Comme... |
use crate::types::{OpaqueCast, OpaquePointer, Scm};
use std::cell::Cell;
#[derive(Debug, Default, PartialEq)]
pub struct ActivationFrame {
next: Cell<Option<&'static ActivationFrame>>,
slots: Vec<Scm>,
}
impl ActivationFrame {
pub fn new(size: usize) -> Self {
ActivationFrame {
next: C... |
use clap::{App, Arg};
pub fn build_cli() -> App<'static, 'static>{
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
App::new("List")
.version(VERSION)
.author("Michael Mezzina")
.about("List files in a directory")
.arg(Arg::with_name("all")
.short("a")
.long("all")
.help("lists all files ... |
//! This module defines a mechanism for type earasure simplar to `dyn Any`.
//!
//! This method allows storing and referencing values coming from a `DataBuffer` in other `std`
//! containers without needing a downcast.
//!
#![allow(dead_code)]
use std::any::{Any, TypeId};
use std::fmt;
use std::hash::{Hash, Hasher};
u... |
mod index;
mod id;
pub use self::index::index;
pub use self::id::id;
|
#![allow(non_snake_case, non_camel_case_types)]
use libc::{c_char, c_int, c_uchar};
use crate::mode_t;
extern "C" {
pub fn ssh_getpass(
prompt: *const c_char,
buf: *mut c_char,
len: usize,
echo: c_int,
verify: c_int,
) -> c_int;
pub fn ssh_get_hexa(what: *const c_... |
use regex::Regex;
use std::io::{self};
#[derive(Debug, Clone)]
struct Instruction {
letter: String,
number: i32,
}
#[derive(Debug, Clone)]
struct Point {
x: i32,
y: i32,
}
impl Point {
fn add(&mut self, other: &Point) {
self.x += other.x;
self.y += other.y;
}
fn abs(&self... |
use crate::{
BaseInterface, LinuxBridgeConfig, LinuxBridgeInterface, LinuxBridgeOptions,
LinuxBridgePortConfig, LinuxBridgeStpOptions,
};
pub(crate) fn np_bridge_to_nmstate(
np_iface: nispor::Iface,
base_iface: BaseInterface,
) -> LinuxBridgeInterface {
LinuxBridgeInterface {
base: base_ifa... |
use failure::Error;
use git2::{Cred, FetchOptions, RemoteCallbacks, Repository};
use git2::build::RepoBuilder;
use std::path::{Path, PathBuf};
#[derive(Debug, PartialEq)]
pub struct GitUrl {
// Cannot use real URLs here because of https://github.com/servo/rust-url/issues/220
pub url: String,
pub branch: Op... |
use crate::errors::{FormatError, SourceError};
use crate::input::{Formatter, SortOrder, Source};
use crate::{try_continue, try_continue_res};
use anyhow::Result;
use regex::Regex;
use std::fs;
use std::iter::{IntoIterator, Iterator};
use std::path::Path;
use std::vec::IntoIter;
use walkdir::IntoIter as WalkIter;
use wa... |
use std::mem;
pub(in super) unsafe fn extend_lifetime<'a, 'b, T>(t: &'a T) -> &'b T
where T: ?Sized {
mem::transmute::<&'a T, &'b T>(t)
}
pub(in super) unsafe fn extend_lifetime_mut<'a, 'b, T>(t: &'a mut T) -> &'b mut T
where T: ?Sized {
mem::transmute::<&'a mut T, &'b mut T>(t)
} |
use std::fs::File;
use std::io::prelude::*;
fn find_2_numbers_that_sum_to_2020(numbers: &Vec<i32>) {
for (i, a) in numbers.iter().enumerate() {
for b in &numbers[i+1..] {
if a + b == 2020 {
println!("{} * {} = {}", a, b, a * b);
}
}
}
}
fn find_3_numbers... |
use failure::Fallible;
mod de;
pub trait DocumentExt {
fn resolve_object<'a>(&'a self, obj: &'a lopdf::Object) -> Fallible<&'a lopdf::Object>;
fn deserialize_object<'de, T>(&'de self, obj: &'de lopdf::Object) -> Fallible<T>
where
T: serde::Deserialize<'de>;
}
impl DocumentExt for lopdf::Document... |
use crate::datastructures::{
AtomSpatial::{PointsTo, LS},
Entailment, Rule,
Spatial::SepConj,
};
/// Π | Σ |- Π' | Σ' ==> Π | S * Σ |- Π' | S * Σ'
pub struct Frame;
impl Rule for Frame {
fn predicate(&self, goal: &Entailment) -> bool {
goal.is_normal_form()
}
fn prem... |
use thiserror::Error;
#[derive(Error, Debug)]
pub enum BotError {
#[error("I/O error")]
IoError(#[from] std::io::Error),
#[error("Paese error")]
ParseError(#[from] toml::ser::Error),
}
|
use {Error, Result, atlas, cameras};
use std::fs::File;
use std::io::Read;
use std::path::Path;
use toml;
/// Configuration for the API.
///
/// All of the paths and other configurations required to drive the entire glacio api. This maps
/// (thanks to serde) onto a TOML configuration file.
#[derive(Clone, Deserialize... |
use libpulse_sys;
use ffi;
use time_event;
use *;
use std::mem;
#[allow(non_camel_case_types)]
type pa_once_cb_t = Option<unsafe extern "C" fn(m: *mut libpulse_sys::pa_mainloop_api, userdata: *mut ::libc::c_void)>;
fn wrap_once_cb<F: Fn(&MainloopApi, *mut ::libc::c_void)>(_: F) -> pa_once_cb_t {
assert!(mem::size... |
//! This module implements the search history. By recording all operations we perform, we can
//! restore the search to an earlier state by rewinding these operations. This is the central
//! mechanism we use to implement a branching search that does not make a copy of the current
//! search state every time it makes... |
pub mod user;
//pub mod user_provider;
pub use user::*;
pub mod character;
pub mod movie;
pub mod movie_character;
|
use crate::{ArgMatchesExt, ErrorKind, Result};
use clap::{App, Arg, ArgMatches};
use ronor::Sonos;
pub const NAME: &str = "pause";
pub fn build() -> App<'static, 'static> {
App::new(NAME)
.about("Pause playback for the given group")
.arg(crate::household_arg())
.arg(Arg::with_name("GROUP").help("Name of... |
use na::Vector2;
use serde::Serialize;
pub type Sample = Vector2<f32>;
pub type Data = Vec<Sample>;
#[derive(Serialize)]
pub struct SampleJson {
x: f32,
y: f32,
}
impl From<Sample> for SampleJson {
fn from(s: Sample) -> Self {
SampleJson { x: s[0], y: s[1] }
}
}
#[derive(Serialize)]
pub stru... |
fn main() {
println!("a+b={}",add(2.0,3.0));
}
/// Adds one to another
/// # Examples
/// ```
/// let x = add(1.0,2.0);
///
/// ```
fn add(a: f32, b: f32)-> f32 {
return a + b;
}
|
use anyhow::Context;
use rusqlite::Transaction;
pub(crate) fn migrate(transaction: &Transaction<'_>) -> anyhow::Result<()> {
let todo: usize = transaction
.query_row("SELECT count(1) FROM starknet_events", [], |r| r.get(0))
.context("Count rows in starknet events table")?;
if todo == 0 {
... |
macro_rules! L {
($str:literal) => {
$crate::LocalizedString::new($str)
};
}
mod commands;
mod dialogs;
mod menu;
mod tools;
mod ui;
use druid::{
theme, AppDelegate, AppLauncher, Application, Color, Command, Data, DelegateCtx, Env, Handled,
Lens, LocalizedString, Target, WindowDesc, WindowId,
... |
struct Nil;
struct Pair(i32, f32);
struct Point {
x: f32,
y: f32,
}
#[allow(dead_code)]
struct Rectangle {
p1: Point,
p2: Point,
}
fn rect_area(r: Rectangle) -> f32 {
let Rectangle {
p1: Point { x: x1, y: y1 },
p2: Point { x: x2, y: y2 },
} = r;
(x2 - x1) * (y2 - y1)
}
f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.