text stringlengths 8 4.13M |
|---|
use std::str::FromStr;
use toml_datetime::*;
use crate::array_of_tables::ArrayOfTables;
use crate::table::TableLike;
use crate::{Array, InlineTable, Table, Value};
/// Type representing either a value, a table, an array of tables, or none.
#[derive(Debug)]
pub enum Item {
/// Type representing none.
None,
... |
/*
Gordon Adam
1107425
This is the main program though as it is getting over complex the plan is to change it to the server program
and also break it up
*/
#![feature(macro_rules)]
use std::io::net::udp::UdpSocket;
use std::io::net::ip::{Ipv4Addr, SocketAddr};
use std::collections::HashMap;
use std::num::SignedInt;
... |
//! Returns a new document whose `origin` is the `origin` of the current global object's associated
//! `Document`.
//!
//! ```elixir
//! case Lumen.Web.Document.new() do
//! {:ok, document} -> ...
//! :error -> ...
//! end
//! ```
use liblumen_alloc::atom;
use liblumen_alloc::erts::process::Process;
use liblume... |
pub mod board_groups;
pub mod grouprc;
pub mod group;
pub mod stone; |
extern crate piston_window;
extern crate sprite;
extern crate find_folder;
extern crate ai_behavior;
use piston_window::*;
use sprite::*;
use std::rc::Rc;
use ai_behavior::{
Action,
Sequence
};
fn main() {
let mut window: PistonWindow =
WindowSettings::new("Hello Piston!", [640, 480])
.exi... |
use rule::Rule;
#[test]
fn literal() {
let code = "y̆y̆y̆x̆";
let r: Rule<u64> = Rule::new(|_, l| {
assert_eq!(l, "y̆y̆y̆x̆");
Ok(7777u64)
});
r.literal("y̆y̆").literal("y̆").literal("x̆");
if let Ok(branches) = r.scan(&code) {
assert_eq!(branches[0], 7777u64)... |
#![feature(plugin)]
#![feature(proc_macro_hygiene, decl_macro)]
mod http;
mod udp;
extern crate ctrlc;
#[macro_use] extern crate rocket;
extern crate rocket_contrib;
extern crate serde_json;
#[macro_use] extern crate serde_derive;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use structopt::Struc... |
use std::io;
use std::mem;
use std::os::windows::io::AsRawHandle;
use std::str::Bytes;
use windows_sys::Win32::Foundation::HANDLE;
use windows_sys::Win32::System::Console::{
GetConsoleScreenBufferInfo, SetConsoleTextAttribute, CONSOLE_SCREEN_BUFFER_INFO,
FOREGROUND_BLUE as FG_BLUE, FOREGROUND_GREEN as FG_GREEN... |
// Copyright (C) 2019 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
//! Crate for handling SDP ([RFC 4566](https://tools.ietf.org/html/rfc4566))
//! session descriptions, including a parser and serializer.
//!
//! ## Seria... |
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - DES Key 3 LSW for 192-Bit Key"]
pub key3_l: KEY3_L,
#[doc = "0x04 - DES Key 3 MSW for 192-Bit Key"]
pub key3_h: KEY3_H,
#[doc = "0x08 - DES Key 2 LSW for 128-Bit Key"]
pub key2_l: KEY2_L,
#[doc = "0x0c - DES Key... |
pub fn task1( text : &str ) -> i32 { tasks(text ).0 }
pub fn task2( text : &str ) -> i32 { tasks(text ).1 }
pub fn tasks( text : &str ) -> (i32,i32) {
let mut level = 1;
let mut total_score = 0;
let mut total_garbage = 0;
let mut prev_ch = ' ';
let mut is_garbage = false;
for ch in text.chars(... |
use crate::clock::clock::Clock;
use std::sync::atomic::{AtomicI64, Ordering};
pub struct ArbitraryClock {
pub now: AtomicI64,
}
impl Clock for ArbitraryClock {
fn now(&self) -> i64 { self.now.load(Ordering::Relaxed) }
}
impl ArbitraryClock {
pub fn new() -> ArbitraryClock {
ArbitraryClock {
now: Atom... |
use std::{
fs::{create_dir_all, File},
io::prelude::Read,
io::Error,
io::Write,
path::Path,
};
use serde_json::{from_str, to_string};
use crate::credentials::{generate_mqtt_password, get_db_password_from_file};
use crate::APP_VERSION;
const BASE_DIRECTORY: &str = "/etc/BlackBox/";
const SETTINGS... |
extern crate rand;
extern crate time;
use std::f64::consts::PI;
use rand::Rng;
use time::precise_time_ns;
use std::env;
use std::fmt;
#[derive(Copy, Clone, PartialEq)]
struct Biquad {
b0: f64,
b1: f64,
b2: f64,
a1: f64,
a2: f64,
x1: f64,
x2: f64,
y1: f64,
y2: f64,
}
impl fmt::De... |
#[doc = "Reader of register OBR"]
pub type R = crate::R<u32, super::OBR>;
#[doc = "Reader of field `OPTERR`"]
pub type OPTERR_R = crate::R<bool, bool>;
#[doc = "Reader of field `RDPRT`"]
pub type RDPRT_R = crate::R<bool, bool>;
#[doc = "Reader of field `WDG_SW`"]
pub type WDG_SW_R = crate::R<bool, bool>;
#[doc = "Reade... |
use crate::{builtins::PyModule, PyRef, VirtualMachine};
pub use module::raw_set_handle_inheritable;
pub(crate) fn make_module(vm: &VirtualMachine) -> PyRef<PyModule> {
let module = module::make_module(vm);
super::os::extend_module(vm, &module);
module
}
#[pymodule(name = "nt", with(super::os::_os))]
pub(... |
use console::style;
use error::Error;
use std::fs;
use emoji;
use PBAR;
pub fn copy_from_crate(path: &str) -> Result<(), Error> {
let step = format!(
"{} {}Copying over your README...",
style("[5/7]").bold().dim(),
emoji::DANCERS
);
let pb = PBAR.message(&step);
let crate_readm... |
#![allow(unused_variables, dead_code)] // macros
/// Dbus macro for Layout code
use std::process::{Command, Stdio};
use ::ipc::utils::{parse_edge, parse_uuid, parse_direction, parse_axis, lock_tree_dbus};
use dbus::tree::MethodErr;
use ::layout::{Layout, commands as layout_cmd};
use rustwlc::{ResizeEdge, Point};
... |
use super::{Chunk, InterLink, LinkId, CHUNK_SIZE};
use rust_src::{a_star_search, dijkstra_search, Cost, Dir, Materials, Path, Point};
use std::collections::HashMap;
#[derive(Debug)]
pub struct HPAMap {
pub width: usize,
pub height: usize,
pub chunks: Vec<Vec<Chunk>>,
pub links: HashMap<LinkId, InterLink>,
pub flo... |
use std::io::{self, Error, ErrorKind};
use serialport::{SerialPort, ClearBuffer};
use std::time::Duration;
use std::convert::TryInto;
const ACK: u8 = 0x79;
const NACK: u8 = 0x1F;
#[derive(Eq, PartialEq)]
enum CommandResult {
Ack,
Nak,
}
pub struct Bootloader {
serial: Box<dyn SerialPort>,
supported... |
#![warn(
clippy::all,
clippy::complexity,
clippy::style,
clippy::perf,
clippy::nursery,
clippy::cargo
)]
pub mod chain;
pub mod history;
pub mod net;
pub mod producer;
mod client;
mod clients;
mod error;
pub use self::client::*;
pub use self::clients::*;
pub use self::error::*;
#[macro_expor... |
use Player;
use Result;
use BadMoveError;
use std::fmt;
pub struct Tile {
pub owner: Option<Player>,
position: u8,
}
impl Tile {
pub fn new(position: u8) -> Tile {
Tile {
position: position,
owner: None,
}
}
pub fn play_x(&mut self) -> Result<()> {
... |
pub mod blines;
pub mod cache;
pub mod ctags;
pub mod dumb_jump;
pub mod exec;
pub mod filter;
pub mod grep;
pub mod gtags;
pub mod helptags;
pub mod rpc;
|
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
//
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
use crate::{Metadata, Tag, VariationalAsset};
// simplified versions of methods for the benefit only of wasm_bind
#[wasm_bindgen]
impl VariationalAsset {
/// WASM-friendly version o... |
include! (
concat! (
env! ("OUT_DIR"),
"/serde_types.rs"));
// ex: noet ts=4 filetype=rust
|
use core::marker::PhantomData;
use digest::{
generic_array::{typenum::Unsigned, GenericArray},
BlockInput, Digest, ExtendableOutput, Update, XofReader,
};
/// Trait for types implementing expand_message interface for hash_to_field
pub trait ExpandMsg {
/// Expands `msg` to the required number of bytes in `... |
use std::collections::HashMap;
use rocket_contrib::Template;
#[get("/")]
fn index() -> Template {
Template::render("index", HashMap::<String, String>::new())
}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct CALLFRAMEINFO {
pub iMethod: u32,
pub fHasInValues: super::s... |
use crate::enumerate::EnumType;
use crate::message::Message;
use crate::stream::Buf;
use crate::{Error, Result};
use pecan_utils::codec;
use std::{ptr, usize};
macro_rules! impl_fixed {
($t:ident, $func:ident, $width:expr) => {
pub fn $func(&mut self) -> Result<$t> {
if self.read + $width > sel... |
#[doc = "Reader of register CR2"]
pub type R = crate::R<u32, super::CR2>;
#[doc = "Writer for register CR2"]
pub type W = crate::W<u32, super::CR2>;
#[doc = "Register CR2 `reset()`'s with value 0"]
impl crate::ResetValue for super::CR2 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
... |
use std::io::Read;
pub(crate) fn authentication_group() -> structopt::clap::ArgGroup<'static> {
structopt::clap::ArgGroup::with_name("authentication").required(true)
}
pub(crate) fn parse_authentication(
sas_token: Option<String>,
certificate_file: Option<std::path::PathBuf>,
certificate_file_password... |
//! mapbaddr, machine APB base address register
read_csr!(0xFC1);
/// Get APB peripheral base address
#[inline]
pub fn read() -> usize {
unsafe { _read() }
}
|
use crate::config;
use anyhow::Result;
use std::process::Command;
/// Print a tree of all tracked files. Relies on the `tree` utility.
pub fn tree() -> Result<()> {
Command::new("tree")
.arg(config::tittle_config_dir())
.arg("-aC")
.arg("--noreport")
.arg("-I")
.arg(".git*|tittle_config.json")
... |
use rocket::http::Status;
use rocket::request::{self, FromRequest, Request};
use rocket::response::Failure;
use rocket::Outcome;
use rocket::Route;
use rocket_contrib::Json;
use dotenv::dotenv;
use std::env;
use serde_derive::{Deserialize, Serialize};
use bcrypt::{hash, verify, DEFAULT_COST};
use frank_jwt::{decode,... |
//! Combine parsing, translation and compilation with a Standard ML compiler
use std::io;
use combine::*;
use combine::primitives::Error;
use parser;
use translator::*;
pub fn parse_and_translate<I, W>(source_code: I, output: &mut W) -> Result<(), ParseError<I>>
where
I: Stream<Item = char>,
W: io... |
pub struct SubRectangleQueries {
width: i32,
matrix: Vec<i32>,
}
impl SubRectangleQueries {
fn new(rectangle: Vec<Vec<i32>>) -> Self {
SubRectangleQueries {
width: rectangle[0].len() as i32,
matrix: rectangle.into_iter().flatten().collect::<Vec<i32>>(),
}
}
... |
//! This module contains code to translate from InfluxDB IOx data
//! formats into the formats needed by gRPC
use std::{collections::BTreeSet, sync::Arc};
use arrow::datatypes::DataType as ArrowDataType;
use futures::{stream::BoxStream, Stream, StreamExt};
use iox_query::exec::{
fieldlist::FieldList,
seriess... |
//! The BSD sockets API requires us to read the `ss_family` field before
//! we can interpret the rest of a `sockaddr` produced by the kernel.
use super::addr::SocketAddrStorage;
#[cfg(unix)]
use super::addr::SocketAddrUnix;
use super::ext::{in6_addr_new, in_addr_new, sockaddr_in6_new};
use crate::backend::c;
use crat... |
use crate::{list, List};
// conversions
macro_rules! ListIdent {
[] => {
$crate::list::base::Nil
};
[$name:ident $(, $names:ident)* $(,)?] => {
$crate::list::base::Cons { head: $name, tail: ListIdent![$($names),*] }
};
}
macro_rules! impl_convert_tuple_list {
($($generics:ident),+... |
extern crate failure;
#[macro_use]
extern crate failure_derive;
use failure::{Backtrace, Fail};
#[derive(Fail, Debug)]
#[fail(display = "Error code: {}", code)]
struct BacktraceError {
backtrace: Backtrace,
code: u32,
}
#[test]
fn backtrace_error() {
let err = BacktraceError {
backtrace: Backtrac... |
pub struct BinaryIndexedTree<T, U> {
data: Vec<T>,
calc: U
}
impl<T, U> BinaryIndexedTree<T, U>
where
T: Copy,
U: Fn(T, T) -> T
{
pub fn new(size: usize, e: T, calc: U) -> BinaryIndexedTree<T,U> {
let data = vec![e; size+1];
BinaryIndexedTree{ data, calc }
}
pub fn add(&mut self, index: ... |
use std::iter;
use super::{List, Node, Stack};
#[cfg(test)] mod test;
impl<T> List<T> {
pub fn iter(&self) -> Iter<T> {
Iter { next: self.head.as_ref().map(|head| &**head)
, len: self.len }
}
pub fn iter_mut(&mut self) -> IterMut<T> {
IterMut { next: self.head.as_mut().map(|h... |
use amethyst::{
input::is_close_requested,
winit::{Event, KeyboardInput, ModifiersState, VirtualKeyCode, WindowEvent},
};
/// Detect whether the program has been requested to close or if macOS quit
/// event has been entered.
pub fn is_exit_program(event: &Event) -> bool {
is_close_requested(&event) || is_... |
extern crate iron;
extern crate mount;
#[macro_use] extern crate juniper;
extern crate juniper_iron;
use std::env;
use mount::Mount;
use iron::prelude::*;
use juniper_iron::{GraphQLHandler, GraphiQLHandler};
use juniper::EmptyMutation;
mod models;
mod schema;
use models::{
System, DiskInformation, LoadAverage, M... |
use aes_gcm_siv::aead::consts::U32;
use aes_gcm_siv::aead::heapless::{consts::U128, Vec};
use aes_gcm_siv::aead::{generic_array::GenericArray, AeadInPlace, NewAead};
use crate::serial_log;
use aes_gcm_siv::Aes256GcmSiv;
pub fn test_encrypt() -> &'static str {
// Not implemented because I'm stupid
serial_log("... |
use pine::libs;
use pine::runtime::data_src::{Callback, DataSrc};
use pine::types::Float;
use pyo3::exceptions;
use pyo3::prelude::*;
use pyo3::types::PyList;
use pyo3::wrap_pyfunction;
use std::collections::HashMap;
struct PyCallbackObj<'p> {
pyobj: PyObject,
py: Python<'p>,
}
impl<'p> Callback for PyCallbac... |
use serde::{Deserialize, Serialize};
use serde_json::Result;
use std::cell::Cell;
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
use string_template::Template;
thread_local!(static OPTION_ID: Cell<usize> = Cell::new(0));
fn next_option_id() -> usize {
OPTION_ID.with(|id| {
let result ... |
//! # Naia Server
//! A server that uses either UDP or WebRTC communication to send/receive events
//! to/from connected clients, and syncs registered actors to clients to whom
//! those actors are in-scope.
#![deny(
missing_docs,
trivial_casts,
trivial_numeric_casts,
unsafe_code,
unstable_features... |
extern crate reqwest;
extern crate serde_json;
use std::fs::File;
use std::io::{BufReader, BufRead};
fn main() {
let key = read_file("accessKey.txt");
let group = read_file("groupNumber.txt");
let url = format!("https://api.groupme.com/v3/groups/{}", group);
let name = "eric";
let id = get_user_id(... |
extern crate matrix;
use matrix::prelude::*;
use std::collections::VecDeque;
use std::vec::Vec;
// Implements a breadth-first search traversal of a given graph
// Input: Graph g = <v, e>
// Output: Graph g with its vertices marked with consecutive integers in the
// order they are visited by the BFS traversal
fn ... |
pub mod binomial;
pub mod digits;
pub mod factorial;
pub mod fibonacci;
pub mod fraction;
pub mod helper;
pub mod modulo;
pub mod partition;
pub mod permutation;
pub mod primes;
pub mod square_roots;
|
// Generated by ./import-tests.sh
mod unittest;
mod unittest_arena;
mod unittest_drop_unknown_fields;
mod unittest_embed_optimize_for;
mod unittest_import;
mod unittest_import_lite;
mod unittest_import_public;
mod unittest_import_public_lite;
mod unittest_lite;
mod unittest_lite_imports_nonlite;
mod unittest_mset;
mod... |
/// Contoh implementasi alternative overloading method di rust
/// yaitu dengan menggunakan generik trait
///
// buat struk kosongan
struct Detector;
// buat generic trait
trait Detect<T> {
fn detect(input: T);
}
// implementasi trait untuk tipe integer 32
impl Detect<i32> for Detector {
fn detect(input: i32... |
extern crate dotenv;
#[macro_use] extern crate diesel;
#[macro_use] extern crate serde;
use std::io;
use dotenv::dotenv;
use actix_web::{middleware, web, App, HttpServer};
use diesel_migrations::run_pending_migrations;
mod db;
mod schema;
mod schema_graphql;
mod models;
mod handlers;
use crate::db::establish_conne... |
use serde_derive::{Deserialize, Serialize};
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Copy, Clone)]
pub enum AccountType {
Assets,
Liabilities,
Equities,
Revenue,
Expenses,
Gains,
Losses,
}
impl AccountType {
pub fn from_i32(value: i32) -> AccountType {
match value ... |
#[macro_use]
extern crate failure;
extern crate fnv;
#[macro_use]
extern crate lazy_static;
extern crate num_traits;
#[macro_use]
extern crate gc_arena;
pub mod compiler;
pub mod conversion;
pub mod function;
pub mod lexer;
pub mod opcode;
pub mod operators;
pub mod parser;
pub mod state;
pub mod string;
pub mod tabl... |
//! Functions for stuff
use std::cmp::Ordering::*;
use std::f32;
use std::str::from_utf8_unchecked;
use crate::evaluate;
use crate::hamming::*;
use crate::xor;
/// Finds the key for a cipher text that was encrypted with a one-byte key.
pub fn single_xor(encrypted: &[u8]) -> (String, u8, f32) {
let mut best_value... |
use std::fs;
use std::env;
use std::path::Path;
fn main() {
let tmp = match env::var("TEMP") {
Ok(name) => name,
Err(_e) => r#"C:\Users\susilo\AppData\Local\Temp"#.to_owned(),
};
let hello_rust = format!("{}\\hello_rust", tmp);
let _ = fs::create_dir(&hello_rust);
if Path::new(&hello_rust).exists... |
use crate::tile::Tile;
use crate::tile::TileType;
use std::slice::IterMut;
use std::slice::Iter;
pub struct World {
tiles: Vec::<Tile>,
width: usize,
height: usize
}
impl World {
pub fn new(width: usize, height: usize) -> World {
let mut tiles: Vec<Tile> = Vec::new();
for i in 0.... |
use anyhow::{bail, Context, Result};
use flate2::read::GzDecoder;
use fs_err::File;
use mailparse::parse_mail;
use regex::Regex;
use std::io::{BufReader, Read};
use std::path::{Path, PathBuf};
use zip::ZipArchive;
fn filename_from_file(path: impl AsRef<Path>) -> Result<String> {
Ok(path
.as_ref()
.... |
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn parse_http_generic_error(
response: &http::Response<bytes::Bytes>,
) -> Result<smithy_types::Error, smithy_json::deserialize::Error> {
crate::json_errors::parse_generic_error(response.body(), response.headers())
}
pub fn de... |
#![macro_use]
#[macro_export]
macro_rules! handle {
(_ in $init:expr, $exit:expr, {$($impl:tt)*}) => {
#[derive(Debug)]
pub struct Handle(());
static INITIALIZED: ::std::sync::atomic::AtomicBool =
::std::sync::atomic::AtomicBool::new(false);
impl Drop for Handle {
... |
use proconio::input;
fn main() {
input! {
a:i32,
}
println!("{}", a + (a * a) + (a * a * a));
}
|
#[macro_use]
extern crate serde_derive;
extern crate bincode;
extern crate hex_database;
#[cfg(target_arch = "wasm32")]
extern crate wasm_bindgen;
#[cfg(target_arch = "wasm32")]
#[macro_use]
extern crate cfg_if;
pub mod error;
pub mod objects;
#[cfg(target_arch = "wasm32")]
cfg_if! {
// When the `wee_alloc` fea... |
use std::io;
use std::path::{Path, PathBuf};
use std::process::Output;
use serde_json::json;
use rnc_test_utils::{temp_file_with, Jsonl};
fn expand(id_file: &Path, json_file: &Path, output: &Path) -> io::Result<Output> {
test_bin::get_test_bin("expand-urs")
.arg(id_file)
.arg(json_file)
.... |
use super::*;
#[derive(Clone, PartialEq, Default)]
pub struct PropertyKey {
pub fmtid: GUID,
pub pid: u32,
}
impl PropertyKey {
pub fn from_attributes<I: IntoIterator<Item = Attribute>>(attributes: I) -> Option<Self> {
attributes.into_iter().find(|attribute| attribute.name() == "PropertyKeyAttribu... |
use crate::api::Rest;
use crate::api::API;
use crate::client::*;
use crate::errors::*;
use crate::model::*;
#[derive(Clone)]
pub struct Market {
pub client: Client,
}
impl Market {
pub fn get_all_pairs(&self) -> Result<Pair> {
self.client.get(API::SerumRest(Rest::Pairs), None)
}
pub fn get_tr... |
use std::io::prelude::*;
use std::str::FromStr;
fn ans(mut t:Vec<i32>,i:Vec<(i32,i32)>) -> Vec<i32> {
for ii in i {
let a : usize = ii.0 as usize;
let b : usize = ii.1 as usize;
let s = t[a-1];
t[a-1] = t[b-1];
t[b-1] = s;
}
t
}
fn main() {
let s... |
//! The team namespace is responsible for the state of the team and for holding
//! the players in the game.
use std::collections::BTreeSet;
use world::world::Id;
use event::event::Event;
use traits::StateMachine;
#[derive(Debug, Clone, Hash)]
pub struct Team<'a> {
pub roster: BTreeSet<&'a Id>,
pub lineup: ... |
pub enum UserInput {
NumberInput(usize),
AbortCommand,
InvalidInput,
}
impl UserInput {
pub fn from_stdin() -> UserInput {
use std::io::stdin;
let mut number = String::new();
stdin().read_line(&mut number)
.expect("Failed to read line");
let number = number.... |
#[cfg(all(not(target_arch = "wasm32"), test))]
mod test;
use anyhow::*;
use liblumen_alloc::erts::exception;
use liblumen_alloc::erts::process::Process;
use liblumen_alloc::erts::term::prelude::*;
#[native_implemented::function(erlang:byte_size/1)]
pub fn result(process: &Process, bitstring: Term) -> exception::Resu... |
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
//
// Portions Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the THIRD-PARTY file.
/// The vsock `EpollH... |
#[doc = "Reader of register PUCRC"]
pub type R = crate::R<u32, super::PUCRC>;
#[doc = "Writer for register PUCRC"]
pub type W = crate::W<u32, super::PUCRC>;
#[doc = "Register PUCRC `reset()`'s with value 0"]
impl crate::ResetValue for super::PUCRC {
type Type = u32;
#[inline(always)]
fn reset_value() -> Sel... |
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// 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 ... |
use std::fs;
fn main() {
fs::create_dir("test1");
fs::remove_dir_all("test1");
} |
use wasm_bindgen::JsCast;
use web_sys::{HtmlCanvasElement, WebGlRenderingContext};
use crate::render::render_target::{RenderScene, RenderTarget};
use super::triangles::TriangleScene;
pub struct WebglRenderTarget {
canvas: HtmlCanvasElement,
context: WebGlRenderingContext,
}
impl WebglRenderTarget {
pub f... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct BackgroundDownloadProgress {
pub BytesReceived: u64,
pub TotalBytesToReceive: u64,
pub Status... |
mod de;
mod ser;
mod shared;
include!("../include/pub_from_to.rs");
|
pub const HEADER_SIZE: u32 = 0x70;
pub const STRING_ID_ITEM_SIZE: u32 = 0x04;
pub const TYPE_ID_ITEM_SIZE: u32 = 0x04;
pub const PROTO_ID_ITEM_SIZE: u32 = 0x0c;
pub const FIELD_ID_ITEM_SIZE: u32 = 0x08;
pub const METHOD_ID_ITEM_SIZE: u32 = 0x08;
pub const CLASS_DEF_ITEM_SIZE: u32 = 0x20;
// pub const MAP_ITEM_SIZE: u32... |
pub mod thompson;
|
//! Events.
/// An event emitted from the contract.
#[derive(Clone, Debug, cbor::Encode, cbor::Decode)]
pub struct Event {
/// Optional module name.
#[cbor(optional, default, skip_serializing_if = "String::is_empty")]
pub module: String,
/// Unique code representing the event for the given module.
... |
use super::Command;
use clap::ArgMatches;
use log::{error, info};
use std::{io, process};
pub fn run(matches: &ArgMatches, commands: &mut Vec<Command>) {
info!("Running DELETE subcommand");
if matches.is_present("all") {
println!("Are you sure you want to delete all entries? (y/n)");
let mut in... |
use super::{browser_info, env, Config, Pinboard, Runner, SubCommand, Tag};
use crate::cli::Opt;
use std::{thread, time};
use alfred::{Item, ItemBuilder, Modifier};
use alfred_rs::Data;
impl<'api, 'pin> Runner<'api, 'pin> {
// pub fn list(&self, cmd: SubCommand) {
pub fn list(&self, opt: Opt) {
let cmd... |
use std::pin::Pin;
use futures::{future, stream};
use juniper::graphql_subscription;
type Stream<'a, I> = Pin<Box<dyn futures::Stream<Item = I> + Send + 'a>>;
struct ObjA;
#[graphql_subscription]
impl ObjA {
async fn wrong(
&self,
#[graphql(default = [true, false, false])] input: [bool; 2],
... |
// Copyright 2016 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 std::path::PathBuf;
pub struct PackageUnify {}
impl PackageUnify {
pub fn from_path(path: PathBuf) -> String {
let mut package = "".to_string();
let path_iter = path.iter();
path_iter.for_each(|str| {
package = format!("{}.{}", package, str.to_str().expect("error path"));
... |
#![deny(missing_docs)]
//! Stringcheck provides functions to check if a given octet sequence matches a ABNF.
//!
//! The module does not aim to be complete, it should only implement the validators needed for
//! parsing HTTP and maybe other protocols in the future.
//!
//! The Core Rules defined in [RFC5234](http://to... |
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct CoreAppWindowPreview(pub ::windows::core::IIns... |
fn main() {
let x = vec![1, 2, 3];
let y = &x;
println!("{:?}", x);
println!("{:?}", y);
let mut x_mut = vec![1, 2, 3];
let y_mut = &mut x_mut;
y_mut.push(4);
println!("{:?}", y_mut);
// println!("{:?}", x_mut);
{
let temp = vec![2, 3, 4];
let x = vec![1, 2, 3];
... |
const PARENS: [u8; 2] = [b'(', b')'];
#[derive(Debug, Copy, Clone, PartialEq)]
enum Token {
Literal(i64),
Op(u8),
Paren(u8),
}
struct Parser<'a> {
expr: &'a str
}
impl Parser<'_> {
fn advance(&mut self) -> Token {
let bytes = self.expr.as_bytes();
let mut start: usize = 0;
... |
use crate::{
linalg::{Mat, Vct},
Deserialize, Flt, Serialize,
};
use serde::de::{Deserializer, SeqAccess, Visitor};
use serde::ser::{SerializeSeq, Serializer};
use std::fmt;
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type", rename_all = "lowercase")]
pub enum TransformType {
Shift { x: ... |
// this is just a comment line introduced to evaulate git push
use a7q3_lib::calculater::probabilty;
fn main() {
let input: u32 = 7;
let output = probabilty::factorial(input);
println!("Factorial of {} is {}",input, output);
}
|
pub struct Solution;
impl Solution {
pub fn product_except_self(nums: Vec<i32>) -> Vec<i32> {
let n = nums.len();
let mut res = vec![0; n];
let mut p = 1;
for i in 0..n {
res[i] = p;
p *= nums[i];
}
p = 1;
for i in (0..n).rev() {
... |
// Largely translated from this: http://paulbourke.net/geometry/polygonise/
use crate::graphics::{render_target, DrawMode, Drawable};
use crate::particles::{consts, fieldprovider::FieldProvider};
use gl_bindings::{shaders::OurShader, shaders::ShaderAttribute, Buffer, BufferType};
use na::Matrix4;
use resources::shader... |
use num::iter::range;
use crate::riscv32_core::Riscv32Core;
use crate::riscv32_core::Riscv32Env;
use crate::riscv64_core::Riscv64Core;
use crate::riscv64_core::Riscv64Env;
use crate::riscv32_core::AddrT;
use crate::riscv32_core::XlenT;
use crate::riscv64_core::Xlen64T;
use crate::riscv32_core::MemAccType;
use crate... |
#![deny(missing_docs)]
//! `bincode` is a crate for encoding and decoding using a tiny binary
//! serialization strategy.
//!
//! There are simple functions for encoding to `Vec<u8>` and decoding from
//! `&[u8]`, but the meat of the library is the `serialize_into` and `deserialize_from`
//! functions which respective... |
#[doc = "Reader of register TX_LPI_USEC_CNTR"]
pub type R = crate::R<u32, super::TX_LPI_USEC_CNTR>;
#[doc = "Reader of field `TXLPIUSC`"]
pub type TXLPIUSC_R = crate::R<u32, u32>;
impl R {
#[doc = "Bits 0:31 - Tx LPI Microseconds Counter"]
#[inline(always)]
pub fn txlpiusc(&self) -> TXLPIUSC_R {
TXL... |
use std::cell::RefCell;
pub struct Seed(RefCell<u64>);
impl Default for Seed {
fn default() -> Self {
Self(RefCell::new(1))
}
}
impl Seed {
pub fn generate(&self) -> u64 {
self.alloc(1)
}
pub fn alloc(&self, len: u64) -> u64 {
let mut seed = self.0.borrow_mut();
l... |
use std::error::Error;
use std::process;
mod mender;
mod parse;
fn main() {
let matches = parse::build_cli().get_matches();
let command = parse::Command::new(matches).unwrap_or_else(|err| {
println!("Parse error: {}", err);
process::exit(1);
});
let config = parse::Config::new(command... |
use crate::{FunctionData, Instruction, Label, Value};
struct SkewedCFGInfo {
skew: Label,
exit: Label,
true_pred: Label,
false_pred: Label,
}
fn make_unconditional_branch(function: &mut FunctionData, from: Label, to: Label) {
let body = function.blocks.get_mut(&from).unwrap();
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.