text stringlengths 3.09k 13.9k |
|---|
//! A model which contains 2 BagOfWords, one containing known spam, and the other known ham.
//! ```
//! # use rammer::{BagOfWords, HSModel};
//! let ham_bow = BagOfWords::from("hello there how are you");
//! let spam_bow = BagOfWords::from("I have an offer you won't be able to pass up!!!");
//! let model = HSModel::ne... |
use crate::{DualNum, DualNumFloat, StaticMat, StaticVec};
use num_traits::{Float, FloatConst, FromPrimitive, Inv, Num, One, Signed, Zero};
use std::fmt;
use std::iter::{Product, Sum};
use std::marker::PhantomData;
use std::ops::{
Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign,
}... |
use anyhow::{anyhow, Result};
use rspotify::{
client::{ApiError, Spotify},
model::{audio::AudioAnalysis, playing::Playing, track::FullTrack},
oauth2::{SpotifyClientCredentials, SpotifyOAuth},
};
use std::time::{Duration, Instant};
const REGULAR_TIMEOUT_THRESHOLD: Duration = Duration::from_secs(5);
pub str... |
///
/// Blitz Money
///
/// Backend of module for manange rules padronizations of imported fields
///
/// Copyright 2018 <NAME> <<EMAIL>>
///
use backend::storage::*;
use backend::contacts::*;
use backend::tags::*;
use backend::transactions::*;
use json::JsonValue;
#[derive(Default, Clone, Debug)]
pub struct Rule {
... |
/*
* Copyright 2019-2021 <NAME>
*
* 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 core::mem;
//use async_std::prelude::*;
use async_std::io::Result;
use async_std::net::{Shutdown, TcpStream};
use async_std::net::SocketAddr;
use async_std::sync::Arc;
use enum_map::{Enum, enum_map, EnumMap};
use futures::{AsyncReadExt, AsyncWriteExt};
use uuid::Uuid;
use crate::extensions::bytes::BytesExt;
use c... |
use ::lib::*;
use ::alloc::boxed::Box;
use crate::kernel::config::*;
use crate::kernel::mem::addr::*;
use crate::kernel::table::paging::*;
pub use crate::kernel::table::paging::Flags;
pub type Result<T> = core::result::Result<T, MapErr>;
pub const PAGE_SIZE: usize = PageTable::PAGE_SIZE;
#[derive(Copy, Clone, Debug)... |
use std::sync::atomic::{AtomicPtr, AtomicUsize, AtomicBool};
use std::sync::atomic::Ordering::{SeqCst};
use std::sync::{Mutex, Condvar};
use std::{mem, ptr};
use std::cell::{Cell};
use select::{_Selectable, WaitQueue, Payload};
use {Error, Sendable};
pub struct Packet<'a, T: Sendable+'a> {
// The id of this chann... |
#![allow(dead_code)]
use super::encoders::winansi;
use super::font::{get_font, Font};
use regex::Regex;
use std::io::Write;
#[derive(Debug, Clone)]
pub enum Tag {
Span,
Link { url: String },
Bold,
}
/// TextSpan contains a fragment of paragraph text,
/// that may have some attributes/tags.
#[derive(Debug... |
#![allow(non_snake_case)]
#![feature(backtrace)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate clap;
use clap::{Arg, ArgGroup, SubCommand};
use futures::channel::oneshot;
use std::error::Error;
type AnyError = Box<dyn std::error::Error>;
mod settings;
mod svn;
mod worktile;
mod endpoint;
mod win_service;
... |
#[doc = "Reader of register EM4WUPOL"]
pub type R = crate::R<u32, super::EM4WUPOL>;
#[doc = "Writer for register EM4WUPOL"]
pub type W = crate::W<u32, super::EM4WUPOL>;
#[doc = "Register EM4WUPOL `reset()`'s with value 0"]
impl crate::ResetValue for super::EM4WUPOL {
type Type = u32;
#[inline(always)]
fn re... |
/*
What follows is basically logic programming, i.e. kind of a Prolog
engine. A trait is considered to be a predicate. One abbreviates
"type T has trait P" as P(T).
The rules of a trait P consist of:
leaf: a list of facts,
clauses: a list of clauses of the form
P(type pattern) :- condition.
Example. Is "[1, 2] + ... |
use crate::util::{math::random_in_unit_disk, Point, Ray, Vec3};
use anyhow::Result;
const DEFAULT_FOCAL_LENGTH: f64 = 1.0;
#[inline]
fn degrees_to_radians(deg: f64) -> f64 {
deg * std::f64::consts::PI / 180.0
}
#[derive(Default)]
pub struct CameraBuilder {
height: Option<usize>,
width: Option<usize>,
... |
use crate::dirs;
use crate::fl;
use anyhow::Context;
use itertools::Itertools;
use std::collections::HashMap;
use std::fs::{self, OpenOptions};
use std::io::{self, Write};
const API_KEY: &str = "<KEY>";
lazy_static! {
static ref URL_ALPHA: String = {
format!(
"https://www.googleapis.com/webfon... |
use super::{models::CrateInfo, Crates, Meta, Owner, Owners, SearchResult};
pub use crate::database::{
schema::{accounts::dsl::*, crates::dsl::*},
Paginate,
};
use crate::{auth::AccountWithId, database::Database};
use anyhow::{bail, Context, Result};
use chrono::Local;
use diesel::{associations::HasTable, dsl::e... |
use again::RetryPolicy;
use chrono::{DateTime, NaiveDateTime, Utc};
use chrono_tz::Tz;
use lazy_static::lazy_static;
use regex::Regex;
use reqwest::{
header::{HeaderMap, HeaderValue},
Response,
};
use serde_json::Value;
use std::time::Duration;
pub trait Or {
/// Return `self` if it's not empty, otherwise ... |
#![type_length_limit = "4323264"]
use anyhow::Context;
use invoker::controller::JudgeRequestAndCallbacks;
use std::sync::Arc;
use tracing::{info, instrument, warn};
fn is_cli_mode() -> bool {
std::env::args().count() > 1
}
async fn start_request_providers(
cancel: tokio::sync::CancellationToken,
chan: asyn... |
use ::std::boxed::Box;
use ::pnet::datalink::{DataLinkReceiver, NetworkInterface};
use ::pnet::packet::ethernet::{EtherTypes, EthernetPacket};
use ::pnet::packet::ip::{IpNextHeaderProtocol, IpNextHeaderProtocols};
use ::pnet::packet::ipv4::Ipv4Packet;
use ::pnet::packet::ipv6::Ipv6Packet;
use ::pnet::packet::tcp::TcpP... |
// Copyright 2018-2020 Parity Technologies (UK) Ltd.
//
// 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 applicab... |
// Copyright (c) 2017 <NAME>
//
// 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 limitation the rights
// to use, copy, modify, merge, publish, distri... |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// 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 ... |
#![no_std]
#![feature(lang_items, core_intrinsics)]
use core::intrinsics;
use core::panic::PanicInfo;
#[panic_handler]
#[no_mangle]
pub fn panic(_info: &PanicInfo) -> ! {
unsafe { intrinsics::abort() }
}
#[lang = "eh_personality"]
#[no_mangle]
pub extern "C" fn rust_eh_personality() {}
extern crate rust_nes_emu... |
mod area;
mod group;
mod input;
mod section;
mod select;
mod validation;
pub use area::*;
pub use group::*;
pub use input::*;
pub use section::*;
pub use select::*;
use std::collections::BTreeMap;
pub use validation::*;
use crate::{Alert, Button, Type, WithBreakpoints};
use std::fmt::{Display, Formatter};
use yew::pr... |
// Copyright 2018 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 crate::serializer::{JsonSerializer, Serializer};
use crate::{AuthDb, AuthDbError, CredentialKey, CredentialValue};
use log::warn;
use std::collections... |
//! Module implementing logging for the application.
//!
//! This includes setting up log filtering given a verbosity value,
//! as well as defining how the logs are being formatted to stderr.
use std::borrow::Cow;
use std::collections::HashMap;
use std::env;
use std::io;
use ansi_term::{Colour, Style};
use isatty;
u... |
use std::cmp;
pub fn bin(byte: u8) -> String {
format!("{:#010b}", byte)
}
pub struct Packer {
_buffer: Vec<u8>,
_byteoffset: usize,
_bitoffset: usize,
}
impl Packer {
pub fn new() -> Packer {
Packer {
_buffer: Vec::new(),
_byteoffset: 0,
_bitoffset: 0,... |
//! Virtualize the Alarm interface to enable multiple users of an underlying
//! alarm hardware peripheral.
use core::cell::Cell;
use kernel::common::cells::OptionalCell;
use kernel::common::{List, ListLink, ListNode};
use kernel::hil::time::{self, Alarm, Time};
pub struct VirtualMuxAlarm<'a, A: Alarm<'a>> {
mux:... |
use crate::{
block::{BlockHeader, BlockTrait, BlockTxList},
block_proposal::{BlockProposal, BlockProposalTrie},
config::{ChainConfig, MinerConfig},
snapshot::Snapshot,
};
use chrono::Utc;
use futures::prelude::*;
use itertools::Itertools;
use slimchain_common::{
basic::{BlockHeight, H256},
error... |
use crate::{
visual::{
aabb_tree::{self, Node},
graphics::{PushConstants, PUSH_CONSTANT_RANGE},
},
Solid, SOLIDS_FRAGMENT, WHOLECANVAS_VERTEX,
};
use std::mem;
use wgpu::*;
const TEXTURE_FORMAT: TextureFormat = TextureFormat::Bgra8UnormSrgb;
const NO_OFFSET: u64 = 0;
const MAX_SOLIDS: u64 ... |
//! Serialize a JSON with the pretty WOF style or single line JSON.
use crate::utils::FloatFormat;
use crate::{JsonObject, JsonValue};
use json::codegen::Generator;
use std::io::{self, Result, Write};
struct WOFGenerator<'a, W> {
writer: &'a mut W,
dent: u16,
pretty: bool,
key: String,
}
impl<'a, W> WOFGenera... |
// Copyright 2020-2021 the Deno authors. All rights reserved. MIT license.
use crate::diagnostic::{LintDiagnostic, Position};
use once_cell::sync::Lazy;
use regex::Regex;
use std::collections::HashMap;
use swc_common::comments::Comment;
use swc_common::comments::CommentKind;
use swc_common::SourceMap;
use swc_common::S... |
use crossbeam_channel::{self, Sender, Receiver, select};
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};
use std::time::Duration;
use std::thread::{self, JoinHandle};
use std::collections::{HashMap};
const TIMER_SAMPLING_CHECK: u64 = 50; //ms
pub struct EventQueue<E> {
receiver: Receiver<E>,
priority_r... |
#[cfg(test)]
#[macro_use]
extern crate hex_literal;
pub mod api;
pub mod block;
pub mod blockchain;
pub mod crypto;
pub mod miner;
pub mod network;
pub mod transaction;
use clap::clap_app;
use crossbeam::channel;
use log::{error, info};
use api::Server as ApiServer;
use network::{server, worker, generator};
use std::... |
//
// Copyright 2018 rust-wallet developers
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agr... |
use super::ChartContext;
use crate::coord::CoordTranslate;
use crate::drawing::backend::{BackendCoord, DrawingErrorKind};
use crate::drawing::{DrawingAreaErrorKind, DrawingBackend};
use crate::element::{EmptyElement, IntoDynElement, MultiLineText, Rectangle};
use crate::style::{IntoFont, IntoTextStyle, ShapeStyle, Size... |
use peg::str::LineCol;
use super::Cst;
use crate::grammar;
macro_rules! make_rule {
( $($variant:ident,)* ) => {
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash)]
#[allow(non_camel_case_types)]
pub enum Rule {
$($variant),*
}
impl Rule {
pub fn par... |
use crate::MeshPipeline;
use crate::{DrawMesh, MeshPipelineKey, MeshUniform, SetMeshBindGroup, SetMeshViewBindGroup};
use bevy_app::Plugin;
use bevy_asset::{load_internal_asset, Handle, HandleUntyped};
use bevy_core_pipeline::Opaque3d;
use bevy_ecs::{prelude::*, reflect::ReflectComponent};
use bevy_reflect::{Reflect, T... |
use rand;
use rand::Rng;
pub struct CellularMap {
width: u32,
height: u32,
map: Vec<u8>,
}
pub enum EvolveStrategy {
Default, // The standard evolution rules.
Cleaning, // Aggressive cleaning. Remove a lot of "single" occupied tiles.
}
impl CellularMap {
/// Create a new `CellularMap` instan... |
use session::config::Options;
use std::fs;
use std::io::{self, StderrLock, Write};
use std::time::Instant;
macro_rules! define_categories {
($($name:ident,)*) => {
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ProfileCategory {
$($name),*
}
#[allow(nonstandard_... |
//! Memory profile of a DDlog program.
use fnv::FnvHashMap;
use std::time::Duration;
use std::fmt;
use std::cell::RefCell;
use std::cmp::{max};
use differential_dataflow::logging::DifferentialEvent;
use timely::logging::{TimelyEvent, OperatesEvent, ScheduleEvent, StartStop};
use sequence_trie::SequenceTrie;
thread_lo... |
//! OTG USB 2.0 FS serial port example using polling in a busy loop.
//!
//! Note: Must build with features "stm32l4x5 otg_fs" or "stm32l4x6 otg_fs".
#![no_main]
#![no_std]
extern crate panic_semihosting;
use cortex_m_rt::entry;
use stm32l4xx_hal::gpio::Speed;
use stm32l4xx_hal::otg_fs::{UsbBus, USB};
use stm32l4xx_h... |
use std::any::Any;
use std::cell::Cell;
use std::error::Error;
use std::fs::File;
use std::io::{Seek, SeekFrom, Write};
use std::os::unix::io::AsRawFd;
use std::os::unix::io::FromRawFd;
use std::rc::Rc;
use std::time::Duration;
use std::{io, thread};
use crossbeam_channel::select;
use os_pipe::{PipeReader, PipeWriter}... |
use super::*;
use std::convert::TryFrom;
use std::fmt::Debug;
use std::ops::{Deref, Range};
/// A rectangle with non-negative & non-NAN dimensions.
///
/// Do not base soundness assumptions on this definition of validity - `debug_assert_valid` can bypass checks.
#[derive(Clone, Copy, Debug, Default)]
pub struct Valid... |
use crate::client::{XCallbackClient, XCallbackResponse, XCallbackStatus};
use crate::x_callback_url::*;
use ::macos::appkit::*;
use ::macos::foundation::*;
use ::macos::{impl_objc_class, Id, ObjCClass};
use objc::declare::ClassDecl;
use objc::runtime::*;
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng... |
// Tifflin OS - login
// - By <NAME> (thePowersGang)
//
// Graphical user session root - Provides background, taskbar and menus
extern crate wtk;
extern crate async;
#[macro_use]
extern crate syscalls;
extern crate loader;
use syscalls::gui::KeyCode;
use wtk::ModifierKey;
macro_rules! imgpath {
($p:expr) => {conc... |
extern crate clap;
extern crate colored;
extern crate log;
extern crate log4rs;
extern crate strip_ansi_escapes;
use std::{
error::Error,
fmt,
io::{self, Cursor, Read, Seek, SeekFrom, Write},
panic,
sync::Mutex,
};
use self::{
clap::ArgMatches,
colored::{ColoredString, Colorize},
log::... |
/*!
`pubsys` simplifies the process of publishing Bottlerocket updates.
Currently implemented:
* building repos, whether starting from an existing repo or from scratch
* validating repos by loading them and retrieving their targets
* checking for repository metadata expirations within specified number of days
* refres... |
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use regex::Regex;
use bytes::Bytes;
use futures::channel::mpsc;
use futures::sink::SinkExt;
use futures::stream;
use futures::stream::StreamExt;
use httpbis::*;
use tokio::runtime::Runt... |
use super::params::Params;
use super::request::ifreq;
use crate::linux::address::Ipv4AddrExt;
use crate::result::Result;
use std::net::Ipv4Addr;
nix::ioctl_write_int!(tunsetiff, b'T', 202);
nix::ioctl_write_int!(tunsetpersist, b'T', 203);
nix::ioctl_write_int!(tunsetowner, b'T', 204);
nix::ioctl_write_int!(tunsetgroup... |
// Copyright 2017-2020 <NAME>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to ... |
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use serde::{Deserialize, Serialize};
use crate::errors::JsonRpcError;
use diem_json_rpc_types::{request::RawJsonRpcRequest, Id, JsonRpcVersion};
use std::sync::Arc;
use storage_interface::DbReader;
use tokio::task::JoinHandle;
use cra... |
use crate::raft::{Command, LogEntry, LogIndex, NodeId, TermIndex};
use base64::write::EncoderStringWriter;
use std::fmt::Debug;
use std::io::Cursor;
use std::marker::PhantomData;
#[derive(Debug)]
pub struct Storage<Cmd> {
session_key: u128,
last_log_index: LogIndex,
last_log_index_key: String,
current_... |
// Copyright (c) 2018-2020 MobileCoin Inc.
//! This module contains code intended to operate within an SGX enclave.
#![no_std]
#![deny(missing_docs)]
extern crate alloc;
use alloc::vec;
use alloc::vec::Vec;
use core::convert::TryFrom;
use failure::Fail;
use mc_attest_core::{
IntelSealed, ParseSealedError, Repo... |
use itertools::Itertools;
use lazy_static::lazy_static;
use regex::Regex;
use unicode_truncate::UnicodeTruncateStr;
mod sigfig;
pub fn is_logical(text: &str) -> bool {
// col_logical -l, T,F,TRUE,FALSE,True,False,true,false,t,f,1,0
lazy_static! {
static ref R: Regex =
Regex::new(r"^true$|^... |
use bevy::prelude::*;
//use heron::prelude::*;
#[derive(Component)]
struct Level {
pub name: String,
pub isLoaded: bool,
pub width: u32,
pub height: u32,
tiles: Vec<Tile>,
}
enum TileType {
None,
Floor,
Wall
}
struct Tile {
pub x: u32,
pub y: u32,
pub tile_type: TileTy... |
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
//
// 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 applicab... |
use clap::{App, Arg};
use gol_client::persistence::load_board::CellularAutomatonConfig;
use rayon::prelude::*;
use serde_json;
use std::collections::HashMap;
use std::fs;
fn main() {
let mut jsons = vec![
include_str!("../examples/tetris.json"),
include_str!("../examples/glider.json"),
incl... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
_reserved0: [u8; 0x78],
#[doc = "0x78 - Enable constant latency mode."]
pub tasks_constlat: crate::Reg<tasks_constlat::TASKS_CONSTLAT_SPEC>,
#[doc = "0x7c - Enable low power mode (variable latency)."]
pub tasks_lowpwr: crate::Reg<tasks... |
use cpython::exc::{RuntimeError, IndexError};
use cpython::{py_class, PyErr, PyResult, PyInt, PyBytes, PyList, ToPyObject};
use cpython::{Python, PyObject};
use edgeql_parser::position::InflatedPos;
py_class!(pub class SourcePoint |py| {
data _position: InflatedPos;
@classmethod def from_offsets(cls, data: P... |
use std::collections::HashMap;
use anyhow::Result;
use chrono::{Duration, NaiveDate, NaiveTime};
use reqwest::blocking;
use reqwest::Url;
use request::{Attendance, LiveAttendance};
use response::{Calendar, Data, HistoryRequest, Login, Response};
mod request;
pub mod response;
#[derive(Debug)]
pub struct Client {
... |
// Copyright (c) The Diem Core Contributors
// SPDX-License-Identifier: Apache-2.0
use std::collections::BTreeMap;
use anyhow::anyhow;
use itertools::zip_eq;
use consensus_types::{
common::Author, executed_block::ExecutedBlock, experimental::commit_vote::CommitVote,
};
use diem_crypto::ed25519::Ed25519Signature;... |
/*
Copyright 2021 JFrog Ltd
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 writi... |
use serialport::prelude::*;
use std::io::prelude::*;
use std::thread;
use std::time;
// MCU Information
const COM_PORT: &str = "COM5";
/// Built-in LED
const LED_BUILTIN: u8 = 13;
/// Prescaler used on TIMER1
const PRESCALER: u32 = 8;
/// MCU clock frequency
const FREQ: u32 = 16000000;
/// Shortest delay on TIMER1 wit... |
use super::DbContext;
use crate::{config::RsbpError, services::undo::UndoEntry, Result};
use chrono::NaiveDateTime;
use diesel::prelude::*;
use rsbp_rep::{models::MaMandant, schema::*};
/// Undo a dataset.
pub fn undo(db: &mut DbContext, or: &String, ac: &String) -> Result<()> {
let oo = UndoEntry::from_str::<MaMa... |
use serde::{Deserialize, Serialize};
use std::{
collections::BTreeMap,
env::{self, current_dir},
fs,
io::{Read, Write},
path::{Path, PathBuf},
};
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct ProjectSetting {
pub manager: String,
}
#[derive(Serialize, Dese... |
//! Module defining the public API of the Rhai engine.
pub mod eval;
pub mod run;
pub mod compile;
pub mod files;
pub mod register;
pub mod call_fn;
pub mod options;
pub mod limits;
pub mod events;
pub mod deprecated;
use crate::engine::Precedence;
use crate::tokenizer::Token;
use crate::{Engine, Identifier}... |
// Copyright 2020 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 futures::future::{ready, select, BoxFuture, Either, FusedFuture};
use futures::prelude::*;
use futures::task::{Context, Poll, Waker};
use slab::Slab;
u... |
use std::collections::HashMap;
use std::fs;
use std::io;
use std::ops::Range;
use std::path::{Component, Path, PathBuf};
use failure::{format_err, ResultExt};
use zip::ZipArchive;
use snips_nlu_ontology::BuiltinEntity;
use snips_nlu_utils::range::ranges_overlap;
use snips_nlu_utils::string::{substring_with_char_range... |
use ndarray;
use ndarray_ext::NdArray;
use op;
use ops;
use tensor::Tensor;
use Float;
pub struct SoftmaxCrossEntropy;
pub struct SparseSoftmaxCrossEntropy;
pub struct SparseSoftmaxCrossEntropyGrad;
pub struct SigmoidCrossEntropy;
pub struct LogSoftmax {
pub axis: isize,
}
impl<T: Float> op::Op<T> for LogSoftmax ... |
use super::*;
pub struct Chain {
pub transform: Mat3<f32>,
pub vertices: Vec<ColoredVertex>,
}
impl Chain {
pub fn new(
chain: batbox::Chain<f32>,
width: f32,
color: Color<f32>,
round_resolution: usize,
) -> Self {
Self::new_gradient(
chain
... |
use std::fs::File;
use std::fs;
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use std::path::Path;
use std::process::exit;
use std::str;
use std::str::FromStr;
use std::sync::{Arc, RwLock};
use std::thread;
use readconfig::Configuration;
struct Options {
address: String,
directory: String,
... |
// Copyright (C) 2020 <NAME> <<EMAIL>>
// This file is subject to the terms and conditions defined in
// file 'LICENSE', which is part of this source code package.
use anyhow::{anyhow, Result};
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::io::{stdin, BufRead};
use std::ops;
use std::str::Fr... |
use core::convert::TryInto;
use rayon::iter::{IndexedParallelIterator, ParallelIterator};
use rayon::slice::ParallelSliceMut;
use crate::decoder::choose_color_convert_func;
use crate::error::Result;
use crate::idct::dequantize_and_idct_block;
use crate::parser::{AdobeColorTransform, Component};
use crate::upsampler::... |
use std::fs::{create_dir_all, File};
use std::io::{self, BufWriter, ErrorKind, Write};
use std::path::PathBuf;
use crate::event_writer::event::What;
use crate::event_writer::summary::value::Value::SimpleValue;
use crate::event_writer::summary::Value;
use crate::event_writer::{EventWriter, Summary};
use std::time::{Sys... |
// cooking_topological_sort.rs
use std::collections::HashMap;
use std::hash::Hash;
use std::fmt::Display;
// 颜色枚举
#[derive(Debug, Clone, PartialEq)]
enum Color {
White, // 白色,未被探索
Gray, // 灰色,正被探索
Black, // 黑色,已被探索
}
// 课程点定义
#[derive(Debug, Clone)]
struct Vertex<T> {
key: T,
color: Color,
n... |
use std::convert::TryInto;
/// This implementation of segment tree is built on
/// an array of i32, and supports the following operation:
/// 1. given an index i, j, query the sum of array in range [i, j]
/// 2. given a range [x, y] and a diff, update all values of the array
/// in range by diff
/// Any range sum query... |
use rustc_index::vec::IndexVec;
use super::constraint::{ConstraintSet, Perm};
use super::context::{Ctxt, FuncSumm};
use super::{ConcretePerm, LTy, PermVar, Var};
/// Mark all sig variables that occur in output positions. An "output position" means the return
/// type of a function or the target of an always-mutable ... |
use js_sys::{ArrayBuffer, Uint8Array};
use web_sys::{BinaryType, MessageEvent, WebSocket};
use std::cell::RefCell;
use std::sync::Arc;
use std::collections::VecDeque;
use std::task::{Poll, Waker};
use futures_util::future::poll_fn;
use url::Url;
use wasm_bindgen::prelude::{Closure, JsValue};
use wasm_bindgen::JsCas... |
//! Module for built-in pixel data adapters.
use dicom_core::value::C;
use snafu::Snafu;
pub mod jpeg;
pub mod rle_lossless;
/// Error conditions when decoding pixel data.
#[derive(Debug, Snafu)]
#[non_exhaustive]
pub enum DecodeError {
/// A custom error occurred when decoding,
/// reported as a dynamic err... |
use crate::{
assert_empty,
catalog::{assert_len, Collection},
error::{ParseError, PdfResult},
objects::{Dictionary, Object, ObjectType},
Resolve,
};
#[derive(Debug, Clone, PartialEq)]
pub enum FileSpecification<'a> {
Simple(FileSpecificationString),
Full(FullFileSpecification<'a>),
}
impl<... |
//! Metric label.
//!
//! # References
//!
//! - [Data model](https://prometheus.io/docs/concepts/data_model/)
//! - [Metric and label naming](https://prometheus.io/docs/practices/naming/)
use atomic_immut::AtomicImmut;
use std;
use std::fmt;
use std::ops::Deref;
use {ErrorKind, Result};
/// Metric label.
///
/// A l... |
use super::eval::{Scope, StackTrace, ValRef, FuncResult};
use std::cell::RefCell;
use std::io;
use std::rc::Rc;
fn write_val<W>(w: &mut W, val: &ValRef, parent: String) -> Result<String, io::Error>
where
W: io::Write,
{
let name;
match val {
ValRef::None => {
name = parent;
... |
use crate::value::{ConcreteValueType, Value};
/// A trait implemented by a type to check if its values match its corresponding abi type (T). This
/// trait can be derived. e.g.:
///
/// ```ignore,rust
/// #[derive(AsValue, TestIsAbiCompatible)]
/// #[ir_name = "struct.MunTypeInfo"]
/// #[abi_type(abi::TypeInfo)]
/// p... |
// @TODO: uncomment once https://github.com/rust-lang/rust/issues/54726 stable
//#![rustfmt::skip::macros(class)]
#![allow(clippy::used_underscore_binding)]
#![allow(clippy::non_ascii_literal)]
#![allow(clippy::enum_glob_use)]
#[macro_use]
extern crate validator_derive;
extern crate validator;
mod generated;
mod pag... |
extern crate neon;
extern crate scanner_rust;
use std::str::from_utf8_unchecked;
use neon::prelude::*;
use scanner_rust::generic_array::typenum::U768;
use scanner_rust::ScannerAscii;
fn get(mut cx: FunctionContext) -> JsResult<JsObject> {
let mut sc: ScannerAscii<_, U768> = match ScannerAscii::scan_path2("/proc... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use naming_special_names_rust as naming_special_names;
use runtime::TypedValue;
use naming_special_names::user_attributes as ua;
/// A... |
#[derive(Clone, PartialEq, Message)]
#[derive(Serialize, Deserialize, Hash)]
pub struct Election {
#[prost(string, optional, tag="1")]
pub member_id: ::std::option::Option<String>,
#[prost(string, optional, tag="2")]
pub service_group: ::std::option::Option<String>,
#[prost(uint64, optional, tag="3"... |
extern crate all_crate_storage;
use std::io;
use std::env;
use std::path::Path;
use all_crate_storage::registry::registry;
use all_crate_storage::reconstruction::{CrateContentBlobs};
use all_crate_storage::hash_ctx::{HashCtx, get_digest_hex};
use all_crate_storage::crate_storage::{CrateSource, FileTreeStorage};
use se... |
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
extern crate gotham;
extern crate handlebars_gotham as hbs;
extern crate hyper;
extern crate serde;
extern crate serde_json;
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate maplit;
extern crate mime;
use gotham::state::State;
use gotham::http::response::create_response;
use gotham::handler::{NewHandl... |
extern crate proc_macro;
mod context;
use context::Context;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use syn::spanned::Spanned;
use syn::{parse_macro_input, DeriveInput};
fn scannable_impl(ctx: &mut Context, ast: &syn::DeriveInput) -> Option<TokenStream> {
let data = match &ast.data {
... |
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use crate::typing_env_return_info;
use crate::typing_make_type::TypeBuilder;
use crate::typing_per_cont_env::{PerContEntry, TypingPerCont... |
use ff::{Field, PrimeField};
use group::CurveProjective;
use pairing::Engine;
use crate::{domain, multi_thread};
use domain::Scalar;
use super::super::{key_pair, windows, parameters};
use parameters::Elements;
use key_pair::{KeyPairWires, FlatKeyPairWires};
use windows::BasedWindows;
pub struct Writer<'a, E: Engine>... |
// Copyright 2017 The Australian National University
//
// 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 applicab... |
mod command;
mod config;
mod git;
mod util;
use std::{path::PathBuf, process::Stdio};
use anyhow::{anyhow, Context};
use clap::Parser;
use config::Config;
use serde_derive::Serialize;
use tracing_subscriber::{EnvFilter, FmtSubscriber};
use crate::{
git::{Git, GitRev},
util::pid::PidLock,
};
const FERSK_ORIG... |
// Copyright (c) 2017 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be ... |
use crate::util::{bytes_from_hex, bytes_to_hex, deserialize_bytes, keccak256, serialize_bytes};
use ark_bn254::Fr as ArkField;
use ark_ff::{BigInteger as _, PrimeField as _};
use core::{
fmt::{Debug, Display},
str,
str::FromStr,
};
use ff::{PrimeField as _, PrimeFieldRepr as _};
use num_bigint::{BigInt, Sig... |
use std::fs;
use std::process::Command;
use cursive::traits::*;
use cursive::views::{Button, Dialog, DummyView, EditView, LinearLayout, SelectView, TextView};
use cursive::Cursive;
pub struct Symbols {
symbols: Vec<String>,
}
impl Symbols {
fn from_file(filename: &str) -> String {
fs::read_to_string(... |
mod block;
mod cell;
mod coord;
mod utils;
use block::Block;
use cell::Cell;
use coord::Coord;
use wasm_bindgen::prelude::*;
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
extern crate web_sys;
macro_rules! log {
( $( $t:tt )* ) => {
web_... |
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct ChannelId(usize);
impl ChannelId {
pub fn new(id: usize) -> ChannelId {
ChannelId(id)
}
}
#[derive(Debug)]
pub struct Channel {
pub id: ChannelId,
pub name: String,
pub text_color: [f32; 4],
}
impl Channel {
pub fn new(id: ChannelId,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.