text stringlengths 8 4.13M |
|---|
//! A Rust wrapper around Python's linecache. We can't just emulate it because
//! PEP 302 `__loader__`s and ipython shoving stuff into it and oh god oh god oh
//! god Python is complicated.
use crate::python;
/// Wrapper around Python's linecache.
#[derive(Default)]
pub struct LineCacher {}
impl LineCacher {
//... |
use crate::core::io::Io;
use std::path::Path;
use std::fs::read;
const _ROM_SIZE: usize = 32768;
const TITLE_START: usize = 0x134;
const TITLE_END: usize = 0x142;
// const LICENSEE_CODE_START: usize = 0x144;
// const LICENSEE_CODE_END: usize = 0x145;
// const SGB_FLAG: ... |
//! AIZU ONLINE JUDGEの回答用ライブラリ。
pub mod itp1_1;
pub mod itp1_2;
pub mod itp1_3;
pub mod itp1_4;
pub mod itp1_5;
pub mod itp1_6;
pub mod itp1_7;
pub mod itp1_8;
pub mod itp1_9;
pub mod itp1_10;
pub mod itp1_11; |
extern crate cgmath;
use cgmath::Vector3;
use cgmath::InnerSpace;
type Vec3 = Vector3<f32>;
use materials::Material;
pub struct Ray {
origin: Vec3,
direction: Vec3,
}
impl Ray {
pub fn new(a: Vec3, b: Vec3) -> Ray {
Ray {
origin: a,
direction: b,
}
}
pub fn... |
use runic::*;
use std::rc::Rc;
use std::cell::RefCell;
use std::error::Error;
use std::env;
use std::collections::HashMap;
use buffer::Buffer;
use res::Resources;
use lsp::LanguageServer;
use mode;
use winit::Event;
use regex::Regex;
use super::ConfigError;
#[derive(Debug,Clone,PartialEq,Eq,Hash)]
pub struct Clips... |
use serde::{Deserialize, Serialize};
use super::auction_type::*;
use super::currency::*;
#[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct Deal {
pub id: String,
#[serde(rename(serialize = "flr", deserialize = "flr"))]
pub floor_price: Option<f64>,
#[serde(default)]
#[serde(rename(se... |
use failure::Error;
use find_file_paths;
use git2::Repository;
use json_patch::merge;
use regex::Regex;
use serde_json::{self, Value};
use std::fs::File;
use std::path::{Path, PathBuf};
use tempfile::{self, TempDir};
use url::{ParseError, Url};
use walkdir::WalkDir;
use git;
pub enum ConfigDir {
File {
dir... |
use super::*;
/**
Wrapper that allows consuming transformations on borrowed data
This is useful when you want a mutable interface wrapping a functional one.
# Example
```
use kai::*;
struct Foo {
v: Swap<Vec<i32>>
}
impl Foo {
fn keep_even(&mut self) {
self.v.hold(|v| v.into_iter().filter(|n| n % 2... |
use std::path::PathBuf;
use clap::Parser;
use once_cell::sync::Lazy;
use simple_ssr::App;
use tokio_util::task::LocalPoolHandle;
use warp::Filter;
// We spawn a local pool that is as big as the number of cpu threads.
static LOCAL_POOL: Lazy<LocalPoolHandle> = Lazy::new(|| LocalPoolHandle::new(num_cpus::get()));
/// ... |
pub enum Mode {
Deploy,
EnemyTurn,
Select(Select),
Action(Action),
}
pub enum Select {
None,
Terrain,
Object,
Enemy,
Soldier
}
pub enum Action {
Move,
Fire,
Sprint,
UseItem,
HunkerDown,
Reload,
ChangeWeapon
} |
use nphysics::object::WorldObject;
use ncollide::events::ProximityEvent;
use ncollide::query::Proximity;
use specs::Join;
pub struct PhysicSystem;
impl<'a> ::specs::System<'a> for PhysicSystem {
type SystemData = (
::specs::ReadStorage<'a, ::component::Player>,
::specs::ReadStorage<'a, ::component... |
#![crate_name = "reforge_client"]
#![crate_type = "bin"]
#![feature(box_syntax)]
#![feature(rand)]
#![feature(core)]
#![feature(os)]
#![feature(io)]
#![feature(old_io)]
#![feature(alloc)]
#![feature(thread_sleep)]
#![feature(collections)]
#![feature(std_misc)]
extern crate bincode;
extern crate time;
extern crate rust... |
use super::message::{Message, send_msg, send_prompt};
use std::path::PathBuf;
pub enum Arg {
S(SendArg),
R(RecvArg),
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum OverwriteStrategy {
Ask,
Rename,
Overwrite,
Skip,
}
#[derive(Debug, Default)]
pub struct SendArg {
pub expire: u8,
p... |
pub mod utils {}
|
extern crate sdl2;
use super::super::controller::player_controller::PlayerController;
use super::super::input::input::Input;
use super::super::network::socket::Socket;
use super::dropped_item;
use super::item;
use super::map::Map;
use super::player;
pub struct World {
map: Option<Map>,
items: Vec<dropped_item... |
use super::super::posting::mastodon::MastodonUpload;
pub struct Saramin {
// 공고 ID
pub id: u32,
// 회사명
pub company_name: String,
// 공고 제목
pub title: String,
// 링크
pub link: String,
// 경력
career: Option<String>,
// 학력
education: Option<String>,
// 근로형태
emplo... |
// SPDX-License-Identifier: Apache-2.0
use std::fmt;
use openssl::hash::{DigestBytes, MessageDigest};
#[derive(Copy, Clone, Debug)]
pub enum Kind {
Sha256,
Null,
}
impl fmt::Display for Kind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let s = match self {
Self::Sha25... |
use argh::FromArgs;
use assembly_pack::pki::core::PackIndexFile;
use std::{convert::TryFrom, fs::File, path::PathBuf};
#[derive(FromArgs)]
/// Show contents of a PKI file
struct Args {
/// print all pack files
#[argh(switch, short = 'p')]
pack_files: bool,
/// print all files
#[argh(switch, short ... |
use std::cell::RefCell;
use std::rc::Rc;
use super::super::{Env, InterpreterError};
use super::super::super::Expr;
pub fn eq(args: &[Expr], _: Rc<RefCell<Env>>) -> Result<Expr, InterpreterError> {
if args.len() != 2 {
Err(InterpreterError::Usage("=".to_string(), args.to_vec()))
} else if args[0] == arg... |
// 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 fidl_fuchsia_wlan_common as fidl_common;
use fidl_fuchsia_wlan_mlme as fidl_mlme;
type Ssid = Vec<u8>;
pub fn fake_bss_description(ssid: Ssid, rsn: O... |
extern crate quicr_core as quicr;
extern crate openssl;
extern crate rand;
#[macro_use]
extern crate slog;
#[macro_use]
extern crate assert_matches;
#[macro_use]
extern crate lazy_static;
extern crate bytes;
#[macro_use]
extern crate hex_literal;
extern crate byteorder;
use std::net::SocketAddrV6;
use std::{fmt, str};... |
#[path="../src/file.rs"]
mod file;
#[test]
fn is_valid_with_path_and_content() {
let file = file::FileResource {
path: "/home/john/hello.txt".to_string(),
content: "Foo".to_string()
};
assert_eq!(file.is_valid(), true);
}
#[test]
fn is_invalid_without_path() {
let file = file::FileReso... |
// Copyright 2016 Google Inc. All Rights Reserved.
//
// Licensed under the MIT License, <LICENSE or http://opensource.org/licenses/MIT>.
// This file may not be copied, modified, or distributed except according to those terms.
use errors::{SerializableError, WireError};
use futures::{self, Future};
use futures::strea... |
#![allow(unused)]
use std::fs::File;
use std::io::prelude::*;
use std::fs::OpenOptions;
pub static CACHE_FILE: &'static str = "cache.txt";
pub fn create_cache_file() {
let try_file = File::open(CACHE_FILE);
match try_file {
Ok(file) => file,
Err(_) => File::create(CACHE_FILE).unwrap(),
};... |
/*
* YNAB API Endpoints
*
* Our API uses a REST based design, leverages the JSON data format, and relies upon HTTPS for transport. We respond with meaningful HTTP response codes and if an error occurs, we include error details in the response body. API Documentation is at https://api.youneedabudget.com
*
* The ve... |
use sudo_test::{Command, Env, User};
use crate::{Result, GROUPNAME, PASSWORD, SUDOERS_NO_LECTURE, USERNAME};
macro_rules! assert_snapshot {
($($tt:tt)*) => {
insta::with_settings!({
filters => vec![(r"[[:xdigit:]]{12}", "[host]")],
prepend_module_to_snapshot => false,
s... |
use crate::protocol::Protocol;
use crate::protocol::ProtocolSet;
use std::net::IpAddr;
use std::net::Ipv4Addr;
use std::net::Ipv6Addr;
pub const DEFAULT_UDP_PORT: u16 = 53;
pub const DEFAULT_TCP_PORT: u16 = 53;
pub const DEFAULT_DOT_PORT: u16 = 853;
pub const DEFAULT_DOH_PORT: u16 = 443;
pub const DEFAULT_MDNS_P... |
use crate::hittable::{aabb::Aabb, HitRecord, Hittable, Hittables};
use crate::material::MaterialType;
use crate::onb::Onb;
use crate::ray::{face_normal, Ray};
use crate::util::random_to_sphere;
use crate::vec::{vec3, Vec3};
use rand::rngs::SmallRng;
use std::sync::Arc;
#[derive(Debug, Clone)]
pub struct Sphere {
p... |
extern crate pest;
#[macro_use]
extern crate pest_derive;
use anyhow::{Context, Result};
use pest::Parser;
use structopt::StructOpt;
#[derive(Parser)]
#[grammar = "adoc.pest"]
struct AdocParser;
#[derive(StructOpt)]
struct Cli {
#[structopt(parse(from_os_str))]
path: std::path::PathBuf,
}
fn main() -> Resul... |
/// EditTeamOption options for editing a team
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct EditTeamOption {
pub can_create_org_repo: Option<bool>,
pub description: Option<String>,
pub includes_all_repositories: Option<bool>,
pub name: String,
pub permission: Option<crate::edi... |
use rusty_martian::read_input::read_input;
use rusty_martian::rover::Position;
use rusty_martian::simulation::Simulation;
fn main() {
let (grid, rovers, instructions) = read_input();
let mut simulation = Simulation::new(grid, rovers, instructions);
simulation.run();
for rover in simulation.rovers.it... |
use http_file::*;
use http::*;
use handler_lib::*;
pub struct FileSystemHandler {
path: String,
fs: FileSystem,
}
impl FileSystemHandler {
pub fn new(path: &str) -> FileSystemHandler {
FileSystemHandler {
path: path.to_string(),
fs: FileSystem::new(path),
}
}
}
i... |
/// Basic linear allocator.
pub struct IdAlloc<T> {
entries: Vec<Option<T>>,
empty_ids: Vec<usize>,
}
impl<T> IdAlloc<T> {
pub fn new() -> IdAlloc<T> {
IdAlloc {
entries: vec![],
empty_ids: vec![],
}
}
/// Get the entry with the given ID as mut.
pub fn get_mut(&mut self, id: usize) -> &mut T {
self... |
extern crate num;
use std::ops;
use std::vec;
use std::fmt;
pub trait Number<T>: Copy + num::Num + num::Bounded + num::NumCast + PartialOrd + Clone {}
impl<T> Number<T> for T where T: Copy
+ num::Num
+ num::Bounded
+ num::NumCast
+ PartialOrd
+ Clone {}
pub trait Vector<'a, T>... |
mod domain;
mod time;
pub use self::domain::run_domain_cli;
pub use self::time::run_time_cli;
|
#![allow(dead_code)]
use render::object::Object;
use nalgebra::geometry::{Quaternion, Point3, UnitQuaternion};
use nalgebra::Vector3;
pub struct GameObject{
// Id of the game object
pub id: u32,
// Name of the Game Object
pub name: String,
// Mesh
pub render_object: Option<Object>,
// Glob... |
use crate::blob::blob::responses::PutBlockListResponse;
use crate::blob::prelude::*;
use azure_core::headers::{add_optional_header, add_optional_header_ref};
use azure_core::prelude::*;
use bytes::Bytes;
#[derive(Debug, Clone)]
pub struct PutBlockListBuilder<'a> {
blob_client: &'a BlobClient,
block_list: &'a B... |
use chrono::prelude::*;
use chrono_tz::Tz;
use crate::{
binary::{Encoder, ReadEx},
errors::Result,
types::{
SqlType, DateTimeType, Value, ValueRef,
column::{
column_data::{BoxColumnData, ColumnData}, list::List,
}
},
};
pub struct DateTime64ColumnData {
data: Li... |
use graphql_client::GraphQLQuery;
#[derive(GraphQLQuery)]
#[graphql(
schema_path = "src/infra/persistent/counter_adapter/schemas/schema.graphql",
query_path = "src/infra/persistent/counter_adapter/schemas/get_counter.graphql",
response_derives = "Debug,Serialize,Deserialize"
)]
pub struct GetCounter;
|
use specs::Join;
pub struct DepthBallSystem;
impl<'a> ::specs::System<'a> for DepthBallSystem {
type SystemData = (
::specs::ReadStorage<'a, ::component::Contactor>,
::specs::ReadStorage<'a, ::component::Player>,
::specs::ReadStorage<'a, ::component::DepthBall>,
::specs::WriteStora... |
use crate::{multi_window::NewWindowRequest, tracked_window::{DisplayCreationError, TrackedWindow, TrackedWindowContainer, TrackedWindowControl}, windows::popup_window::PopupWindow};
use egui_glow::EguiGlow;
use glutin::{PossiblyCurrent, event_loop::ControlFlow};
use crate::MultiWindow;
use crate::windows::MyWindows;... |
// Copyright 2019 Parity Technologies
//
// 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 agree... |
pub(crate) mod response;
mod use_case;
use apllodb_immutable_schema_engine::ApllodbImmutableSchemaEngine;
use apllodb_shared_components::{ApllodbSessionResult, Session};
use apllodb_sql_processor::SqlProcessorContext;
use std::sync::Arc;
use use_case::UseCase;
use crate::ApllodbCommandSuccess;
#[derive(Clone, Debug... |
use tomorrow_core::{Error, Result};
use super::Requester;
use std::io::Read;
use serde_json;
use serde::de::DeserializeOwned;
use hyper::Client as HttpClient;
use hyper::status::StatusCode;
use hyper::header::Headers;
pub struct Client {
client: HttpClient,
headers: Headers,
api_url: String
}
impl Cli... |
// Copyright 2020 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
use consts::*;
use dividend::*;
use wasmlib::*;
mod consts;
mod dividend;
mod types;
#[no_mangle]
fn on_load() {
let exports = ScExports::new();
exports.add_func(FUNC_DIVIDE, func_divide);
exports.add_func(FUNC_MEMBER, func_member);
}... |
#[doc = "Register `APB1FZR2` reader"]
pub type R = crate::R<APB1FZR2_SPEC>;
#[doc = "Register `APB1FZR2` writer"]
pub type W = crate::W<APB1FZR2_SPEC>;
#[doc = "Field `DBG_LPTIM2_STOP` reader - LPTIM2 counter stopped when core is halted"]
pub type DBG_LPTIM2_STOP_R = crate::BitReader;
#[doc = "Field `DBG_LPTIM2_STOP` w... |
use crate::file::FileHash;
use crate::{Address, Range, Size};
/// A register number.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct Register(pub u16);
impl Register {
/// The name of the register, if known.
pub fn name(self, hash: &FileHash) -> Option<&'static str> {
... |
// Copyright 2021 The MWC 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 agreed... |
pub trait Summary {
fn summarize(&self) -> String;
}
//
pub struct NewsArticle {
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary for NewsArticle {
fn summarize(&self) -> String {
format!("{}, by {} ({})", self.headline, self.author, s... |
typeof1
f
fn
fn1
trai2
trait
trait3
typeof
typeo1
type1
typ1
et c = b + 1;
let b = b + 2;
println!("My First Program in Rust {} {} {}", a, b, c);
} |
pub type Reg = usize;
#[derive(Debug, PartialEq)]
pub enum Val {
Reg(usize),
Imm(i32),
}
// Clone is needed to tokenize.
#[derive(Debug, PartialEq, Clone)]
pub enum Op2 {
Add,
Sub,
Mul,
Div,
Mod,
LT,
Eq
}
#[derive(Debug, PartialEq)]
pub enum Printable {
Id(String),
Val(Val... |
//! Simplifies stevia expression trees via word-level transformations.
#![doc(html_root_url = "https://docs.rs/stevia_utils/0.1.0")]
#![feature(fn_traits)]
#![feature(unboxed_closures)]
// #![allow(missing_docs)]
#![allow(dead_code)]
extern crate stevia_ast as ast;
mod bitblaster;
mod gate_encoder;
mod repr;
|
use sdl2::render::{Texture, TextureCreator, Canvas};
use sdl2::video::{WindowContext, Window};
use sdl2::pixels::{PixelFormatEnum};
use crate::nes::nes::NES;
use crate::gfx::render;
use super::window::RenderableWindow;
const TEXTURE_WIDTH: u32 = 128;
const TEXTURE_HEIGHT: u32 = 128;
pub struct PatternTableWindow<'a>... |
#![allow(unconditional_recursion)]
use backend::models as m;
use pest::prelude::*;
use std::collections::LinkedList;
use super::ast;
use super::errors::*;
/// Check if character is an indentation character.
fn is_indent(c: char) -> bool {
match c {
' ' | '\t' => true,
_ => false,
}
}
/// Find... |
use std::collections::{HashSet, HashMap};
pub struct Map { }
impl Map {
/// Calculates the Mean Average Precision of all queries provided.
pub fn calc(results: &HashMap<usize, Vec<usize>>, relevance_info: &HashMap<usize, HashSet<usize>>) -> f64 {
let mut count = 0.0;
let mut sum = 0.0;
... |
use evitable::*;
#[evitable]
pub enum Context {
#[evitable(description("IO error"), from = std::io::Error)]
Io,
#[evitable(description("Writer closed"))]
WriterClosed,
}
|
use super::*;
use async_trait::async_trait;
use std::io;
use std::net::{IpAddr, Ipv4Addr};
use std::str::FromStr;
use std::sync::atomic::AtomicU64;
use util::vnet::chunk::Chunk;
use util::{vnet::router::Nic, vnet::*, Conn};
use waitgroup::WaitGroup;
pub(crate) struct MockConn;
#[async_trait]
impl Conn for MockConn {... |
use std::collections::HashMap;
use std::collections::HashSet;
use serde::{Serialize, Deserialize};
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
pub enum PieceKind {
King,
Queen,
Rook,
Bishop,
Knight,
Pawn,
}
#[derive(Clone, Copy, PartialEq, Debug, Serialize, Deserialize)]
p... |
use nix::unistd::*;
use super::process::Process;
impl Process {
pub(crate) fn pipe_first_connect(&self) -> Result<(), String> {
match self.get_pipe(self.len_pipes()) {
Some(pipes) => {
match dup2(pipes.1, 1) {
Ok(_) => {}
Err(_) => {
return Err(format!("pipe first d... |
//! # Orderbook
//!
//! A module to trade shares using a naive on-chain orderbook.
//!
//! ## Overview
//!
//! TODO
//!
//! ## Interface
//!
//! ### Dispatches
//!
#![cfg_attr(not(feature = "std"), no_std)]
use codec::{Decode, Encode};
use frame_support::traits::{Currency, ExistenceRequirement, ReservableCurrency, Wi... |
use crate::*;
#[derive(PartialEq, Debug, Clone)]
pub enum Expr {
FuncApp {
func_name: String,
args: Vec<TypedExpr>,
},
Constant(Literal),
OpExp {
lhs: Box<TypedExpr>,
rhs: Box<TypedExpr>,
op: Operator,
},
// just a name that gets looked up in the namespac... |
#[doc = "Reader of register SPINLOCK12"]
pub type R = crate::R<u32, super::SPINLOCK12>;
impl R {}
|
use pt_server::{
config::Config,
db,
logger::{create_logger, LoggerExt},
server,
};
#[actix_web::main]
async fn main() -> anyhow::Result<()> {
let config = Config::from_env()?;
let db_pool = db::connect(&config).await?;
let log = create_logger(&config).with_scope("http-server");
server:... |
mod lib;
#[derive(Debug)]
struct gen<T, U> {
name: T,
age: U,
}
impl<T, U> gen<T, U> {
fn test_knowlege(&self) -> &T {
&self.name
}
fn test_knowlege1(&self) -> &U {
&self.age
}
}
impl gen<&str, i32> {
fn find_age_times_10(&self) -> i32 {
self.age * 10
}
}
#[d... |
use std::env;
fn main(){
let target = env::var("TARGET").unwrap();
if target.contains("arm") {
println!("cargo:rustc-link-lib=dylib=mosquitto");
println!("cargo:rustc-link-lib=dylib=crypto");
println!("cargo:rustc-link-lib=dylib=ssl");
println!("cargo:rustc-link-lib=dylib=cares... |
use sqlx::arguments::Arguments;
use sqlx::sqlite::{SqliteArguments, SqliteQueryAs};
use sqlx::SqlitePool;
pub async fn get_last_inserted_id(pool: &SqlitePool) -> Result<i32, sqlx::Error> {
let rec: (i32, ) = sqlx::query_as("SELECT last_insert_rowid()")
.fetch_one(pool)
.await?;
Ok(rec.0)
}
p... |
//! Performance counters and statistics
use std::cmp::max;
use time::{get_time, Timespec};
/// Type that provides counters for the GC to gain some measure of performance.
pub trait StatsLogger: Send {
/// mark start of time
fn mark_start_time(&mut self);
/// mark end of time
fn mark_end_time(&mut s... |
pub mod handling;
pub enum TransformationResult {
Unchanged,
Modified,
Canceled
}
impl TransformationResult {
pub(crate) fn combine(&mut self, other: TransformationResult) -> bool {
match self {
TransformationResult::Unchanged => {
match other {
... |
use amethyst::core::{Hidden, Transform};
use amethyst::ecs::{Entities, Join, ReadStorage, System};
use amethyst::renderer::{Camera, SpriteRender};
use crate::components::{Explored, Init, Intent, Mob, Player, Tile};
#[derive(Default)]
pub struct DebugSystem;
impl<'s> System<'s> for DebugSystem {
type SystemData =... |
use actix::prelude::*;
use actix::registry::SystemService;
use futures::future::*;
use chrono;
#[cfg(feature = "python")]
use cpython::{FromPyObject, PyDict, PyObject, PyResult, Python};
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum ScriptType {
StreamSpan,
// Python function that can act on a tes... |
fn main() {
{
let s = String::from("hello world");
let hello = &s[0..5];
let world = &s[6..11];
println!("{} {}", hello, world);
// string slices are a pointer and a length
let _slice = &s[..2];
let _slice = &s[7..];
}
// a string with outstanding ... |
use super::*;
use roaring::RoaringBitmap;
/// # Drop.
impl Graph {
/// Return a roaringbitmap with the node ids to keep.
///
/// If both node\_names and node\_types are specified the result will be the
/// union of both queries.
///
/// # Arguments
/// * `node_names` : Option<Vec<String>>... |
use cosmwasm_std::{Decimal, HumanAddr, Uint128};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use terraswap::asset::Asset;
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InitMsg {
pub terraswap_factory: HumanAddr,
}
#[derive(Serialize, Deserialize, Clone, Debug... |
//! Flash memory
//!
//! This currently implements basic chip startup-related functions. You will probably not need to
//! use this interface directly, as the Flash peripheral is mostly configured by `Rcc::freeze`
use core::ptr;
use crate::common::Constrain;
use crate::power::{self, Power};
use crate::stm32l0x1::{fla... |
#[doc = "Register `SR` reader"]
pub type R = crate::R<SR_SPEC>;
#[doc = "Field `C1VAL` reader - COMP channel 1 output status bit"]
pub type C1VAL_R = crate::BitReader;
#[doc = "Field `C2VAL` reader - COMP channel 2 output status bit"]
pub type C2VAL_R = crate::BitReader;
#[doc = "Field `C1IF` reader - COMP channel 1 In... |
use crate::geo::*;
use serde::Deserialize;
use std::{collections::HashMap, fs::File, io::BufReader, path::Path};
use thiserror::Error;
#[derive(Error, Debug)]
/// Error types for vulkan compute operations
pub enum ToolError {
#[error("Tool table not found in file")]
Table,
#[error("Tool number not found i... |
//! Implementation Control Block
#[cfg(any(armv7m, armv8m, native))]
use volatile_register::RO;
use volatile_register::RW;
/// Register block
#[repr(C)]
pub struct RegisterBlock {
/// Interrupt Controller Type Register
///
/// The bottom four bits of this register give the number of implemented
/// in... |
mod compare_at;
use self::compare_at::{execute_home_compare_at, home_compare_at_subcommand, SUB_HOME_COMPARE_AT};
use clap::{App, Arg, ArgMatches, SubCommand};
use comparators::HomeInvest;
pub const SUB_HOME: &str = "home";
const ARG_SUPPLY: &str = "supply";
const ARG_LOAN: &str = "loan";
const ARG_LOAN_RATE: &str = ... |
use std::fs::File;
use std::io::Read;
#[derive(Debug, PartialEq)]
enum Operation {
SwapPos((usize, usize)),
SwapLetter((char, char)),
RotateLeft(usize),
RotateRight(usize),
RotatePos(char),
Reverse((usize, usize)),
Move((usize, usize)),
}
fn parse_operation(op: &str) -> Operation {
let... |
fn main() {
let mut contador = 1;
while contador <= 10 {
println!("Contador: {}", contador);
contador += 1;
}
//123 -> 3 = 12
//12345 -> 5
// 123456789 -> 9
let mut numero = 123456789;
let mut contador = 0;
while numero > 0 {
numero = numero / 10;
... |
use regex::Regex;
use std::error::Error;
use std::fs;
use std::path::Path;
use std::str::FromStr;
#[derive(Debug, Clone, PartialEq)]
struct Entry {
min: usize,
max: usize,
look_up_char: char,
password: String,
}
impl FromStr for Entry {
type Err = Box<dyn Error>;
fn from_str(input: &str) -> R... |
// This file is part of dpdk. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/dpdk/master/COPYRIGHT. No part of dpdk, including this file, may be copied, modified, propagated, or distributed except accordin... |
#[derive(serde::Serialize, serde::Deserialize, Clone)]
pub struct Envelope {
pub period: u16, // constant volume/envelope period
divider: u16,
pub decay_counter: u16, // remainder of envelope divider
pub start: bool, // restarts envelope
pub length_counter_halt: bool, // also the envelope loop flag
... |
/*
$ ipcal 192.168.1.0/24
Network addr : 192.168.1.0
Hosts addr : 192.160.1.1 - 192.168.1.254
Broadcast addr : 192.168.1.255
Hosts addr num : 254
*/
use std::env;
#[derive(Debug, PartialEq)]
struct IPAddr {
addr: [u8; 4],
prefix: u8,
}
impl IPAddr {
fn compose(&self) -> u32{
let ... |
use holochain_json_api::error::JsonError;
use holochain_persistence_api::{
cas::{
content::{Address, AddressableContent, Content},
storage::ContentAddressableStorage,
},
error::PersistenceResult,
reporting::{ReportStorage, StorageReport},
};
use pickledb::{PickleDb, PickleDbDumpPolicy, ... |
// This file is part of Substrate.
// Copyright (C) 2019-2020 Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// 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
//
// ht... |
// mod print;ß
// mod vars;
// mod strings;
// mod tuples;
// mod vectors;
// mod functions;
mod linkedList_test;
fn main() {
linkedList_test::run();
}
|
use std::fs::File;
fn create(filename: &str) -> std::io::Result<()> {
File::create("xxx")?; // is equivalent of
match File::create(filename) {
Ok(f) => f,
Err(e) => return Err(e),
};
Ok(())
}
fn main() {
let t = create("/tmp/xxx");
println!("{:?}", t);
}
|
include!(concat!(env!("OUT_DIR"), "/load_assets.rs"));
pub fn dfinity_logo() -> String {
if atty::is(atty::Stream::Stdout) {
include_str!("../../assets/dfinity-color.aart").to_string()
} else {
include_str!("../../assets/dfinity-nocolor.aart").to_string()
}
}
|
use core::f64::consts::PI;
use core::f64::consts::FRAC_PI_2;
use std::num::FpCategory;
use crate::coord_plane::CartPoint;
use crate::coord_plane::map_one_point;
use crate::coord_plane::LatLonPoint;
#[derive(Debug)]
pub struct MapBounds {
pub upper_x: f64,
pub lower_x: f64,
pub upper_y: f64,
pub lower_... |
extern crate piston;
extern crate graphics;
extern crate glutin_window;
extern crate opengl_graphics;
extern crate rand;
extern crate find_folder;
use piston::event_loop::*;
use piston::input::*;
use opengl_graphics::glyph_cache::GlyphCache;
use opengl_graphics::GlGraphics;
use glutin_window::GlutinWindow as Window;
u... |
use super::Icon;
use crate::JsObject;
pub struct ChatItem {
display_name: String,
peer_id: String,
character_id: Option<u128>,
icon: Icon,
payload: String,
}
impl ChatItem {
pub fn new(
display_name: impl Into<String>,
peer_id: impl Into<String>,
character_id: Option<u1... |
//! See [`Matrix`].
use crate::types::{ConPat, Lang, Pat, RawPat};
use std::fmt;
/// A 2-D matrix of [`Pat`]s.
pub(crate) struct Matrix<L: Lang> {
/// invariant: all rows are the same length.
rows: Vec<Row<L>>,
}
impl<L: Lang> Default for Matrix<L> {
fn default() -> Self {
Self { rows: Vec::new() }
}
}
... |
fn palindrome_permutation(s1: &str) -> bool {
s1.to_owned()
.replace(" ", "")
.chars()
.rev()
.collect::<String>()
== s1.to_owned().replace(" ", "")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_1() {
assert!(palindrome_permutation("taco cat"))... |
#[cfg(test)]
#[path = "../../../tests/unit/format/problem/fleet_reader_test.rs"]
mod fleet_reader_test;
use crate::extensions::create_typed_actor_groups;
use crate::format::coord_index::CoordIndex;
use crate::format::problem::reader::{ApiProblem, ProblemProperties};
use crate::format::problem::Matrix;
use crate::parse... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use ::libra_types::proto::*;
pub mod sgtypes {
include!(concat!(env!("OUT_DIR"), "/sgtypes.rs"));
}
|
use crate::server::{ServerConnection, RealServerConnection};
use serenity::framework::standard::{Args, CommandError};
use serenity::model::channel::Message;
use serenity::prelude::Context;
use super::alias_from_arg_or_channel_name;
use crate::db::*;
use crate::model::*;
use crate::commands::servers::{get_details_for_... |
use totsu::prelude::*;
use totsu::*;
use totsu_f32cuda::F32CUDA;
use totsu_core::LinAlgEx;
use rand::prelude::*;
use rand_xoshiro::rand_core::SeedableRng;
use rand_xoshiro::Xoshiro256StarStar;
use std::str::FromStr;
fn bench<L: LinAlgEx<F=f32>>(sz: usize) {
let n = sz;
let m = n + sz;
let p = 0;
le... |
mod net;
pub use net::{PipeConnection, PipeListener, ClientConnection};
|
use glob::{glob, GlobError};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use std::fs::{create_dir_all, read_to_string};
use std::path::PathBuf;
use tauri::api::path::{document_dir, resource_dir};
use tauri::Window;
#[derive(Serialize, Deserialize)]
struct Metadata {
api: i16,
name: String,
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.