blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
6303f8138b26b701ce97876e7ce12bbedca93870 | Rust | rust-lang/rust | /tests/ui/mismatched_types/ref-pat-suggestions.rs | UTF-8 | 1,405 | 2.578125 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // run-rustfix
fn _f0(&_a: u32) {} //~ ERROR mismatched types
fn _f1(&mut _a: u32) {} //~ ERROR mismatched types
fn _f2(&&_a: &u32) {} //~ ERROR mismatched types
fn _f3(&mut &_a: &mut u32) {} //~ ERROR mismatched types
fn _f4(&&mut _a: &u32) {} //~ ERROR mismatched types
fn _f5(&mut &mut _a: &mut u32) {} //~ ERROR mis... | true |
ec74a61e5a8067f278e3e4688857538580ba6587 | Rust | obeah/sheeit | /sheeit_computation/src/functions/rand.rs | UTF-8 | 2,262 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::{Arity, EvalContext, EvalErrorKind, RefResolver};
use rand;
use rand::Rng;
use sheeit_storage::raw_parser::Expression;
use sheeit_storage::{CoreDocument, Value};
pub fn eval<'a>(
_fn_name: &str,
_context: &'a EvalContext,
document: CoreDocument,
args: &[&'a Expression],
_eval_ref_handle:... | true |
5790e6e61581b33525c2263f0dad4e8eb900f5c5 | Rust | Fluxie/bistest | /src/hash_store.rs | UTF-8 | 680 | 3.21875 | 3 | [
"MIT"
] | permissive |
use integer_set;
use std::collections::HashSet;
pub struct HashStore {
members: HashSet<i32>
}
impl HashStore {
pub fn new(
data: & integer_set::IntegerSet
) -> HashStore{
let mut store: HashSet< i32 > = HashSet::with_capacity( data.members.le... | true |
73fbc5af0914fe241c4f203dae5be4f75cbe781b | Rust | khuzama98/hello-world | /Rust/hello_world_dangle.rs | UTF-8 | 223 | 3.359375 | 3 | [] | no_license | //this is main function
fn main() {
let message = dangle();
println!("{}", message)
}
//this is dangle function which move the ownership
fn dangle() -> String {
let str = String::from("Hello World");
str
}
| true |
632409795be202346b8e97d8494e09a28db5fe09 | Rust | bohdaq/rust-web-server | /src/url/path/mod.rs | UTF-8 | 2,887 | 3.09375 | 3 | [] | no_license | use std::collections::HashMap;
use crate::json::object::{FromJSON, ToJSON};
#[cfg(test)]
mod tests;
pub struct UrlPath;
pub struct Part {
pub is_static: bool,
pub name: String,
pub value: String
}
impl UrlPath {
pub fn extract_parts_from_pattern(_pattern: &str) -> Vec<Part>{
let part_list: V... | true |
8a8580899dde28f587021e6f0e54d632410a8a4c | Rust | inversion-engine/inversion-api-rust | /crates/broker/src/inv_api_spec.rs | UTF-8 | 7,112 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | //! inversion api spec definitions
use crate::inv_uniq::*;
use std::sync::Arc;
/// Status of a particular Feature Definition in an ApiSpec.
#[derive(
Debug,
serde::Serialize,
serde::Deserialize,
PartialEq,
Eq,
PartialOrd,
Ord,
Hash,
)]
#[serde(rename_all = "camelCase")]
pub enum Featu... | true |
163183fc642d22e556f69a54abc080e40b242f60 | Rust | AkifumiSato/actix-web-demo | /src/driver/tags.rs | UTF-8 | 5,996 | 2.78125 | 3 | [] | no_license | use crate::domain::entity::tags::{PostTag, Tag};
use crate::driver::data_access::DataAccess;
use crate::schema::posts_tags;
use crate::schema::tags;
use crate::usecase::article_list_get::TagFindsDataAccess;
use crate::usecase::error::DataAccessError;
use crate::usecase::tag_all_get::TagAllGetDataAccess;
use crate::usec... | true |
ea4bee0ae9b6ea18ac9efeba7dcac0f8142f62ce | Rust | Canop/termimad | /src/parse/parse_attribute.rs | UTF-8 | 1,214 | 2.84375 | 3 | [
"MIT"
] | permissive | use {
crossterm::style::{
Attribute,
},
lazy_regex::*,
};
#[derive(thiserror::Error, Debug)]
pub enum ParseAttributeError {
#[error("not a recognized attribute")]
Unrecognized,
}
/// Read a Minimad Attributement from a string.
pub fn parse_attribute(s: &str) -> Result<Attribute, ParseAttri... | true |
cd5b66ec312fe9f5bf1ad2f6a7e5179cf74620c8 | Rust | remicaumette/rust-shop | /src/http/server.rs | UTF-8 | 1,042 | 2.546875 | 3 | [] | no_license | use std::io::Result;
use actix_web::{web, middleware, App, HttpServer};
use crate::http::handlers;
use crate::repository::product::ProductRepository;
#[derive(Clone)]
pub struct Server {
data: ServerData,
}
#[derive(Clone)]
pub struct ServerData {
pub product_repository: ProductRepository
}
impl Server {
pub f... | true |
5633e14d886d4367f3ab2c9c7004c5e7dd6bd6d8 | Rust | DLR-FT/a653rs-linux | /core/src/fd.rs | UTF-8 | 3,222 | 2.71875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Implementation of PID file descriptors
// TODO: Consider renaming this module to "pidfd" for less ambiguity
// TODO: Remove this, as soon as the following is available in stable Rust:
// https://doc.rust-lang.org/stable/std/os/linux/process/struct.PidFd.html
use std::io::ErrorKind;
use std::os::unix::prelude::{AsRa... | true |
1a2572f97d2ccba1ee9932c8d8592fbe512d3636 | Rust | BrooksPatton/natureofcode | /chapter_3/example_3_2_rust/src/mover.rs | UTF-8 | 1,906 | 3 | 3 | [
"MIT"
] | permissive | use bbggez::{
color,
ggez::{graphics, nalgebra::Vector2, Context},
mesh,
};
pub trait NatureOfCode {
fn new(x: f32, y: f32, mass: f32, context: &mut Context) -> Self;
fn update(&mut self, delta_time: f32);
fn apply_force(&mut self, force: Vector2<f32>);
fn reverse_horizontal_velocity(&mut self);
fn reverse... | true |
d6a71afc83837939d841ef4c58dfc839f838cf65 | Rust | BartMassey/parsere | /parsere/src/lib.rs | UTF-8 | 671 | 2.875 | 3 | [] | no_license | pub use parsere_derive::ParseRe;
#[derive(Debug, Clone)]
pub enum Error {
Mismatch { re: &'static str, txt: String },
NoGroup { re: &'static str, txt: String, index: usize },
}
impl std::fmt::Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
... | true |
1883d16d35a03400c94625637fc3adb97b3643f6 | Rust | gifnksm/man-sysnopsis-tools | /deps/synop/src/util.rs | UTF-8 | 389 | 2.765625 | 3 | [] | no_license | use std::io::BufReader;
use std::io::prelude::*;
use super::Tokenizer;
use ast::Expr;
pub type ReadResult = Result<Expr, String>;
pub fn read_ast<R: Read>(reader: R) -> ReadResult {
let cs = BufReader::new(reader).chars().map(|c| c.unwrap());
match super::parse(Tokenizer::new(cs)) {
Ok(ast) => Ok(ast... | true |
5287955b9b8f1a651aa0e3d5bc20bf04a8df75a2 | Rust | CGUTA/nannou | /src/draw/properties/primitive/polygon.rs | UTF-8 | 8,251 | 3.109375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::draw::properties::spatial::{self, orientation, position};
use crate::draw::properties::{
ColorScalar, Draw, Drawn, IntoDrawn, Primitive, Rgba, SetColor, SetOrientation, SetPosition,
};
use crate::draw::{self, mesh, Drawing};
use crate::geom;
use crate::math::BaseFloat;
use std::iter;
/// A polygon prior... | true |
5aa3d01d8b63819441113e93b424bab2c1b8cec1 | Rust | arkorobotics/HABEXpico | /Firmware/src/gps.rs | UTF-8 | 2,766 | 2.640625 | 3 | [] | no_license | //#![deny(warnings)]
#![deny(unsafe_code)]
use stm32l0xx_hal::{prelude::*, gpio, serial};
use nb::block;
use super::nmea;
use super::habex;
pub struct GPS<'a> {
pub gps_tx: &'a mut serial::Tx<serial::LPUART1>,
pub gps_rx: &'a mut serial::Rx<serial::LPUART1>,
pub gps_en: &'a mut gpio::gpioa::PA1<gpio::Out... | true |
2db6a89f15b06203fb8330a5e1a059a3bc5bbe06 | Rust | MindFlavor/azure-sdk-for-rust | /sdk/cosmos/src/cosmos_entity.rs | UTF-8 | 1,360 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-generic-cla",
"LGPL-2.1-or-later"
] | permissive | use crate::headers;
use azure_core::Request as HttpRequest;
use http::request::Builder;
use serde::Serialize;
/// CosmosDB partition key. Every CosmosDB entity must implement it.
pub trait CosmosEntity<'a> {
/// Returned type.
type Entity: Serialize + 'a;
/// Return partition key value as reference.
f... | true |
980a9b57b2f14e500901218a848ca00113b1999f | Rust | joshuawarner32/ruba | /src/csv_loader.rs | UTF-8 | 1,430 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | use std::fs::File;
use std::io::BufReader;
use std::io::BufRead;
use std::rc::Rc;
use std::boxed::Box;
use value::InpVal;
use value::InpRecordType;
pub struct CSVIter<'a> {
iter: Box<Iterator<Item=InpRecordType<'a>> + 'a>,
}
impl<'a> Iterator for CSVIter<'a> {
type Item = InpRecordType<'a>;
fn next(&mut... | true |
ada16a6c3222320bb32b1d55ed42a959fb634feb | Rust | zatchl/kawaiifi-cli | /src/app.rs | UTF-8 | 2,623 | 2.578125 | 3 | [] | no_license | use crate::widgets::{
BssTable, BssTableColumnHeader, BssTableState, IeTable, IeTableState, TableSortOrder,
};
use kawaiifi::Bss;
use std::io::{self, Stdout};
use tui::{
backend::CrosstermBackend,
layout::{Constraint, Direction, Layout},
Terminal,
};
#[derive(Debug)]
pub struct App {
bss_table: Bss... | true |
b4fcb91d5fcfeddd4d15117201cdc7c87e14ed49 | Rust | jonsaw/google-maps-places-rs | /src/response.rs | UTF-8 | 13,316 | 2.921875 | 3 | [
"MIT"
] | permissive | use serde::Deserialize;
#[cfg(feature = "async-graphql")]
use async_graphql::{Enum, SimpleObject};
/// https://developers.google.com/maps/documentation/places/web-service/details#PlacesDetailsStatus
#[derive(Debug, Deserialize)]
#[serde(tag = "status")]
pub enum Response {
/// `OK` indicating the API request was ... | true |
205bd813b57a596563d26148b3963088d1bd4d85 | Rust | cogciprocate/qutex | /src/qutex.rs | UTF-8 | 10,447 | 2.953125 | 3 | [
"MIT"
] | permissive | //! A queue-backed exclusive data lock.
//!
//
// * It is unclear how many of the unsafe methods within need actually remain
// unsafe.
use crossbeam::queue::SegQueue;
use futures::sync::oneshot::{self, Canceled, Receiver, Sender};
use futures::{Future, Poll};
use std::cell::UnsafeCell;
use std::ops::{Deref, DerefMu... | true |
e7c5fa44a1a6c5e50b6ed577bc3aab261303f564 | Rust | michaelwoerister/std-mangle-rs | /src/int_radix.rs | UTF-8 | 2,480 | 3.578125 | 4 | [
"MIT"
] | permissive | use std::fmt;
pub struct RadixFmt {
radix: u8,
value: u64,
}
const DIGITS: &[u8] = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
pub fn radix(radix: u8, value: u64) -> RadixFmt {
RadixFmt { radix, value }
}
impl fmt::Display for RadixFmt {
fn fmt(&self, f: &mut fmt::Formatter) -... | true |
ac20a50a85bf50fd7795c559e80402d8b1becc23 | Rust | vgamula/CHIP-8 | /src/chip8.rs | UTF-8 | 9,740 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::Read;
use std::thread;
use std::time::Duration;
use rand;
use crate::input_driver::{EventProcessingState, InputDriver};
use crate::video_driver::{VideoDriver, GFX_HEIGHT, GFX_WIDTH};
const MEMORY_SIZE: usize = 4096;
const REGISTERS_COUNT: usize = 16;
const STACK_SIZE: usize = 16;
con... | true |
d8851e745c68cd013d7d3035fe02061f4f28326d | Rust | dhartunian/advent-of-code-2018 | /src/main.rs | UTF-8 | 15,445 | 3.4375 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use std::collections::HashSet;
use std::collections::HashMap;
use std::iter::FromIterator;
fn main() -> std::io::Result<()> {
let mut file = File::open("inputs/day-5-input.txt")?;
let mut contents = String::new();
file.read_to_string(&mut contents)?;
let mut... | true |
0166506f62d2722b7652d4853b2d697777ba858e | Rust | aiden0z/snippets | /lang/rust/ownership/src/main.rs | UTF-8 | 4,479 | 4.28125 | 4 | [
"MIT"
] | permissive | // 在任意给定的时间(同一个作用域内),要么只能有一个可变引用,要么 只能有多个不可变引用
// 引用必须总是有效的(避免悬垂指针)
fn main() {
// Rust 中的每一个值都有一个被称为其 所有者(owner)的变量。
// 值在任一时刻有且只有一个所有者。
// 当所有者(变量)离开作用域,这个值将被丢弃。
println!("Hello, world!");
{
// s 在这里无效, 它尚未声明
let s = "hello"; // 从此处起,s 是有效的
// 使用 s
println!("The ... | true |
da22281c0bbbe2c6a2fb4f4c9d65e8cc48f28bd7 | Rust | ChineseNewMinecraft/be_voxel_rs | /src/gui/container/mod.rs | UTF-8 | 1,846 | 2.875 | 3 | [] | no_license | use super::style::Style;
use font_kit::family_name::FamilyName;
use font_kit::properties::Properties;
use font_kit::source::SystemSource;
use raqote::*;
use raqote::{
DrawOptions, DrawTarget, PathBuilder, Point, SolidSource, Source, StrokeStyle, Transform,
};
pub trait Node {
fn draw(&self, targer: &DrawTarget... | true |
3b4360d84b4ed73c021a97c6be6c2f39e10dc706 | Rust | nb-twy/redisgraph-rs | /src/lib.rs | UTF-8 | 3,201 | 2.84375 | 3 | [
"MIT"
] | permissive | #![doc(html_logo_url = "https://oss.redislabs.com/redisgraph/images/logo_small.png")]
//! # redisgraph-rs
//!
//! `redisgraph-rs` is an idiomatic Rust client for RedisGraph, the graph database by Redis.
//!
//! This crate parses responses from RedisGraph and converts them into ordinary Rust values.
//! It exposes a ve... | true |
1af8205cd8cffae2fa58844cefafc0a4b803155f | Rust | socialdash/notifications | /src/services/templates.rs | UTF-8 | 2,070 | 2.515625 | 3 | [] | no_license | use failure::Error as FailureError;
use diesel::connection::AnsiTransactionManager;
use diesel::pg::Pg;
use diesel::Connection;
use r2d2::ManageConnection;
use repos::ReposFactory;
use services::types::{Service, ServiceFuture};
use stq_static_resources::TemplateVariant;
pub trait TemplatesService {
/// Get templ... | true |
80c6eb17dbf0bc772a724842369881d9cd8a88ab | Rust | cc13ny/tokio | /tokio/src/io/poll_evented.rs | UTF-8 | 12,648 | 3.03125 | 3 | [
"MIT"
] | permissive | use crate::io::driver::{Direction, Handle, ReadyEvent};
use crate::io::registration::Registration;
use crate::io::{AsyncRead, AsyncWrite, ReadBuf};
use mio::event::Evented;
use std::fmt;
use std::io::{self, Read, Write};
use std::marker::Unpin;
use std::pin::Pin;
use std::task::{Context, Poll};
cfg_io_driver! {
/... | true |
fbbdf87554d798025d49febd91e46970b37d4690 | Rust | olivierBeausejour96/rust_playground | /Alpha/learningGroundProject/bitmap/src/lib.rs | UTF-8 | 8,178 | 3 | 3 | [
"MIT"
] | permissive | #[cfg(tests)]
mod tests {
}
use std::fs;
#[derive(Debug)]
pub struct Bitmap {
width: u32,
height: u32,
offset: usize,
bpp: u32,
stride: u32,
data:Box<std::vec::Vec<u8>>
}
pub struct Rec {
x: u32,
y: u32,
width: u32,
height: u32,
}
impl Bitmap {
pub fn get_ptr0(&self)... | true |
0f841c3334c84ecf4957d3a53978f371be9e8dab | Rust | pwwolff/RussianRust | /src/wiktionary_parser.rs | UTF-8 | 2,074 | 3.296875 | 3 | [] | no_license | use std::fs::File;
use std::io::BufReader;
use xml::reader::{EventReader, XmlEvent};
#[derive(Debug, Default)]
pub struct WikiParser {
pub(crate) file_path: String,
}
impl WikiParser {
pub(crate) fn parse(&self) {
let file = File::open(&self.file_path).unwrap();
let file = BufReader::new(file)... | true |
10b8637b98ec4bdd152d11e09c461452460d6215 | Rust | bjornua/space-game | /src/game/mod.rs | UTF-8 | 847 | 2.984375 | 3 | [
"MIT"
] | permissive | use items::Item;
pub struct GameState {
pub objects: Vec<Item>
}
pub fn generate_gamestate() -> GameState {
GameState {
objects: vec![
]
}
}
struct Object {
}
// type Time = u64;
// type PlayerId = u64;
// type ObjectId = u64;
// struct Vector2(x, y);
// struct Point(Vector2);
// st... | true |
17e8081676881cb117397c25e42ee844ca55f77e | Rust | alerdenisov/unrust | /src/engine/context.rs | UTF-8 | 8,089 | 2.640625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use engine::asset::AssetResult;
use engine::core::Component;
use engine::engine::EngineStats;
use engine::render::{CullMode, DepthTest, Material, MaterialState, MeshBuffer, ShaderProgram,
Texture};
use std::collections::VecDeque;
use std::rc::{Rc, Weak};
use std::sync::Arc;
use uni_gl;
use uni_gl::... | true |
ccdac372f43c0493ad0a1849aba3caaa5ad97e71 | Rust | drPytho/mecah | /src/database/storage.rs | UTF-8 | 4,838 | 4.03125 | 4 | [] | no_license | use std::collections::HashMap;
use std::fmt;
/// This enum is just a easy to read description
/// of possible errors ocurred when consulting
/// the database
pub enum StorageError {
KeyNotFound,
InternalError,
}
impl fmt::Debug for StorageError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
... | true |
5f9ec1e20af2045f87e26807d73cc00f153b35e7 | Rust | dobrakmato/renderer | /bf/src/tree.rs | UTF-8 | 7,591 | 3.375 | 3 | [] | no_license | //! Scene tree structures & scene and prefab serialization.
//!
//! # Programmatically creating a scene
//!
//! The simplest way to create a single level deep scene tree is to
//! use the `scene_tree!` and `scene_node!` macros.
//!
//! ```ignore
//! use bf::tree::Component;
//! use bf::scene_tree;
//! use bf::scene_nod... | true |
de4c0528a7697710370653f755ef13323bbceb92 | Rust | TehUncleDolan/spiders | /hyraigne/src/fs.rs | UTF-8 | 3,101 | 3.546875 | 4 | [
"BSD-3-Clause"
] | permissive | //! Filesystem helpers.
use crate::{
Error,
Result,
};
use once_cell::unsync::Lazy;
use regex::Regex;
use std::{
fs,
path::{
Path,
PathBuf,
},
};
use url::Url;
/// Clean a name to safely use it as directory name.
#[allow(clippy::expect_used)] // Regexp are hardcoded and correct.
pu... | true |
2663a11df2e4c05361aa389916011c74adbb8e20 | Rust | SergeevPavel/rtrace | /src/math.rs | UTF-8 | 2,700 | 3.796875 | 4 | [] | no_license | use std::ops::{Add, Mul, Sub, Div};
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Vector {
pub x: f64,
pub y: f64,
pub z: f64,
}
impl Vector {
pub fn length(self) -> f64 {
(self * self).sqrt()
}
pub fn normalize(self) -> Vector {
self / self.length()
}
pub fn c... | true |
99f6d9d1f3abe3313fc7acd0ef88226b0e35b6c1 | Rust | ReggieMarr/audio-oxide | /docs/reference_src/old_main.rs | UTF-8 | 6,090 | 2.5625 | 3 | [] | no_license |
#[allow(unreachable_code)]
fn setup_device(cfg_settings:&mut Devicecfg) -> (StatusType) {
let mut input = String::new();
let mut cfg_complete = false;
println!("Setup custom config: s");
println!("Use Default settings: d");
println!("Quit: q");
while !cfg_complete {
match io::stdin().r... | true |
dbd1b6e5d9e7091f691762e6af1441eb3e88ac29 | Rust | ebraminio/allsorts | /src/lib.rs | UTF-8 | 4,597 | 2.640625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![warn(rust_2018_idioms)]
#![doc(html_logo_url = "https://github.com/yeslogic/allsorts/raw/master/allsorts.svg?sanitize=1")]
//! # Font parser, shaping engine, and subsetter
//!
//! Allsorts is a font parser, shaping engine, and subsetter for OpenType, WOFF, and WOFF2
//! written entirely in Rust. It was extracted fr... | true |
1bb4ec5695a7b419819792da96d33751cf7846e4 | Rust | isgasho/bam3d | /src/contact.rs | UTF-8 | 2,291 | 3.640625 | 4 | [] | no_license | //! Collision contact manifold
use glam::{Vec3};
/// Collision strategy to use for collisions.
///
/// This is used both to specify what collision strategy to use for each shape, and also each
/// found contact will have this returned on it, detailing what data is relevant in the
/// [`Contact`](struct.Contact.html).... | true |
df89e015a9023aea9b9e4ecc8fa354d38c3c908d | Rust | Arnaz87/arna-organ | /gui/src/lib.rs | UTF-8 | 3,326 | 2.953125 | 3 | [] | no_license |
extern crate image;
extern crate winapi;
extern crate user32;
extern crate kernel32;
extern crate gdi32;
#[macro_use]
extern crate lazy_static;
use std::sync::{Arc, Mutex, MutexGuard};
#[cfg(windows)]
mod windows;
pub mod widget;
/// Color en componentes RGBA de 8 bits.
#[derive(Debug)]
pub struct Color {
r: u... | true |
841499dcc5215103a6331bc0b32fd03e288863cc | Rust | nimiq/albatross-simulator | /src/logging.rs | UTF-8 | 2,389 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use std::sync::atomic::{AtomicUsize, Ordering};
use chrono::Local;
use colored::Colorize;
use fern::colors::{Color, ColoredLevelConfig};
use fern::Dispatch;
use log::LevelFilter;
static MAX_MODULE_WIDTH: AtomicUsize = AtomicUsize::new(0);
pub const DEFAULT_LEVEL: LevelFilter = LevelFilter::Info;
/// Retrieve and se... | true |
162acac0d59039aad9167b5a3269e4d38ce8f3f6 | Rust | mkubala/ncollide | /ncollide_pipeline/narrow_phase/contact_generator/default_contact_dispatcher.rs | UTF-8 | 2,985 | 2.5625 | 3 | [
"BSD-2-Clause"
] | permissive | use std::marker::PhantomData;
use math::{Point, Isometry};
use geometry::shape::{Shape, Ball, Plane};
use geometry::query::algorithms::johnson_simplex::JohnsonSimplex;
use narrow_phase::{
ContactDispatcher,
ContactAlgorithm,
BallBallContactGenerator,
PlaneSupportMapContactGenerator,
SupportMapPlaneC... | true |
ff27d4a2c17854f11fe8c62a87bba7a6c162bcf8 | Rust | isaacasensio/chip8-rust-emulator | /src/instruction.rs | UTF-8 | 656 | 3.25 | 3 | [
"MIT"
] | permissive |
pub struct Instruction {
raw: u16
}
impl Instruction {
pub fn new(raw: u16) -> Instruction {
Instruction {
raw
}
}
pub fn raw(self) -> u16{
self.raw as u16
}
pub fn op(&self) -> u8{
((self.raw & 0xF000) >> 12) as u8
}
pub fn x(&self) -> u8... | true |
87ca0f2a647b50d266a7cfca6796b8aa679e7450 | Rust | rsstdd/RIA | /ch_03_compound_data_types/src/03_newtype_pattern.rs | UTF-8 | 360 | 3.421875 | 3 | [] | no_license | #[derive(PartialEq)] // PartialEq enables types to be compared for equality.
struct Hostname(String); // Newtype
fn main() {
let ordinary_string = String::from("localhost");
let host = Hostname ( ordinary_string.clone() );
if host == ordinary_string { // Will not compile b/c Hostname and String are disti... | true |
6be4692dcb024f45a36e0ffe515ec9ccdcb97749 | Rust | seanchen1991/rune | /crates/rune/src/errors.rs | UTF-8 | 901 | 3.1875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::LoadError;
/// A collection of errors.
#[derive(Debug)]
pub struct Errors {
errors: Vec<LoadError>,
}
impl Errors {
/// Construct a new collection of errors.
pub fn new() -> Self {
Self { errors: Vec::new() }
}
/// Push an error to the collection.
pub fn push(&mut self, err... | true |
4eed802115e6e6b12ea9bf47609f76a9c7d33534 | Rust | fengshux/zhengma | /src/bin/init.rs | UTF-8 | 2,509 | 3.25 | 3 | [] | no_license |
use std::fs;
use std::collections::HashMap;
use std::fs::File;
use std::io::{BufWriter, Write};
fn main() {
data_to_hash_file();
}
// 把data里的数据装载到map里
pub fn load_data_to_map_full_code(path: &str) -> Box<HashMap<String,Vec<String>>> {
let mut dict: Box<HashMap<String, Vec<String>>> = Box::new(HashMap::n... | true |
99e67c6597306cd7e2293e18f2cfb711dd3ef7eb | Rust | palindrom615/problem-solving | /src/bin/blank.rs | UTF-8 | 614 | 2.734375 | 3 | [] | no_license | use problem_solving::utils::*;
fn main() {
let t: i32 = read_line()[0];
for i in 0..t {
let answer = 0;
/////////////////////////////////////////////////////////////////////////////////////////////
/*
Implement your algorithm here.
The answer to the case will be stor... | true |
82b0bd8c4178ad810b8a9ef292bbf7f8a31611e4 | Rust | owen8877/leetcode-rs | /src/problem_242.rs | UTF-8 | 353 | 3.125 | 3 | [] | no_license | pub fn is_anagram(s: String, t: String) -> bool {
let mut count = vec![0; 26];
for c in s.chars() {
count[(c as u8 - 'a' as u8) as usize] += 1;
}
for c in t.chars() {
let index = (c as u8 - 'a' as u8) as usize;
if count[index] == 0 {
return false;
}
co... | true |
ca6b2ee48788a0a2cdc06af62c9db483727a3d32 | Rust | fitzgen/fart | /crates/cli/src/watcher.rs | UTF-8 | 3,111 | 2.921875 | 3 | [] | no_license | //! Watching, re-building, and re-running `fart` projects.
use crate::{output::Output, run::Run, Result};
use failure::ResultExt;
use notify::Watcher as _;
use std::io::Write;
use std::path::PathBuf;
use std::sync::{mpsc, Arc, Mutex};
use std::time;
pub struct Watcher {
project: PathBuf,
extra: Vec<String>,
... | true |
dd7b2e15198fb9d99032842b87c91288a9f78ee4 | Rust | starblue/advent_of_code | /a2018/src/bin/a201809a.rs | UTF-8 | 1,702 | 3.03125 | 3 | [] | no_license | use std::io;
use std::iter::repeat;
use std::str::FromStr;
use nom::bytes::complete::tag;
use nom::character::complete::digit1;
use nom::combinator::map_res;
use nom::IResult;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
struct Config {
n_players: i32,
last_marble: i32,
}
// 459 players; las... | true |
86b618c7e40f0423ac15c5824772e5025aadc3ba | Rust | svenstaro/proxyboi | /src/config.rs | UTF-8 | 2,217 | 2.921875 | 3 | [
"MIT"
] | permissive | use actix_web::http::{HeaderMap, HeaderName, HeaderValue};
use clap::Parser;
use std::net::SocketAddr;
use std::path::PathBuf;
use url::Url;
/// Parse a header given in a string format into a `HeaderMap`
///
/// Headers are expected to be in format "key:value".
fn parse_header(header: &str) -> Result<HeaderMap, String... | true |
aeb9cfe35ce85fdbf13a15d966a154026b914d63 | Rust | lineCode/tuix | /core/src/systems/hover_system.rs | UTF-8 | 5,798 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::{Display, Entity, Event, PropGet, PropSet, Propagation, State, Units, Visibility, WindowEvent};
/// Determines the hovered entity based on the mouse cursor position
pub fn apply_hover(state: &mut State) {
let mut draw_tree: Vec<Entity> = state.tree.into_iter().collect();
// This should be cached so... | true |
88f5299455a1a7525bf28fdca042642fde09dea9 | Rust | ani003/prusti_panic_test | /panics/13/word_wrap/word_wrap.rs | UTF-8 | 2,689 | 3.578125 | 4 | [
"MIT"
] | permissive | #[derive(Clone, Debug)]
pub struct LineComposer<I> {
words: I,
width: usize,
current: Option<String>,
}
impl<I> LineComposer<I> {
pub(crate) fn new<S>(words: I, width: usize) -> Self
where
I: Iterator<Item = S>,
S: AsRef<str>,
{
LineComposer {
words,
... | true |
9adfbb3e7adc2e2f95402da540b7d172b60bcb47 | Rust | haydenbaker/MySync | /src/log.rs | UTF-8 | 680 | 3.125 | 3 | [] | no_license | /* logging functionality */
pub enum LogLevel {
Debug,
Info,
Warning,
Critical
}
pub fn log(verbosity: LogLevel, msg: &str) {
let dt = chrono::Utc::now().format("%Y-%m-%d %H:%M:%S").to_string();
match verbosity {
LogLevel::Debug => {
println!("[{}] {:>10} - {}", dt, "DEBUG" ... | true |
068379c3c81c041efac39ec3b4a337cd84c9b24b | Rust | nintha/talent-plan-rust-pna | /project-4/src/model.rs | UTF-8 | 7,135 | 3.625 | 4 | [] | no_license | //! struct or enum
use serde::{Deserialize, Serialize};
use std::net::TcpStream;
use std::io::Read;
use crate::Result;
use crate::error::KvsError;
#[allow(missing_docs)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum Behavior {
/// The user invokes kvs set mykey myvalue
Set { key: String, value: Str... | true |
69ba08aa7af6136f80858fe05f18d886d8925f46 | Rust | jeffparsons/grit-rs | /git-object/src/immutable/blob.rs | UTF-8 | 487 | 3.296875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::convert::Infallible;
/// A chunk of any [`data`][Blob::data].
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct Blob<'a> {
/// The bytes themselves.
pub data: &'a [u8],
}
impl<'a> Blob<'a> {
/// I... | true |
4270c891268521c9c072b8597d997fce5c12bf89 | Rust | lotabout/tuikit | /src/widget/util.rs | UTF-8 | 2,713 | 2.9375 | 3 | [
"MIT"
] | permissive | use crate::event::Event;
use crate::key::Key;
use crate::widget::Rectangle;
pub fn adjust_event(event: Event, inner_rect: Rectangle) -> Option<Event> {
match event {
Event::Key(Key::MousePress(button, row, col)) => {
if inner_rect.contains(row as usize, col as usize) {
let (row,... | true |
51f0bc0b20695779eb2636fe72570badc5967dc5 | Rust | hawkingrei/image-gif | /src/batch/mod.rs | UTF-8 | 7,237 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use common::{DisposalMethod, Frame};
use encoder::Encoder;
use reader::ColorOutput;
use reader::Decoder;
use reader::StreamingDecoder;
use std::cell::Cell;
use std::io;
use std::io::prelude::*;
use std::sync::Arc;
struct BatchFrame {
Frame: Frame<'static>,
transparent_color: Option<[u8; 3]>,
color_table: V... | true |
5bebe87dbfb628f02ee9e0428cacd23c14cb3b17 | Rust | canndrew/error_defs | /examples/example.rs | UTF-8 | 1,376 | 2.84375 | 3 | [] | no_license | #[macro_use(error_defs)]
extern crate error_defs;
use std::io;
use std::error::Error;
error_defs! {
error Example<T, U: Error> {
VariantA
=> "short description",
VariantB
=> "another short description" ("long description, 23 == {}.", 23),
VariantC { arg0: u32, arg1:... | true |
ecd077ecf80d9c506a8f2c065a54b5e76a0addc7 | Rust | jdalberg/tr181-validate | /src/lib.rs | UTF-8 | 27,979 | 3.125 | 3 | [
"Unlicense"
] | permissive | use std::collections::HashMap;
use std::fs::File;
use std::io::BufReader;
use xml::reader::{EventReader, XmlEvent};
/// Pathref contains the special pathRef string syntax
#[derive(Debug, Eq, PartialEq, Hash, Default, Clone)]
struct PathRef {
ref_type: String,
target_parent: String,
target_type: String,
}
#[deri... | true |
f56fdf9bd1a3375c443f73ff5eee841a9049a903 | Rust | muskanmahajan37/fizz-buzz-rs | /test.rs | UTF-8 | 934 | 3.828125 | 4 | [] | no_license | fn div_by_three(num: int) -> bool {
num % 3 == 0
}
fn div_by_five(num: int) -> bool {
num % 5 == 0
}
fn div_by_fifteen(num: int) -> bool {
num % 15 == 0
}
#[test]
fn test_div_by_three() {
let num = 1;
if div_by_three(num) {
fail!("{} is not a multiple of 3", num);
}
}
#[test]
fn test_div_b... | true |
f1754a938c68f51dcf0191f642704ec604b8f15c | Rust | Nimor111/Infodium | /src/models/player_game.rs | UTF-8 | 1,173 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | //! Module representing a PlayerGame entity in the api database
use diesel;
use diesel::pg::PgConnection;
use diesel::prelude::*;
use schema::player_games;
use schema::player_games::dsl::*;
use models::game::Game;
use models::player::Player;
/// Struct representing a single row in the `player_games` table of the da... | true |
1e438255601e182ccb4e8298879fc6ff07bb976f | Rust | dalalsunil1986/spinel | /src/arch/amd64/devices/text_mode_tty.rs | UTF-8 | 5,793 | 3.265625 | 3 | [
"MIT"
] | permissive | use core::fmt;
use core::ptr::{read_volatile, write_volatile};
use lazy_static::lazy_static;
use num_derive::{FromPrimitive, ToPrimitive};
use num_traits::cast::{FromPrimitive, ToPrimitive};
use spin::Mutex;
const SCREEN_COLUMNS: isize = 80;
const SCREEN_ROWS: isize = 25;
lazy_static! {
/// Global terminal contex... | true |
e30a7539701908d6da24ce37651c308f79bb96b6 | Rust | BenjaminWFox/need-find-tribbles-js13k2021 | /near-protocol/tests/sim/test_core.rs | UTF-8 | 3,213 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::utils::{init, TOKEN_ID};
use near_contract_standards::non_fungible_token::Token;
use near_sdk_sim::{call, view};
#[test]
fn simulate_simple_transfer() {
let (root, nft, alice, _, _) = init();
let token: Token = view!(nft.nft_token(TOKEN_ID.into())).unwrap_json();
assert_eq!(token.owner_id, root... | true |
dcb63c517016af2b6be857d6bbca231ad0094739 | Rust | gbmhunter/AdventOfCode2019 | /advent_of_code_2019/src/day03/mod.rs | UTF-8 | 3,586 | 3.28125 | 3 | [] | no_license | use std::fs;
use std::collections::HashMap;
pub fn main() {
let input = fs::read_to_string("src/day03/input.txt").unwrap();
let input_by_line: Vec<&str> = input.split("\n").collect();
let line_positions_1 = parse_line(input_by_line[0]);
let line_positions_2 = parse_line(input_by_line[1]);
let ... | true |
df4f320aa4cc5b731d959613d91918599e0b6ff2 | Rust | timefly-1989/abstreet | /abstio/src/http.rs | UTF-8 | 1,013 | 3 | 3 | [
"Apache-2.0"
] | permissive | use anyhow::Result;
/// Performs an HTTP POST request and returns the response.
pub async fn http_post<I: AsRef<str>>(url: I, body: String) -> Result<String> {
let url = url.as_ref();
info!("HTTP POST to {}", url);
let resp = reqwest::Client::new().post(url).body(body).send().await?;
let status = resp.... | true |
8e3abaa03200d2021c2a4206912178c7f084ade8 | Rust | clojit/legacy-clojit-vm | /src/diag.rs | UTF-8 | 893 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::fmt::Show;
use std::num::FromPrimitive;
use vm;
use vm::Instr;
use vm::OpCode;
use decode::Decode;
use decode::from_instr;
use decode::OpAD;
use decode::OpABC;
impl Show for OpABC {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let op: OpCode = FromPrimitive::from_u8(self.... | true |
8c53dd3b1f8205637825b4687c9a498c6ab08b3a | Rust | farico/openrtb2 | /src/banner_ad_type.rs | UTF-8 | 1,169 | 3.21875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use serde_repr::{Deserialize_repr, Serialize_repr};
/// 5.2 Banner Ad Types
///
/// The following table indicates the types of ads that can be accepted by the exchange unless
/// restricted by publisher site settings.
#[derive(Serialize_repr, Deserialize_repr, Debug, PartialEq, Eq, Clone, Copy)]
#[repr(i32)]
pub enum ... | true |
fbb546deed05fb9bc4a058565e243b344dec72eb | Rust | zvolin/peach-8 | /peach8/src/builder.rs | UTF-8 | 1,510 | 3.25 | 3 | [
"MIT"
] | permissive | use crate::context::Context;
use crate::peach::Peach8;
pub struct Builder<'a, C: Context + Sized> {
context: Option<C>,
program: Option<&'a [u8]>,
}
impl<'a, C: Context + Sized> Builder<'a, C> {
pub fn new() -> Self {
Self {
context: None,
program: None,
}
}
... | true |
f657d07f3bfdfbe03cd6c3422c2d8638f13ff071 | Rust | Dzejkop/crowley | /src/scrape.rs | UTF-8 | 6,870 | 2.703125 | 3 | [] | no_license | use crate::db::get_connection;
use crate::UrlEncodedUrl;
use anyhow::anyhow;
use futures::future;
use hyper::header::CONTENT_TYPE;
use scraper::Selector;
use std::collections::HashSet;
use url::Url;
const BATCH_SIZE: usize = 128;
pub async fn scrape_or_fail(root_url: UrlEncodedUrl) -> anyhow::Result<()> {
let roo... | true |
48e26a0c83eb72bb11e6b6a9c74d0ae47f35587c | Rust | tylerwhall/rust | /src/test/compile-fail/borrowck-partial-reinit-4.rs | UTF-8 | 820 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"MIT",
"Unlicense",
"BSD-3-Clause",
"bzip2-1.0.6",
"NCSA",
"ISC",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | // Copyright 2015 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 ... | true |
0131b6d7e08106b91ffe9db9a62199a57df470d1 | Rust | gaycodegal/wander-interactive-fiction-engine | /rust/ift/sentence.rs | UTF-8 | 6,681 | 2.921875 | 3 | [
"MIT"
] | permissive | use cfg::ast::AST;
use cfg::ast_search::ASTSearch;
use cfg::lang::Lang;
use serde_json::Value;
use std::fmt;
pub struct NounClause {
pub noun: String,
count: Option<String>,
pub adjective: Option<String>,
}
impl NounClause {
pub fn new(
noun: String,
count: Option<String>,
adje... | true |
6224f88ade555788157f632a33c5097f0dbb6ec4 | Rust | sindreij/crafting-interpreters | /lox-treewalker/src/parser.rs | UTF-8 | 17,660 | 3.171875 | 3 | [] | no_license | use crate::{
ast::{Expr, Literal, Stmt, StmtFunction, VariableExpr},
error_reporter::format_err,
token::{Token, TokenType},
};
use std::sync::atomic::{AtomicUsize, Ordering};
static EXPR_COUNTER: AtomicUsize = AtomicUsize::new(1);
fn next_expr_id() -> usize {
EXPR_COUNTER.fetch_add(1, Ordering::Relaxe... | true |
6228803153a5f4ec83b7c06e9c68ea241c20ea6d | Rust | TheRenegadeCoder/sample-programs | /archive/r/rust/fraction-math.rs | UTF-8 | 5,378 | 3.78125 | 4 | [
"MIT"
] | permissive | use std::env::args;
use std::process::exit;
use std::str::FromStr;
use std::fmt;
use std::ops;
use std::cmp::Ordering;
fn usage() -> ! {
println!("Usage: ./fraction-math operand1 operator operand2");
exit(0);
}
fn parse_int<T: FromStr>(s: &str) -> Result<T, <T as FromStr>::Err> {
s.trim().parse::<T>()
}
... | true |
755cef5a1979f7aa8a76e1582f2c09f8161b1ae3 | Rust | attilahorvath/advent-of-code-2019 | /intcode/src/lib.rs | UTF-8 | 16,411 | 3.203125 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fmt;
use std::str::FromStr;
use std::sync::mpsc;
use std::sync::mpsc::TryRecvError;
const MEMORY_SIZE: usize = 4096;
pub type ValueType = i64;
#[derive(Clone, Copy)]
enum ParameterMode {
Position = 0,
Immediate = 1,
Relative = 2,
}
impl ParameterMode {
fn parse_nth_dig... | true |
8c1a421432b86fc8348d828d88eaaf8e592cf5ed | Rust | hurdissej/explorerust | /mmm/src/main.rs | UTF-8 | 978 | 3.3125 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let mut numbers: Vec<i32> = vec![4, 3, 2, 10, 324, 21, 8, 8];
numbers.sort();
let mut tot = 0;
let mut contents : HashMap<i32, i32> = HashMap::new();
for num in &numbers {
let count = contents.entry(*num).or_insert(0);
*count += 1;
... | true |
2ec133627cb9b675ab0b32b8bfdd7b91259c815c | Rust | wearypossum4770/silver-umbrella | /unsorted/convert_minutes_to_seconds.rs | UTF-8 | 514 | 3.28125 | 3 | [] | no_license | /// copyright https://edabit.com/challenge/8q54MKnRrm89pSLmW
pub fn convert_minutes_to_seconds(minutes:i32)-> i32{
let seconds: i32 = minutes*60;
seconds
}
#[cfg(test)]
mod tests {
use super::convert_minutes_to_seconds;
#[test]
fn test_convert_minutes_to_seconds() {
assert_eq!(convert_minutes_to_se... | true |
645d99e06415cba7005e0ee0eb64b10560c5b037 | Rust | ytakhs/leetcode-rs | /examples/archives/squares_of_a_sorted_array.rs | UTF-8 | 360 | 3.25 | 3 | [] | no_license | struct Solution {}
impl Solution {
pub fn sorted_squares(a: Vec<i32>) -> Vec<i32> {
let mut a = a;
a.sort_by(|a, b| a.abs().partial_cmp(&b.abs()).unwrap());
a.into_iter().map(|v| v * v).collect()
}
}
fn main() {
assert_eq!(
Solution::sorted_squares(vec![-4, -1, 0, 3, 10]),
... | true |
74d3ecba3073f47d0a16e60a649466f755cb8510 | Rust | memorysafety/sudo-rs | /test-framework/sudo-compliance-tests/src/sudo/lecture.rs | UTF-8 | 4,694 | 2.765625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::{
Result, OG_SUDO_STANDARD_LECTURE, PASSWORD, SUDOERS_ALWAYS_LECTURE, SUDOERS_NO_LECTURE,
SUDOERS_ONCE_LECTURE, SUDOERS_ROOT_ALL, SUDOERS_USER_ALL_ALL, SUDOERS_USER_ALL_NOPASSWD,
USERNAME,
};
use sudo_test::{Command, Env, User};
#[test]
#[ignore = "gh399"]
fn default_lecture_shown_once() -> Resu... | true |
4cfda51366b8c29a02adc67667e5095c97ff6f72 | Rust | jieyouxu/ray-tracer | /src/ppm/encode.rs | UTF-8 | 405 | 2.765625 | 3 | [] | no_license | //! Encodes a supplied pixel buffer and encodes it in the proper PPM format and writes it out
//! using the provided writer.
use super::PpmHeader;
use std::io::Write;
/// Encoder responsible for encoding a provided pixel buffer into a plain-text PPM image format
/// and write it out using the supplied writer.
#[deri... | true |
afda00b1c1c98603a9b5e8be7b88779c92947812 | Rust | sflanaga/wc | /src/walktar.rs | UTF-8 | 3,462 | 2.78125 | 3 | [] | no_license | extern crate flate2;
extern crate tar;
extern crate csv;
use std::fs::File;
use std::fs::OpenOptions;
use flate2::read::GzDecoder;
use tar::Archive;
use std::env::args;
use std::io::Read;
use std::io::BufReader;
use std::io::BufRead;
use std::io::BufWriter;
use std::io::Write;
use std::collections::BTree... | true |
7c02b08089fc28d260d1b99428934eda031646fa | Rust | allonsy/advent2017 | /day3/main2.rs | UTF-8 | 2,578 | 3.34375 | 3 | [
"MIT"
] | permissive | const TARGET_NUMBER: i32 = 368078;
const ARRAY_LENGTH: usize = 1000;
enum Direction {
Up,
Down,
Left,
Right,
}
impl Direction {
fn next(self) -> Direction {
match self {
Direction::Up => Direction::Left,
Direction::Left => Direction::Down,
Direction::Dow... | true |
a8ab18eeeb4e3632ad138e51827e4cc9126f319b | Rust | gunjunlee/ps | /baekjoon/src/bin/10996.rs | UTF-8 | 319 | 2.78125 | 3 | [] | no_license | fn main() {
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).unwrap();
let num: i32 = buffer.trim().parse().unwrap();
for row in 0..2 * num {
for col in 0..num {
print!("{}", if (col + row) % 2 == 0 { "*" } else { " " });
}
println!();
}
}
| true |
6fa3dfedcceef3a28b7300846611996df8cccff4 | Rust | AndWass/txrx | /txrx/src/consumers/sync_wait.rs | UTF-8 | 2,625 | 2.84375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::priv_sync::AsyncValue;
use crate::traits::{Receiver, Sender};
use std::sync::Arc;
#[derive(Debug)]
pub enum WaitResult<V> {
Value(V),
Error(crate::Error),
Cancelled,
}
impl<V> WaitResult<V> {
pub fn unwrap(self) -> V {
match self {
WaitResult::Value(v) => v,
... | true |
820f27bdeb92c763e74bc4706995398f7360540e | Rust | joedane/raytracer-challenge | /ch1/src/material.rs | UTF-8 | 16,956 | 3.28125 | 3 | [] | no_license |
use crate::vec::{Point, Vector};
use crate::color::Color;
use crate::transform::Matrix;
use crate::shape::Shape;
use std::fmt;
use std::borrow::Borrow;
#[derive(Debug, Clone)]
pub struct Light {
pub intensity: Color,
pub position: Point
}
impl Light {
pub fn new(i: Color, p: Point) -> ... | true |
c9e5000d684a9a245a1c7856f11a9eb119d17d9c | Rust | ritiek/piano-rs | /src/arguments.rs | UTF-8 | 4,997 | 3.015625 | 3 | [
"MIT"
] | permissive | use clap::{Arg, App, ArgMatches};
use clap::value_t;
use std::net::SocketAddr;
pub struct Options {
pub host_address: SocketAddr,
pub volume: f32,
pub record_file: Option<String>,
pub play_file: Option<String>,
pub play_file_tempo: f32,
pub sequence: i8,
pub note_duration: u64,
pub mark... | true |
dff7efee395ec07b3b8c697c9c39e6b0493bbb81 | Rust | Soft/buttons | /src/manifest.rs | UTF-8 | 1,389 | 2.546875 | 3 | [
"MIT"
] | permissive | use lazy_static::*;
use serde::Serialize;
use std::default::Default;
use std::sync::Arc;
use tera::Tera;
use warp::http::StatusCode;
use crate::state;
lazy_static! {
static ref TEMPLATE: Tera = {
let mut template: Tera = Default::default();
template
.add_raw_template(
"... | true |
a3d7b83f771842f388715996198bc8d33bfac9de | Rust | fredrikpe/less-in-rust | /src/printer.rs | UTF-8 | 5,682 | 2.890625 | 3 | [] | no_license | use termion::color;
use termion::screen::AlternateScreen;
use unicode_segmentation::UnicodeSegmentation;
use std::io::Write;
use std::str;
use grep::matcher::Match;
use controller::Controller;
use util;
struct ColoredString {
string: String,
color: bool,
}
impl ColoredString {
pub fn new(s: &str, color... | true |
3cb27fbbb0af3aa6740c537e65ca0ea26edfb9db | Rust | kamioftea/advent-of-code-2020 | /src/day_14.rs | UTF-8 | 12,560 | 3.890625 | 4 | [] | no_license | //! This is my solution for [Advent of Code - Day 14](https://adventofcode.com/2020/day/14) -
//! _Docking Data_
//!
//! This was themed around bitwise operations. The challenge was mostly parsing the puzzle
//! description into the bitwise operations needed. This was the first time I needed an Either
//! implementatio... | true |
8b4e3256f83e20cae8499dd5e4ea02cb6ec30dd0 | Rust | xenia-project/xell-rs | /shared/xenon-cpu/src/intrin.rs | UTF-8 | 1,411 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[inline]
pub fn mftb() -> u128 {
let mut tbu: u64;
let mut tbl: u64;
let mut tbu2: u64;
loop {
unsafe {
asm!(
"mftbu {0}",
"mftb {1}",
"mftbu {2}",
out(reg) tbu,
out(reg) tbl,
out(reg) ... | true |
8e242b4e16ff959d3d469b729f556618ffab481a | Rust | johndaniels/rusttls | /testexe/src/main.rs | UTF-8 | 85 | 2.515625 | 3 | [] | no_license | fn main() {
tlslib::client::connect().unwrap();
println!("Hello, world!");
}
| true |
b2bd3f5d39a292ca584529ae57cf6952ad5835cd | Rust | andyyu2004/l-lang | /src/lc-typeck/src/tests/parametric_tests.rs | UTF-8 | 3,370 | 3.328125 | 3 | [] | no_license | //! generics and parametric polymorphism
use super::*;
#[test]
fn generic_type_alias() {
let src = r#"
type P<T> = S<T, int>;
fn construct_p() -> P<bool> {
P { t: false, u: 9 }
}
struct S<T, U> {
t: T,
u: U,
}"#;
typeck!(src);
}
#[test]
fn incorrect_number_of_ge... | true |
5210428dc0f3e45105aecda2e7dd286450a20c61 | Rust | Byron/gitoxide | /gix-status/src/index_as_worktree/types.rs | UTF-8 | 3,113 | 3 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use bstr::BStr;
/// The error returned by [`status()`](crate::index_as_worktree()).
#[derive(Debug, thiserror::Error)]
#[allow(missing_docs)]
pub enum Error {
#[error("Could not convert path to UTF8")]
IllformedUtf8,
#[error("The clock was off when reading file related metadata after updating a file on dis... | true |
f5142b4341603ad77ee6bd711a197c758c3b3d06 | Rust | splintersuidman/zermelo-rs | /src/lib.rs | UTF-8 | 2,021 | 3.5625 | 4 | [
"MIT"
] | permissive | //! This is a crate that can be used to retrieve a schedule from [Zermelo](https://www.zermelo.nl/).
//! The goal of this crate is to be easy to use, whilst also being powerful.
//!
//! # Examples
//!
//! ## Obtaining an access token
//! ```no_run
//! let school = "example";
//! let code = "123456789012";
//!
//! let s... | true |
bbdd37882dd7e033893e7c0225e73299ac54b0b6 | Rust | sdroege/gobject-example-rs | /src/shared_rstring/imp.rs | UTF-8 | 2,127 | 2.703125 | 3 | [] | no_license | use std::sync::Arc;
// No #[repr(C)] here as we export it as an opaque struct
// If it was not opaque, it must be #[repr(C)]
#[derive(Clone, Debug, PartialEq, Eq, glib::Boxed)]
#[boxed_type(name = "ExSharedRString")]
pub struct SharedRString(Arc<Option<String>>);
impl SharedRString {
fn new(s: Option<String>) -> ... | true |
64ebc8fb1b5d8c9195bfea985de008cbf0df37f7 | Rust | micahscopes/rugl | /src/webgl/uniform.rs | UTF-8 | 1,796 | 3.171875 | 3 | [
"MIT"
] | permissive | /*!
The Uniform class holds a vector of the inner types and offers many coersions of other types.
*/
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum UniformInner {
Uniform1i(i32),
Uniform1f(f32),
Uniform2i(i32, i32),
Uniform2f(f32, f32),
Uniform3i(i32, i32, i32),
Uniform3f(f32, f32, f32),
... | true |
275d03a4fdcb3468aa4b5698d12b15d4101d5eb4 | Rust | jvff/protocol-interceptor | /src/channel_factory.rs | UTF-8 | 2,467 | 2.796875 | 3 | [] | no_license | use std::collections::VecDeque;
use futures::Async;
use futures::task;
use futures::task::Task;
use futures::sync::BiLock;
use tokio_io::AsyncRead;
use tokio_io::io::{ReadHalf, WriteHalf};
use super::io::IoQueue;
use super::read_channels::ReadChannels;
use super::write_channels::WriteChannels;
pub(crate) type ReadCh... | true |
10649da76fce140b34a99665dd27444a7f0137ab | Rust | gs-akhan/learning-rust | /src/clock_better.rs | UTF-8 | 1,050 | 3.546875 | 4 | [
"MIT"
] | permissive | use std::fmt;
#[derive(Debug, PartialEq, Eq)]
pub struct Clock {
hours: i32,
minutes: i32,
}
const MINUTES_IN_A_DAY: i32 = 1440;
const MINUTES_IN_AN_HOUR: i32 = 60;
impl Clock {
pub fn new(hours: i32, minutes: i32) -> Self {
let mut all_minutes = hours * MINUTES_IN_AN_HOUR + minutes;
all_... | true |
56d221cca34152047fd3025cce069ea8cd9a8244 | Rust | tjhaskel/tjhaskel | /src/main.rs | UTF-8 | 723 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::time::Duration;
use simpleterm_profile::{art::*, text::*, terminal::Terminal};
fn main() {
// Create a window and display the GEO art (from art.rs) for 2 seconds.
let mut term: Terminal = Terminal::new("simpleterm test", (420, 120), DARK_GREY, EMERALD, "LeagueSpartan-Regular.ttf", 32);
term.art_f... | true |
e11d659db657323087d429d887e4400804cfdc13 | Rust | danielhenrymantilla/macro_rules_attribute-rs | /src/proc_macro/mod.rs | UTF-8 | 9,033 | 3.046875 | 3 | [
"Zlib",
"Apache-2.0",
"MIT"
] | permissive | //! Do not use this crate directly. Instead, use [`::macro_rules_attribute`](
//! https://docs.rs/macro_rules_attribute)
use {
::core::{
ops::Not as _,
iter::FromIterator as _,
},
::proc_macro::{*,
TokenTree as TT,
},
};
// See the re-export at the frontend (`src/lib.rs`) for t... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.