text stringlengths 8 4.13M |
|---|
//! Tests auto-converted from "sass-spec/spec/libsass-closed-issues/issue_1210"
#[allow(unused)]
use super::rsass;
// From "sass-spec/spec/libsass-closed-issues/issue_1210/ampersand.hrx"
#[test]
fn ampersand() {
assert_eq!(
rsass(
"foo {\
\n @at-root {\
\n & {\
... |
use std::fs::File;
use std::io::{Read, Write};
use std::path::Path;
use compiler;
use parser;
use rustc_serialize::json::Json;
use rustc_serialize::json::Json::{Boolean, Null, I64, U64, F64, Array, Object};
use rustc_serialize::json::Json::String as JString;
use build::{HashBuilder, VecBuilder};
use template::Template;... |
#[test]
fn percent_absolute_position() {
let layout = stretch::node::Node::new(
stretch::style::Style {
flex_direction: stretch::style::FlexDirection::Column,
size: stretch::geometry::Size {
width: stretch::style::Dimension::Points(60f32),
height: stre... |
/*
#[derive(Debug)]
struct Weeks
{
day1 : String,
day2 : String,
}
#[derive(Debug)]
enum Days
{
Sunday(String),
Monday(u8,u8),
Tuesday,
}
#[derive(Debug)]
enum Option
{
Some(u8),
None
}
*/
//generic
enum Option<T>
{
Some(T),
None
}
fn main()
{
/*
let value1 = Some(5);
let name = Some(String::from("Rizwan"));
let d... |
use std::str::FromStr;
use problem::{Problem, solve};
struct Answers(u32);
impl FromStr for Answers {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
Ok(Answers(s.chars().fold(0, |acc, c| acc | (1 << (c as usize - 'a' as usize)))))
}
}
struct Day6;
impl Problem for Day6 {
ty... |
use std::ops::Add;
fn main() {
println!(
"First solution: {}",
part1(include_str!("../../input/18.txt"))
);
println!(
"Second solution: {}",
part2(include_str!("../../input/18.txt"))
);
}
fn part1(s: &str) -> u32 {
s.lines()
.map(Number::from)
.reduc... |
#![recursion_limit = "256"]
extern crate proc_macro;
use proc_macro::TokenStream;
use proc_macro2::Span;
use quote::{quote, ToTokens};
use syn::punctuated::Punctuated;
use syn::token::Comma;
#[proc_macro_attribute]
pub fn rusterlium(args: TokenStream, input: TokenStream) -> TokenStream {
let args = syn::parse_ma... |
mod camera;
mod engine;
mod object;
mod printer;
mod window;
mod raytrace_pipeline;
use engine::*;
fn main() {
raytrace_pipeline::raytracing()
} |
use bstr::ByteSlice;
use anyhow::Result;
use super::{
AnnotationCollection, AnnotationColumn, AnnotationRecord, ColumnKey,
};
#[derive(Debug, Clone, Default)]
pub struct BedRecords {
file_name: String,
pub records: Vec<BedRecord>,
column_keys: Vec<BedColumn>,
// TODO add header support
// p... |
mod support;
mod ui;
use cubik::glium::{glutin, Surface};
use cubik::draw::{ObjDrawInfo, EnvDrawInfo, basic_render, MAX_LIGHTS, Light};
use cubik::camera::perspective_matrix;
use cubik::input::{InputListener, process_input_event, center_cursor};
use cubik::skybox::Skybox;
use cubik::animation::ObjAnimation;
use cubi... |
/*!
BLS signatures
*/
use ff::Field;
use hkdf::Hkdf;
use pairing::bls12_381::{Bls12, Fq12, Fr, G1, G2};
use pairing::hash_to_field::BaseFromRO;
use pairing::hash_to_curve::HashToCurve;
use pairing::{CurveAffine, CurveProjective, Engine};
use sha2::digest::generic_array::typenum::U48;
use sha2::digest::generic_array::G... |
use kite::schema::FieldRef;
use kite::term::TermRef;
use kite::Query;
use kite::query::term_scorer::TermScorer;
use RocksDBIndexReader;
#[derive(Debug, Clone)]
pub enum CombinatorScorer {
Avg,
Max,
}
#[derive(Debug, Clone)]
pub enum ScoreFunctionOp {
Literal(f64),
TermScorer(FieldRef, TermRef, Term... |
use std::io::{Write};
use std::fs::File;
use lib::{Node};
use parser_lib as parser;
use asm_lib as asm;
// $ gcc -m32 -masm=intel main.s -o main
pub fn gen(ast: & Vec<Node::Node>, filename: & String) {
// println!("");
// println!("----------------");
// println!("[+] Code Generator:");
let mut f = File::c... |
use ggez::*;
use ggez::graphics::{DrawMode, Drawable, Rect, Color, Mesh, DrawParam};
use base::*;
use pathfinder::*;
use std::time::Instant;
use path_example::Point2;
/*
* AMD Ryzen 5 3600 6-Core Processor
* rustc 1.43.0
* Time elapsed : 4.99 sec
*/
static SIZE_COEFF : i32 = 5;
pub struct MainState {
pub titl... |
//!
use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Result as FmtResult;
use std::fmt::Write;
use super::expression::AlgebraicExpression;
#[derive(Clone, Debug, PartialEq)]
pub struct Observable {
name: String,
value: AlgebraicExpression,
}
impl Observable {
pub fn new<N, A>(name: N, value... |
use std::rc::Rc;
use cgmath::{self, EuclideanSpace};
use midgar::{KeyCode, Midgar, Surface};
use midgar::graphics::shape::ShapeRenderer;
use midgar::graphics::sprite::{DrawTexture, MagnifySamplerFilter, SpriteDrawParams, SpriteRenderer};
use midgar::graphics::text::{self, Font, TextRenderer};
use midgar::graphics::tex... |
/// GitTreeResponse returns a git tree
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
pub struct GitTreeResponse {
pub page: Option<i64>,
pub sha: Option<String>,
pub total_count: Option<i64>,
pub tree: Option<Vec<crate::git_entry::GitEntry>>,
pub truncated: Option<bool>,
pub url: Opt... |
use tonic::transport::Server;
|
#[doc = "Reader of register CTRLR0"]
pub type R = crate::R<u32, super::CTRLR0>;
#[doc = "Writer for register CTRLR0"]
pub type W = crate::W<u32, super::CTRLR0>;
#[doc = "Register CTRLR0 `reset()`'s with value 0"]
impl crate::ResetValue for super::CTRLR0 {
type Type = u32;
#[inline(always)]
fn reset_value() ... |
mod context;
mod gdt;
mod ide;
mod idt;
mod io;
mod mmu;
mod pci;
mod pic;
mod timer;
mod tss;
/* exposed child definitions */
pub use self::context::Context;
use self::idt::IDT;
use self::timer::Timer;
pub const HEAP_VIRT: u64 = mmu::HEAP_VIRT;
pub const HEAP_SIZE: u64 = mmu::HEAP_SIZE;
/* exported symbols */
pub ... |
extern crate gui;
use gui::*;
use math::*;
struct TextExample {
text_input: TextInput,
}
impl State for TextExample {
fn draw(&mut self, frame: &mut Frame, data: &StateData) {
frame.rect()
.size(Vec2::new(0.7, 0.2))
.color(color::rgb(0.7, 0.3, 0.2))
.anchor(Anchor:... |
extern crate utils;
use std::env;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::{self, BufReader};
use std::io::prelude::*;
use std::fs::File;
use utils::*;
type Input = Vec<u64>;
#[cfg(test)]
const PREAMBLE_SIZE: usize = 5;
#[cfg(not(test))]
const PREAMBLE_SIZE: usize = 25;
fn part1(i... |
use hex;
use std::str::from_utf8;
pub fn repeating_key_xor(item: String, key: String) -> String {
let mut xor_vec = Vec::new();
let mut index = 0;
for i in item.into_bytes().iter() {
let xored = key.as_bytes()[index] ^ i;
if ((index + 1) == key.as_bytes().len()) {
index = 0;
... |
use std::collections::HashMap;
use std::fmt;
#[derive(Debug, Hash, Eq, PartialEq, Clone, PartialOrd)]
pub enum Pixel {
Black = 0,
White = 1,
Transparent = 2,
}
impl Default for Pixel {
fn default() -> Self {
Pixel::Transparent
}
}
impl From<char> for Pixel {
fn from(input: char) -> Se... |
use crate::prelude::*;
use crate::{headers::from_headers::*, ResourceQuota};
use azure_core::headers::{content_type_from_headers, session_token_from_headers};
use azure_core::{Request as HttpRequest, Response as HttpResponse};
use chrono::{DateTime, Utc};
#[derive(Debug, Clone)]
pub struct DeleteCollectionOptions {
... |
use crate::schema::games as schema_games;
#[derive(serde_derive::Deserialize, serde_derive::Serialize, Queryable)]
pub struct Game {
pub id: i32,
pub match_id: Option<i32>,
pub duel_id: Option<i32>,
pub score_1: i32,
pub score_2: i32,
pub timestamp: chrono::NaiveDateTime,
}
#[derive(serde_deri... |
use gotham::router::Router;
use gotham::router::builder::build_router;
use gotham::router::builder::DrawRoutes;
use gotham::router::builder::DefineSingleRoute;
use gotham::pipeline::set::{finalize_pipeline_set, new_pipeline_set};
use gotham::pipeline::new_pipeline;
use gotham::middleware::session::{NewSessionMiddlewar... |
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(dead_code)]
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BTreeMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::sync::mpsc::{Sender, Receiver};
use std::sync::m... |
#[allow(unused_variables)]
fn main() {
println!("Hello, world!");
another_function();
parameter_function(5);
two_parameters(10, 20);
// error - let is a statement, not an expression, so it does not return anything
//let x = (let y = 6);
// A scope IS an expression
let x = 5;
let y = {
let x = 3;
x ... |
use middle::middle::*;
use mangle::Mangle;
use ast::name::Symbol;
use code::{emit_expression, sizeof_ty, size_name, short_size_name, eax_lo};
use context::Context;
use descriptors::{emit_descriptor, emit_primitive_descriptors};
use method::emit_method;
use ref_alloc::emit_class_allocator;
use stack::Stack;
use strings... |
use crate::math::vector::Vector2;
#[derive(Copy, Clone)]
pub struct Wall {
pub a: Vector2,
pub b: Vector2,
pub normal: Vector2,
pub texture: i32,
pub floor: f32,
pub ceiling: f32,
pub u: f32,
pub v: f32,
pub s: f32,
pub t: f32,
}
impl Wall {
pub fn new(a: Vector2, b: Vector... |
use crate::prelude::*;
use std::marker::PhantomData;
use syntax::source_map::FileName;
use gimli::write::{
Address, AttributeValue, DwarfUnit, EndianVec, FileId, LineProgram, LineString,
LineStringTable, Range, RangeList, Result, Sections, UnitEntryId, Writer,
};
use gimli::{Encoding, Format, LineEncoding, R... |
extern crate terminal;
extern crate serde_json;
use terminal::Source;
use std::net::{TcpListener, TcpStream};
// use std::net::Shutdown; // need to implement shutdown later
use std::thread;
use std::sync::mpsc::channel;
use std::str;
use std::io::{Read, Write};
pub struct Transport {
pub listener_addr: std::net::... |
fn main() {
proconio::input! {
n: usize,
s: String,
}
let mut cs: Vec<char> = s.chars().collect();
// println!("{:?}", cs);
for i in (0..n).rev() {
let mut pre = cs[0];
for j in 1..(i+1) {
// println!("{} {}", i, j);
if cs[j] == pre {
... |
#[doc = "Reader of register CONN_UPDATE_NEW_INTERVAL"]
pub type R = crate::R<u32, super::CONN_UPDATE_NEW_INTERVAL>;
#[doc = "Writer for register CONN_UPDATE_NEW_INTERVAL"]
pub type W = crate::W<u32, super::CONN_UPDATE_NEW_INTERVAL>;
#[doc = "Register CONN_UPDATE_NEW_INTERVAL `reset()`'s with value 0"]
impl crate::Reset... |
use std::env;
use std::vec::Vec;
mod graphreader;
mod graph;
mod dfs;
mod bfs;
mod mark;
mod constructiongraph;
fn main() {
let args: Vec<String> = env::args().collect();
let arg = args.get(1);
if arg.is_some() {
let g = graphreader::new_from_file(&(arg.unwrap())).unwrap();
let mut marker =... |
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
use crate::itest;
use test_util as util;
itest!(globals {
args: "run --compat --unstable --allow-read --allow-env compat/globals.ts",
output: "compat/globals.out",
});
itest!(fs_promises {
args: "run --compat --unstable -A compat/fs_pro... |
use std::io::{Write, Seek, SeekFrom, Read, self};
use regex::Regex;
use ::{format_u64, format_usize, NumberStyle, parse_as_u64, extract_section};
use sections::Section;
#[derive(Copy, Clone, Debug, Eq, Hash, PartialEq)]
pub enum SegmentType {
Text, Data
}
impl SegmentType {
pub fn to_string(self, seg_num: u... |
use aoc::*;
use std::collections::BTreeSet;
fn main() -> Result<()> {
let asteroids: Vec<_> = input("10.txt")?
.lines()
.enumerate()
.flat_map(|(y, line)| {
line.chars()
.enumerate()
.filter(|(_, ch)| *ch == '#')
.map(move |(x, _)|... |
#[doc = "Register `NSEPOCHR_CUR` reader"]
pub type R = crate::R<NSEPOCHR_CUR_SPEC>;
#[doc = "Field `NS_EPOCH` reader - Non-volatile non-secure EPOCH counter"]
pub type NS_EPOCH_R = crate::FieldReader<u32>;
impl R {
#[doc = "Bits 0:23 - Non-volatile non-secure EPOCH counter"]
#[inline(always)]
pub fn ns_epoc... |
use std::any::Any;
use std::cell::{RefCell, RefMut};
use std::rc::Rc;
use super::{CanReceive, Handoff, HandoffMeta, Iter};
/// A [Vec]-based FIFO handoff.
pub struct VecHandoff<T>
where
T: 'static,
{
pub(crate) input: Rc<RefCell<Vec<T>>>,
pub(crate) output: Rc<RefCell<Vec<T>>>,
}
impl<T> Default for VecHa... |
use lazy_static::lazy_static;
use regex::Regex;
const INPUT: &str = include_str!("../input");
const MAX_STEPS: u32 = 1_000_000;
type Result<T> = ::std::result::Result<T, Box<dyn ::std::error::Error>>;
lazy_static! {
static ref INPUT_REGEX: Regex =
Regex::new(r"position=<\s*(-?\d+),\s*(-?\d+)> velocity=<\... |
pub mod cli_tests;
|
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
#[allow(dead_code)]
struct Scanner<'a> {
cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
fn new(cin: StdinLock<'a>) -> Scanner<'a> {
Scanner { cin: cin }
}
fn read<T: FromStr>(&mut self) -> Option<T> {
let t... |
use core::fmt::Write;
use core::panic::PanicInfo;
use cortexm4;
use kernel::debug;
use kernel::debug::IoWrite;
use kernel::hil::led;
use kernel::hil::uart;
use kernel::hil::uart::Configure;
use stm32f407vg;
use stm32f407vg::gpio::PinId;
use crate::CHIP;
use crate::PROCESSES;
/// Writer is used by kernel::debug to ... |
use super::*;
use common_failures::prelude::*;
#[derive(Default)]
pub struct MemDataStore {
blocks: BTreeMap<BlockHeight, Block>,
block_hashes: BTreeMap<BlockHeight, BlockHash>,
}
impl DataStore for MemDataStore {
fn get_hash_by_height(&mut self, height: BlockHeight) -> Result<Option<BlockHash>> {
... |
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::batch::WriteBatch;
use crate::storage::{CodecStorage, ValueCodec};
use crate::TRANSACTION_INFO_PREFIX_NAME;
use crate::{define_storage, TransactionInfoStore};
use anyhow::{Error, Result};
use crypto::HashValue;
use scs::S... |
//! Contains baked-in assets.
use phf;
macro_rules! include_files_as_assets {
( $field_name:ident, $file_base:expr, $( $file_name:expr ),* ) => {
pub static $field_name: phf::Map<&'static str, &'static [u8]> = phf_map!(
$(
$file_name => include_bytes!(concat!($file_base, $file_... |
//! This example demonstrates an alternative method for creating a [`Table`].
//! [`Builder`] is an efficient implementation of the [builder design pattern](https://en.wikipedia.org/wiki/Builder_pattern).
//!
//! > The intent of the Builder design pattern is to separate the construction of a complex object from its rep... |
use crate::grammar::model::WrightInput;
use crate::grammar::tracing::input::OptionallyTraceable;
use crate::grammar::tracing::trace_result;
use nom::error::ErrorKind;
use nom::Err;
use nom::IResult;
/// A trait used to replace
/// [nom's trait of the same name](https://docs.rs/nom/5.1.1/nom/branch/trait.Alt.html).
pub... |
#[doc = "Reader of register TEMP_ICIFR"]
pub type R = crate::R<u32, super::TEMP_ICIFR>;
#[doc = "Writer for register TEMP_ICIFR"]
pub type W = crate::W<u32, super::TEMP_ICIFR>;
#[doc = "Register TEMP_ICIFR `reset()`'s with value 0"]
impl crate::ResetValue for super::TEMP_ICIFR {
type Type = u32;
#[inline(always... |
// Copyright (c) 2017-present PyO3 Project and Contributors
use crate::{
exceptions::{PyAttributeError, PyNotImplementedError},
ffi,
impl_::freelist::FreeList,
pycell::PyCellLayout,
pyclass_init::PyObjectInit,
type_object::{PyLayout, PyTypeObject},
PyClass, PyMethodDefType, PyNativeType, Py... |
use super::constants::RICH_SCHEMA;
use super::RequestType;
use crate::ledger::constants::{GET_RICH_SCHEMA_BY_ID, GET_RICH_SCHEMA_BY_METADATA};
use crate::ledger::identifiers::rich_schema::RichSchemaId;
use crate::utils::validation::{Validatable, ValidationError};
pub const MAX_ATTRIBUTES_COUNT: usize = 125;
#[derive(... |
extern crate sdl2;
extern crate ted_interface;
extern crate time;
extern crate rand;
use self::rand::Rng;
use std::io;
mod terrain;
use terrain::*;
mod effects;
use effects::*;
mod flag_selection;
mod spell_selection;
mod building_selection;
use spell_selection::*;
mod windows;
use windows::{WindowState,WindowArgs};
... |
mod parser;
pub mod tokenizer;
use parser::create::{CreateQuery};
use sqlparser::ast::{Statement};
use sqlparser::dialect::SQLiteDialect;
use sqlparser::parser::{Parser, ParserError};
use crate::error::{SQLRiteError, Result};
#[derive(Debug,PartialEq)]
pub enum SQLCommand {
Insert(String),
Delete(String),
... |
use std::str::CharIndices;
pub type Spanned<Tok, Loc, Error> = Result<(Loc, Tok, Loc), Error>;
#[derive(Copy, Clone, Debug)]
pub enum Tok<'input> {
Comment(&'input str),
Str(&'input str),
SectionKey(&'input str),
SectionValue(&'input str),
Guid(&'input str),
Id(&'input str),
DigitsAndDots(... |
use core::cmp::min;
use crate::error::ExpectedString;
use crate::parser::Parser;
use crate::span::Span;
impl<'s> Parser for &'s str {
type Value = Self;
type Error = ExpectedString<'s>;
fn parse(&self, input: &'_ str) -> Result<Span<Self::Value>, Span<Self::Error>> {
if input.starts_with(*self) {... |
use std::io::Error;
use std::os::unix::io::RawFd;
#[derive(Debug)]
pub struct Prog;
#[macro_export]
macro_rules! bpfprog {
($count:expr, $($code:tt $jt:tt $jf:tt $k:tt),*) => {
bpf::Prog
};
}
#[allow(unused_variables)]
pub fn attach_filter(fd: RawFd, prog: Prog) -> Result<(), Error> {
Ok(())
}
#... |
#[doc = "Register `MACTXTSSNR` reader"]
pub type R = crate::R<MACTXTSSNR_SPEC>;
#[doc = "Register `MACTXTSSNR` writer"]
pub type W = crate::W<MACTXTSSNR_SPEC>;
#[doc = "Field `TXTSSLO` reader - Transmit Timestamp Status Low This field contains the 31 bits of the Nanoseconds field of the Transmit packet's captured times... |
use crate::schema::page;
#[derive(
juniper::GraphQLObject,
Debug,
Queryable,
Identifiable,
Serialize,
Deserialize,
PartialEq,
Associations,
)]
#[table_name = "page"]
pub struct Page {
pub id: i32,
pub name: String,
pub icon: Option<String>,
pub content: Option<String>,
}
... |
use handlegraph::packedgraph::paths::StepPtr;
#[allow(unused_imports)]
use handlegraph::{
handle::{Direction, Handle, NodeId},
handlegraph::*,
mutablehandlegraph::*,
packed::*,
packedgraph::index::OneBasedIndex,
packedgraph::*,
path_position::*,
pathhandlegraph::*,
};
use crossbeam::{at... |
use core::cellbuffer::{CellAccessor, Cell};
use ui::core::attributes::{HorizontalAlign, VerticalAlign};
#[derive(Clone, Copy)]
pub enum Orientation {
Horizontal,
Vertical,
}
pub trait Painter: CellAccessor {
/// Prints a string at the specified position.
///
/// This is a shorthand for setting eac... |
// Copyright (c) 2018 Alexander Færøy. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
extern crate image;
extern crate rand;
use image::{Rgb, RgbImage};
/// Expression types and helpers.
mod expression;
use self::expression::{Evaluate, Gen... |
use crate::{
default_resource, diffable,
error::ServiceError,
generation,
models::{
sql::{slice_iter, SelectBuilder},
Lock, TypedAlias,
},
update_aliases, Client,
};
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use drogue_client::{meta, registry};
use drogue_cloud_s... |
use crate::components::{EnergyComponent, EnergyRegenComponent};
use crate::indices::EntityId;
use crate::join;
use crate::profile;
use crate::storage::views::{UnsafeView, View};
use crate::tables::JoinIterator;
pub fn energy_update(
mut energy: UnsafeView<EntityId, EnergyComponent>,
energy_regen: View<EntityId... |
use crate::AddAsHeader;
use http::request::Builder;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ContentType<'a>(&'a str);
impl<'a> ContentType<'a> {
pub fn new(s: &'a str) -> Self {
Self(s)
}
pub fn as_str(&self) -> &str {
self.0
}
}
impl<'a, S> From<S> for ContentType<'a... |
extern crate earthinator;
use earthinator::field::Map;
fn main(){
let mut map = Map::new(200,150);
map.generate();
//map.print();
map.export();
}
|
#[doc = "Register `C0CR` reader"]
pub type R = crate::R<C0CR_SPEC>;
#[doc = "Register `C0CR` writer"]
pub type W = crate::W<C0CR_SPEC>;
#[doc = "Field `DMAREQ_ID` reader - DMA request identification"]
pub type DMAREQ_ID_R = crate::FieldReader<DMAREQ_ID_A>;
#[doc = "DMA request identification\n\nValue on reset: 0"]
#[de... |
use std::cmp;
fn main() {
let input: &str = include_str!("input.txt");
let mut p = Picture::from(input);
p.enhance(2);
p.enhance(48);
}
struct Picture {
grid: Grid,
template: Vec<bool>,
}
impl Picture {
fn from(str: &str) -> Picture {
let mut sections = str.split("\n\n");
... |
use std::io;
fn main() {
// practice of convert between Fahrenheit and Celsius
println!("Please input the Fahrenheit");
let mut input_f = String::new();
io::stdin().read_line(&mut input_f)
.expect("Can not read line");
let input_f: f64 = input_f.trim().parse()
.expect("please... |
//! Validating References with [Lifetimes]
//!
//! [lifetimes]: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html
//!
//! # Examples
//!
//! Generic lifetimes in functions.
//!
//! ```
//! use the_book::ch10::longest;
//!
//! let a = "this is a sentence.";
//! let b = "This is also a sentence.";
//!
//! asser... |
#![warn(rust_2018_idioms)]
use std::path::{Path, PathBuf};
use winapi::shared::minwindef::{MAX_PATH, TRUE, UINT};
use winapi::um::winnt::{HRESULT, PVOID, WCHAR};
use winapi::um::winuser::{
SystemParametersInfoW, SPIF_SENDCHANGE, SPIF_UPDATEINIFILE, SPI_GETDESKWALLPAPER,
SPI_SETDESKWALLPAPER,
};
use widestrin... |
use crate::block::{Block, Content};
use crate::blockchain::BlockChain;
use crate::blockdb::BlockDatabase;
use crate::crypto::hash::Hashable;
use crate::experiment::performance_counter::PERFORMANCE_COUNTER;
use crate::miner::memory_pool::MemoryPool;
use crate::network::server::Handle as ServerHandle;
use std::sync::Mu... |
use crate::{app, config, eww_state::*, ipc_server, script_var_handler, try_logging_errors, util, EwwPaths};
use anyhow::*;
use futures_util::StreamExt;
use std::{collections::HashMap, os::unix::io::AsRawFd, path::Path};
use tokio::sync::mpsc::*;
pub fn initialize_server(paths: EwwPaths) -> Result<()> {
do_detach(&... |
use super::super::super::super::super::{awesome, btn, color_picker, modeless, text};
use super::super::state::{Modal, Modeless};
use super::Msg;
use crate::{
block::{self, BlockId},
model::{self},
resource::Data,
Color, Resource,
};
use kagura::prelude::*;
use wasm_bindgen::JsCast;
pub fn render(
b... |
//! A port of request parameter *Optionals from apimachinery/types.go
use crate::request::Error;
use serde::Serialize;
/// Controls how the resource version parameter is applied for list calls
///
/// Not specifying a `VersionMatch` strategy will give you different semantics
/// depending on what `resource_version`, `... |
use std::collections::HashSet;
pub struct Solution {}
/// LeetCode Monthly Challenge problem for March 1st, 2021.
impl Solution {
/// Given a vector of i32 integers, returns the minimum of unique integers,
/// or half the vector length.
///
/// # Arguments
///
/// * candy_type - A vector of i... |
use std::collections::{HashMap, HashSet};
use hydroflow::util::collect_ready;
use hydroflow::{assert_graphvis_snapshots, hydroflow_syntax};
use multiplatform_test::multiplatform_test;
#[multiplatform_test]
pub fn test_fold_tick() {
let (items_send, items_recv) = hydroflow::util::unbounded_channel::<Vec<u32>>();
... |
mod libc_wrapper;
mod tagfs;
use chrono::Local;
use std::ffi::OsStr;
use std::{env, io};
use crate::tagfs::TagFS;
#[macro_use]
extern crate log;
struct ConsoleLogger;
impl log::Log for ConsoleLogger {
fn enabled(&self, _metadata: &log::Metadata) -> bool {
true
}
fn log(&self, record: &log::Rec... |
mod cd_args;
mod ls_args;
mod cat_args;
pub use cd_args::CdArgs;
pub use ls_args::LsArgs;
pub use cat_args::CatArgs;
|
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub enum Network {
Mainnet,
Devnet,
Testnet,
}
impl Network {
pub fn epoch(&self) -> &'static str {
match *self {
Network::Mainnet => "2017-03-21T13:00:00.000Z",
Network::Devnet => "2017-03-21T13:00:00.000Z",
Netwo... |
pub fn question2() {
let number = 0;
if number < 0
{
println!("value {} is Nagitive",number);
}
else
{
println!("value {} is Positive",number);
}
} |
pub fn xor_byte_slices(raw_bytes_1: &[u8], raw_bytes_2: &[u8]) -> Vec<u8> {
let mut raw_bytes_xor = Vec::with_capacity(raw_bytes_1.len());
if raw_bytes_1.len() != raw_bytes_2.len() {
panic!("bytes to xor must have equal length")
}
let mut i = 0;
while i < raw_bytes_1.len() {
raw_byte... |
use bevy::prelude::*;
pub struct Plate;
pub struct PlateMaterial(Handle<ColorMaterial>);
pub const PLATE_WIDTH: f32 = 80.;
pub const PLATE_HEIGHT: f32 = 10.;
pub fn init(
commands: &mut Commands,
asset_server: &AssetServer,
materials: &mut ResMut<Assets<ColorMaterial>>,
) {
let plate_sprite = asset_s... |
fn main(){
let x = String::from("Hello");
let y = &x;
println!("{}", y); //this line fails. comment out to fix
println!("{}", x); //this line fails. comment out to fix
// so what happens here?
// x is the owner of some data, and x holds a reference to
// a string.
// y then is given a pointe... |
// SPDX-License-Identifier: Apache-2.0
use crate::evp;
use cipher_bench::{BlockCipher, BlockCipherBuilder};
use std::os::raw::c_int;
use std::ptr;
pub struct Aes128CbcCtxBuilder {
iv: Option<Vec<u8>>,
}
impl Aes128CbcCtxBuilder {
pub fn new() -> Self {
Self { iv: None }
}
fn build(&mut self,... |
use std::sync::Arc;
use eyre::Report;
use hashbrown::HashMap;
use rosu_v2::{
prelude::{GameMode, OsuError, Username},
OsuResult,
};
use twilight_model::id::{marker::ChannelMarker, Id};
use crate::{
embeds::{EmbedData, TrackListEmbed},
util::{constants::OSU_API_ISSUE, MessageExt},
BotResult, Comman... |
use std::fmt::{Display, Formatter};
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum Term {
Var(Var),
Const(Const),
Atom(Atom),
}
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Var(pub String, pub usize);
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Or... |
macro_rules! test_op {
($ty:ty => $lhs:literal $op:tt $rhs:literal = $result:literal) => {{
let program = format!(
r#"const A = {lhs}; const B = {rhs}; const VALUE = A {op} B; fn main() {{ VALUE }}"#,
lhs = $lhs, rhs = $rhs, op = stringify!($op),
);
assert_eq!(
... |
/*!
Totsu ([凸](http://www.decodeunicode.org/en/u+51F8) in Japanese) means convex.
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js"></script>
This crate for Rust provides **convex optimization probl... |
use core::cell::UnsafeCell;
use core::ops::{Deref, DerefMut, Drop};
use crate::bindings;
//use crate::println;
extern "C" {
pub fn spin_lock_init_wrapper(lock: *mut bindings::spinlock_t);
pub fn spin_lock_wrapper(lock: *mut bindings::spinlock_t);
pub fn spin_unlock_wrapper(lock: *mut bindings::spinlock_t);... |
fn main() {
// Rust has a lot of neat things you can do with functions: let's go over the basics first
fn no_args() {}
// Run function with no arguments
no_args();
// Calling a function with fixed number of arguments.
// adds_one takes a 32-bit signed integer and returns a 32-bit signed intege... |
use crate::be::MinBigEndian;
use crate::error::Error;
use crate::error::UnsupportedType;
use serde::ser::{
SerializeMap, SerializeSeq, SerializeStruct, SerializeStructVariant, SerializeTuple,
SerializeTupleStruct, SerializeTupleVariant,
};
use serde::{Serialize, Serializer};
use std::fmt::Display;
pub fn to_by... |
#[doc = "Register `RCC_MC_APB5ENSETR` reader"]
pub type R = crate::R<RCC_MC_APB5ENSETR_SPEC>;
#[doc = "Register `RCC_MC_APB5ENSETR` writer"]
pub type W = crate::W<RCC_MC_APB5ENSETR_SPEC>;
#[doc = "Field `SPI6EN` reader - SPI6EN"]
pub type SPI6EN_R = crate::BitReader;
#[doc = "Field `SPI6EN` writer - SPI6EN"]
pub type S... |
use std::fmt::Debug;
use aoc_lib::Solver;
#[derive(Debug, Default)]
pub struct Day10 {
cycles: Vec<(i32, i32, i32)>,
}
#[derive(Clone, Default)]
struct Crt {
rows: Vec<PixelType>,
current_sprite_pos: usize,
}
#[derive(Clone, Copy)]
enum PixelType {
Lit,
Dark,
}
impl Solver for Day10 {
fn day(... |
#[derive(Debug, PartialEq, Clone, Copy)]
pub enum Token {
String,
Number,
Name,
/// default token
None,
Eof,
/// used for errors
SC(char),
LeftParen,
RightParen,
LeftSquare,
RightSquare,
LeftBrace,
RightBrace,
Colon,
Line,
Dot,
And,
Or,
Equal,
Eq,
Neq,
Gt,
Lt,
Ge,
L... |
use async_executor::Executor;
use async_std::sync::Mutex;
use log::*;
use std::net::SocketAddr;
use std::sync::{Arc, Weak};
use crate::net::error::{NetError, NetResult};
use crate::net::protocols::{ProtocolAddress, ProtocolPing};
use crate::net::sessions::Session;
use crate::net::{ChannelPtr, Connector, P2p};
use crat... |
extern crate aoc2017;
use aoc2017::days::day12;
fn main() {
let input = aoc2017::read_trim("input/day12.txt").unwrap();
let value1 = day12::part1::parse(&input);
let value2 = day12::part2::parse(&input);
println!("Day 12 part 1 value: {}", value1);
println!("Day 12 part 2 value: {}", value2);
}
|
extern crate std;
extern crate term;
enum Color {
Green,
Red,
Yellow,
Blue,
Blank
}
fn _ask(question: &str, col: Color) -> String {
_say(question, col);
let mut s = std::io::stdio::stdin().read_line().unwrap();
s.pop(); // XXX terrible terrible
s
}
pub fn ask(question: &str) -> St... |
use super::{Pages, Pagination};
use crate::{embeds::MostPlayedCommonEmbed, BotResult};
use hashbrown::HashMap;
use rosu_v2::prelude::{MostPlayedMap, Username};
use smallvec::SmallVec;
use twilight_model::channel::Message;
pub struct MostPlayedCommonPagination {
msg: Message,
pages: Pages,
names: Vec<Usern... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.