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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
bb1d19d1cb9fdfe2779476be551a376bd3acd8f6 | Rust | jrmuizel/glsl | /glsl/src/transpiler/spirv.rs | UTF-8 | 3,292 | 3.09375 | 3 | [
"BSD-3-Clause"
] | permissive | //! SPIR-V transpiler.
//!
//! The current implementation uses the [shaderc](https://crates.io/crates/shaderc) crate to
//! transpile GLSL to SPIR-V. This is not ideal but will provide a default and starting
//! implementation.
use shaderc;
use crate::syntax;
use crate::transpiler::glsl as glsl_transpiler;
#[derive(... | true |
df96b3a7aa8b2c3ace217c33ae0239ac8eeea042 | Rust | hartmantis/sheepit | /src/changelog/change.rs | UTF-8 | 2,495 | 3.328125 | 3 | [] | no_license | //
// Author:: Jonathan Hartman (<j@p4nt5.com>)
// License:: Apache License, Version 2.0
//
// Copyright (C) 2015, Jonathan Hartman
//
// 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
//
// ... | true |
e63b1f6e4675baabce90394fff448c55ab773adc | Rust | gz/autoperf | /src/util.rs | UTF-8 | 12,546 | 2.578125 | 3 | [
"MIT"
] | permissive | #![allow(unused)]
use csv;
use itertools::*;
use log::error as lerror;
use log::*;
use nom::*;
use std::fs;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::path::Path;
use std::path::PathBuf;
use std::process::{Command, Output};
use std::str::{from_utf8_unchecked, FromStr};
use x86::cpuid;
pub type ... | true |
7763aebdd49fce200baf769385b60872b0474a92 | Rust | aguang-xyz/leetcode-rust | /src/solution/s0044_wildcard_matching.rs | UTF-8 | 2,002 | 3.453125 | 3 | [] | no_license | pub struct Solution {}
impl Solution {
pub fn is_match(s: String, p: String) -> bool {
let s: Vec<char> = s.chars().collect();
let p: Vec<char> = p.chars().collect();
let is_match = |s, p| s == p || p == '?';
let mut f: Vec<Vec<bool>> = vec![vec![false; p.len() + 1]; s.len() + 1];... | true |
0aa4409dc4ae6c39d1fe4e968c1caab612f6a70b | Rust | yuichi-morisaki/rust-tutorial | /book/ch19_advanced-features/never-type/src/main.rs | UTF-8 | 604 | 3.6875 | 4 | [] | no_license | fn bar() -> ! {
loop {}
}
fn main() {
let guess = String::from("Hello");
/* error: `match` arms have incompatible types
let guess: u32 = match guess.trim().parse() {
Ok(num) => num,
Err(_) => "hello",
};
*/
loop {
let guess: u32 = match guess.trim().parse() {
... | true |
fd018b49933addc0dde2e56e6c83814c6f982b22 | Rust | franleplant/frd-lisp | /src/lisp_value.rs | UTF-8 | 3,527 | 3.296875 | 3 | [] | no_license | use log::debug;
use std::cmp::Ordering;
use std::collections::HashMap;
use std::fmt;
use std::rc::Rc;
use crate::ast::Expr;
use crate::env::Env;
use crate::eval::eval_expression;
//TODO rename this to value
#[derive(Clone)]
pub enum LispValue {
Nill,
Id(String),
Int(i64),
Bool(Bool),
Intrinsic(f... | true |
c7f7d376deea874e38ba29466f00c98c9ce799e0 | Rust | jeremyletang/whl-puller | /src/unesco_xml.rs | UTF-8 | 1,746 | 2.640625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2017 Jeremy Letang.
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to ... | true |
fa7594c8d116f7f8b865fa2e2b5911e963d07407 | Rust | jjsloboda/aoc2019 | /intcode/src/lib.rs | UTF-8 | 1,281 | 3.453125 | 3 | [] | no_license |
pub fn execute(mem: &mut Vec<i32>) -> i32 {
let mut cursor = 0;
loop {
if mem[cursor] == 99 {
return mem[0];
}
let loc1 = mem[cursor+1] as usize;
let loc2 = mem[cursor+2] as usize;
let loc3 = mem[cursor+3] as usize;
match mem[cursor] {
1 =... | true |
f537626a021d03ef487ab6ee082873cc5eb43750 | Rust | vernonrj/advent2020 | /day-2/src/main.rs | UTF-8 | 7,595 | 3.109375 | 3 | [] | no_license | #[macro_use] extern crate lazy_static;
use std::{error::Error, ops::{RangeInclusive}};
use std::io::{self, Read, BufRead, BufReader};
use std::fs::File;
use std::str::FromStr;
use clap::{App, Arg};
use regex::Regex;
fn main() -> Result<(), Box<dyn Error>> {
let matches = App::new("day-2")
.arg(Arg::w... | true |
53b4a77f93b6f3e064b027639ec3fcd8a4112bcd | Rust | Luni-4/iced_aw | /src/style/spinner.rs | UTF-8 | 1,045 | 3.265625 | 3 | [
"MIT"
] | permissive | //! Use a spinner to suggest to the user something is loading.
//!
//! *This API requires the following crate features to be activated: spinner*
use iced_style::Theme;
/// The style of a [`Spinner`](crate::native::spinner::Spinner).
#[derive(Default)]
#[allow(missing_debug_implementations)]
pub enum SpinnerStyle {
... | true |
f13de87af6a6a78fafe00ccaf29dc4e75ee1c306 | Rust | poulenque/glium_fractal | /src/file_to_string.rs | UTF-8 | 335 | 2.703125 | 3 | [] | no_license | use std::path::Path;
use std::fs::File;
use std::io::Read;
use std::io;
pub fn file_to_string(path:String) -> io::Result<String> {
let path = Path::new(&path);
let mut file = match File::open(&path) {
Ok(f)=>f,
Err(why)=> return Err(why),
};
let mut s = String::new();
let _unused_var = file.read_to_string(&mu... | true |
ff94bea57dcb9273b4af6463f397b323fcdbcfd7 | Rust | mvanbem/oot-explorer | /oot-explorer-segment/src/segment.rs | UTF-8 | 1,162 | 2.90625 | 3 | [
"MIT"
] | permissive | use std::fmt::{self, Debug, Formatter};
use crate::SegmentError;
#[derive(Clone, Copy, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Segment(pub u8);
impl Segment {
pub const SCENE: Segment = Segment(0x02);
pub const ROOM: Segment = Segment(0x03);
pub const GAMEPLAY_KEEP: Segment = Segment(0x04);
... | true |
7903d935702cb60a67a2efe0df9225272317a98c | Rust | schets/atomic_utilities | /src/artificial_dep.rs | UTF-8 | 4,260 | 3.25 | 3 | [
"MIT"
] | permissive | //! This module provides a function that forces an artificial data dependency
//! between two loads. Basically, the code:
//!
//! ```text
//! val = some_atomic.load(DepOrd);
//! val2_ref = &val2;
//! val2 ref ^= val;
//! val2_ref ^= val; // val_2 ref now is equal to &val2, but data depends on val
//! loaded_val2 = *val... | true |
33d25fb48dfaa2cef467e49c62029fd51ff8613a | Rust | oxigraph/oxigraph | /lib/sparesults/src/xml.rs | UTF-8 | 26,347 | 2.578125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Implementation of [SPARQL Query Results XML Format](https://www.w3.org/TR/rdf-sparql-XMLres/)
use crate::error::{ParseError, SyntaxError};
use oxrdf::vocab::rdf;
use oxrdf::Variable;
use oxrdf::*;
use quick_xml::events::{BytesDecl, BytesEnd, BytesStart, BytesText, Event};
use quick_xml::{Reader, Writer};
use std::... | true |
9d66732197179cfb0b8bd99d9de19d9f1f841c78 | Rust | foxfriends/root | /src/models/cult.rs | UTF-8 | 1,201 | 2.734375 | 3 | [] | no_license | #![allow(clippy::new_without_default)]
use super::*;
use sqlx::{postgres::PgConnection, query, query_as};
#[derive(Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename = "cult")]
pub struct Cult {
faction: FactionId,
outcast: Option<Suit>,
hated_outcast: bool,
}
impl Cult {
pub fn new() -> Sel... | true |
d0e884ecc9f4e69171f7aa287b1436b8dcead62b | Rust | rbudnar/rust-mazes | /crate/src/grid/standard_grid.rs | UTF-8 | 2,319 | 3.0625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::rc::{Rc};
use super::{grid_base::GridBase, Grid, CellFormatter};
use crate::cells::{ICellStrong, cell::{Cell, CellLinkStrong}};
use crate::rng::RngWrapper;
pub static STANDARD_GRID: &str = "standard_grid";
pub struct StandardGrid {
pub grid: GridBase,
}
impl StandardGrid {
pub fn new(rows: usize, co... | true |
eecd2980b03ca476e8a12a74075bc6081742ffbd | Rust | digitalbitbox/bitbox02-firmware | /src/rust/vendor/chacha20/src/cipher.rs | UTF-8 | 6,725 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | //! ChaCha20 stream cipher implementation.
//!
//! Adapted from the `ctr` crate.
// TODO(tarcieri): figure out how to unify this with the `ctr` crate (see #95)
use crate::{
block::{Block, BUFFER_SIZE},
rounds::{Rounds, R12, R20, R8},
BLOCK_SIZE, MAX_BLOCKS,
};
use core::{
convert::TryInto,
fmt::{s... | true |
bdeaabc8479cce86cfebc59c74d790b15d599f97 | Rust | FilippoRanza/rmd | /src/file_remove_iterator/remove_by_size.rs | UTF-8 | 2,934 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::fs::metadata;
use std::io::{Error, ErrorKind};
use std::path::Path;
use super::file_remove::FileRemove;
use super::parser::spec_string_parser;
const BYTE: u64 = 1;
//standard SI sizes
const KILO_BYTE: u64 = 1000 * BYTE;
const MEGA_BYTE: u64 = 1000 * KILO_BYTE;
const GIGA_BYTE: u64 = 1000 * MEGA_BYTE;
const ... | true |
578c4d908d9ced059317024afc81931b45be4cb7 | Rust | cramt/aoc_2020 | /src/days/day10.rs | UTF-8 | 3,562 | 3.21875 | 3 | [] | no_license | use crate::days::Day;
use std::collections::{HashMap, HashSet};
use std::num::Wrapping;
struct Node {
children: Vec<Node>,
data: usize,
}
impl Node {
pub fn new() -> Node {
Node {
children: vec![],
data: 0,
}
}
pub fn expand(&mut self) {
self.childr... | true |
bc67d437d6482b21ebf687f5b53ddce911f8a895 | Rust | tokio-rs/loom | /src/sync/mpsc.rs | UTF-8 | 2,679 | 3.140625 | 3 | [
"MIT"
] | permissive | //! A stub for `std::sync::mpsc`.
use crate::rt;
/// Mock implementation of `std::sync::mpsc::channel`.
#[track_caller]
pub fn channel<T>() -> (Sender<T>, Receiver<T>) {
let location = location!();
let (sender_channel, receiver_channel) = std::sync::mpsc::channel();
let channel = std::sync::Arc::new(rt::C... | true |
462dc33984d73f9be4eab8c5f5fd11f7afa41d89 | Rust | enukane/rust-atcoder-apg4b | /ex4.rs | UTF-8 | 181 | 2.765625 | 3 | [] | no_license | fn main() {
let seconds = 365 * 24 * 60 * 60;
println!("{}", seconds);
println!("{}", 2 * seconds);
println!("{}", 5 * seconds);
println!("{}", 10 * seconds);
}
| true |
3bbdb1af0efe8d9f1ddfa6bba497c7c14c59912e | Rust | sinistersnare/ds_store | /src/allocator.rs | UTF-8 | 20,250 | 3.171875 | 3 | [
"MIT"
] | permissive |
use std::collections::HashMap;
use byteorder::{ByteOrder, BigEndian};
use crate::Error;
// TODO verify `as usize` casts, or place them where they truly belong (where they are created, not when used).
#[derive(Debug)]
pub struct Directory<'a> {
num_internals: u32,
num_nodes: u32,
num_records: u32,
//... | true |
89c074ed078905880c188bb014750604fb175748 | Rust | cqueirolo/21C1-Stormtroopers | /redis_server/src/command/keys_cmd/ttl_cmd.rs | UTF-8 | 3,016 | 2.84375 | 3 | [] | no_license | //! Returns the expire time of a key.
//!
//! Example:
//! ```text
//! > expire key 60
//! OK
//! > ttl key
//! 60
//! ```
use crate::command::cmd_trait::Command;
use crate::command::command_builder::CommandBuilder;
use crate::command::command_parser::ParsedMessage;
use crate::errors::run_error::RunError;
use crate::se... | true |
8a8b89d92935eb00b808fcf95bae061188667fab | Rust | bgourlie/rs-nes | /rs-nes/src/apu/mocks.rs | UTF-8 | 570 | 2.75 | 3 | [
"MIT"
] | permissive | use crate::apu::IApu;
#[derive(Default)]
pub struct ApuMock {
write_addr: u16,
write_value: u8,
control: u8,
}
impl ApuMock {
pub fn write_addr(&self) -> u16 {
self.write_addr
}
pub fn write_value(&self) -> u8 {
self.write_value
}
pub fn set_control(&mut self, val: u8... | true |
9035c917b273a3ed626a4fc44dc7a36c38b289d1 | Rust | DenSA-Inc/awrevim | /src/ex.rs | UTF-8 | 2,483 | 3.21875 | 3 | [] | no_license | use crossterm::event::{KeyEvent, KeyCode};
use ropey::Rope;
use std::fmt::Write;
pub struct ExBar {
buffer: Rope,
cursor_index: usize,
}
pub enum ExResult {
StillEditing,
Aborted,
Finished(String),
}
impl ExBar {
pub fn new() -> Self {
Self {
buffer: Rope::new(),
... | true |
39908f9f079ce9e51c59cc29d93e20725ef50942 | Rust | hube12/AoC2020 | /day15/src/main.rs | UTF-8 | 1,524 | 3.171875 | 3 | [] | no_license | #![allow(unreachable_code)]
use std::fs;
use std::time::Instant;
fn solve(bound: usize, puzzle: Vec<u64>) -> usize {
let mut last_index = 1;
let mut last = 1;
let mut v = vec![(u32::MAX, u32::MAX); bound];
for el in puzzle.iter().enumerate() {
v[*el.1 as usize] = ((el.0 + 1) as u32, u32::MAX);... | true |
3da1d5989554c7e6bc19ed0a306b03fb48014927 | Rust | djc/askama | /askama/src/helpers.rs | UTF-8 | 905 | 3.265625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::iter::{Enumerate, Peekable};
pub struct TemplateLoop<I>
where
I: Iterator,
{
iter: Peekable<Enumerate<I>>,
}
impl<I> TemplateLoop<I>
where
I: Iterator,
{
#[inline]
pub fn new(iter: I) -> Self {
TemplateLoop {
iter: iter.enumerate().peekable(),
}
}
}
impl<I... | true |
8f27f167d5fb98d3bb9ec475dc03aa4081a77362 | Rust | sorpaas/bm | /le/derive/tests/derive.rs | UTF-8 | 2,002 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | use sha2::{Digest, Sha256};
use primitive_types::H256;
use bm::InMemoryBackend;
use bm_le::{IntoTree, FromTree, MaxVec, DigestConstruct, tree_root};
use generic_array::GenericArray;
fn chunk(data: &[u8]) -> H256 {
let mut ret = [0; 32];
ret[..data.len()].copy_from_slice(data);
H256::from(ret)
}
fn h(a: &[u8], b: ... | true |
ae9a62886c6015d678d67c0c333f4452bf3abb1b | Rust | lnicola/t-rex | /t-rex-core/src/service/tileset.rs | UTF-8 | 2,114 | 2.71875 | 3 | [
"MIT"
] | permissive | //
// Copyright (c) Pirmin Kalberer. All rights reserved.
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
//
use core::grid::Extent;
use core::layer::Layer;
use core::config::Config;
use core::config::TilesetCfg;
/// Collection of layers in one MVT
pub struct Tile... | true |
c93dd0e6bc577411f2cce5f398ceb595f2e726a3 | Rust | alexander-jackson/advent-of-code-2020 | /day4/src/main.rs | UTF-8 | 2,870 | 3.390625 | 3 | [] | no_license | use std::collections::HashMap;
use std::str::FromStr;
const EXPECTED_FIELDS: [&str; 7] = ["ecl", "pid", "eyr", "hcl", "byr", "iyr", "hgt"];
fn parse_input() -> Vec<String> {
let contents = std::fs::read_to_string("input.txt").unwrap();
contents
.trim()
.split("\n\n")
.map(|x| x.replac... | true |
34a6f3cadb3b3f01055b9c23f2d2dc58ea5c32c9 | Rust | songyzh/leetcode-rust | /src/solution/s0412_fizz_buzz.rs | UTF-8 | 1,436 | 3.453125 | 3 | [
"Apache-2.0"
] | permissive | /**
* [412] Fizz Buzz
*
* Write a program that outputs the string representation of numbers from 1 to n.
*
* But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For numbers which are multiples of both three and five output “FizzBuzz”.
*
* E... | true |
d8f14790f0742b2de030f37b5a955b33841524c0 | Rust | ianpreston/rust86 | /src/modrm.rs | UTF-8 | 2,960 | 3.265625 | 3 | [
"WTFPL"
] | permissive | use cstate::{CpuState, Reg8, Reg16};
use operand::Operand;
pub fn read_modrm(cs: &mut CpuState, byte_registers: bool) -> (u8, Operand, Operand) {
// Read ModR/M byte
let byte = cs.read();
// Extract `mod'
let modbits = byte & 0b11000000;
let modbits = modbits / 64;
// Extract `reg'
let r... | true |
ea2fb5e97d4206a081e7a32d07005845f5187f5e | Rust | mbougrin/Rust | /ft_time_server/src/main.rs | UTF-8 | 1,556 | 3.046875 | 3 | [] | no_license | use std::io::prelude::*;
use std::net::TcpListener;
use std::net::TcpStream;
use std::env;
use std::thread;
use std::time::Duration;
use std::time::{SystemTime, UNIX_EPOCH};
fn print_time() {
println!("{}", SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap().as_millis());
}
fn handl... | true |
5e827fee0a826beca036785aaf7e46fb9f1d7570 | Rust | hairyhum/ockam | /implementations/rust/ockam/ockam_credential/src/lib.rs | UTF-8 | 4,162 | 3.03125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Attribute based, privacy preserving, anonymous credentials.
//!
//! This crate provides the ability to issue and verify attribute based,
//! privacy preserving, anonymous credentials.
//!
//! The issuer of a credential signs a collection of statements that attest to
//! attributes of the subject of that credential.... | true |
914c70274b3c60ebdb72ffb07aa3ea6c0e08e1d0 | Rust | alex-dukhno/rust-tdd-katas | /old-katas-iteration-02/string_compression_kata/src/day_1.rs | UTF-8 | 1,281 | 3.65625 | 4 | [
"MIT"
] | permissive | pub fn compress(src: &str) -> String {
if src.is_empty() {
src.to_owned()
} else {
let mut compressed = String::new();
let mut i = 1;
let len = src.len();
let mut chars = src.chars();
let mut c = chars.next().unwrap();
let mut count = 1;
while i < ... | true |
870d864b360c1406213f673a3ef266d31eed140c | Rust | VBota1/Rust-Code-Snippets | /handleStringCLIarguments/lib.rs | UTF-8 | 617 | 2.875 | 3 | [
"MIT"
] | permissive | fn handle_arguments() -> Result<String,String> {
match args.get(1) {
Some(command) => {
match command.as_str() {
"expected" => {
Err ( "{}", log_stub (format!("Command \"expected\" is not implemented")) );
}
}
},
Non... | true |
fe4559aa15f6acbe5aa4256e0a76c71e7b126816 | Rust | magiclen/vcard | /src/values/property_id_value.rs | UTF-8 | 1,634 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::fmt::{Display, Write};
use validators::{Validated, ValidatedWrapper};
use super::*;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct PropertyIDValue {
d1: u8,
d2: Option<u8>,
}
#[derive(Clone, Debug, PartialEq)]
pub enum PropertyIDValueError {
OutOfRange,
}
impl PropertyIDValue {
pu... | true |
3c50d7581e7c16055b72e90c33e1531f0c5c175c | Rust | rusticata/pcap-analyzer | /libpcap-analyzer/src/plugins/mod.rs | UTF-8 | 3,076 | 2.515625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Plugin factory definition and default plugins implementation
use std::collections::HashMap;
use crate::{Plugin, PluginBuilder, PluginBuilderError, PluginRegistry};
use libpcap_tools::Config;
mod basic_stats;
#[cfg(feature = "plugin_community_id")]
mod community_id;
#[cfg(feature = "plugin_examples")]
mod example... | true |
93239acbe125cae9c5592e97497a4497438dcafb | Rust | maxhardt/rust-ci-github-actions-workflow | /src/lib.rs | UTF-8 | 200 | 3.546875 | 4 | [
"MIT"
] | permissive | /// Multiplies two integers
pub fn multiply(a: i32, b: i32) -> i32 {
a * b
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test() {
assert_eq!(multiply(2, 2), 4);
}
}
| true |
dabaad3484889025ce3300207b3714dbb7090570 | Rust | kimsnj/loxers | /src/resolver.rs | UTF-8 | 4,893 | 2.671875 | 3 | [] | no_license | use crate::{
ast::{self, Expr, Stmt},
error::LoxError,
token::Token,
};
use std::collections::HashSet;
type AnalysisRes = Result<(), LoxError>;
type Bindings = Vec<(*const Token, usize)>;
type BindingsRes = Result<Bindings, LoxError>;
#[derive(Default)]
pub(crate) struct Resolver {
env: Environment,
... | true |
6da62deb4769812342eb9bcfefb15e251d368381 | Rust | flyq/datastruct-algorithm | /leetcode/p0682/src/main.rs | UTF-8 | 1,311 | 2.921875 | 3 | [
"MIT"
] | permissive | fn main() {
println!("Hello, world!");
}
pub struct Solution{}
use std::collections::VecDeque;
impl Solution {
pub fn cal_points(ops: Vec<String>) -> i32 {
let mut stack: VecDeque<i32> = VecDeque::new();
let mut res = 0;
for i in 0..ops.len() {
match ops[i].as_str() {
... | true |
7455e335889cca5f510c242eb0d1191c9630ba3b | Rust | FilippoRanza/simpla | /src/semantic_analysis/error_message_generator.rs | UTF-8 | 10,594 | 3.015625 | 3 | [] | no_license | use super::semantic_error;
use extract_line_error::extract_error_code;
use simpla_parser::syntax_tree;
impl<'a> semantic_error::SemanticError<'a> {
pub fn format_error(&self, code: &str) -> String {
let msg = match self {
Self::NameRidefinition(err) => format!("name error: {}", err.format_error... | true |
7d5df272973e3876bc2d702e77a8e3c7e047e735 | Rust | dhparrick1/feroxide | /src/data_sef.rs | UTF-8 | 9,092 | 2.796875 | 3 | [
"MIT"
] | permissive | use ion::Ion;
use types::*;
use std::collections::HashMap;
// Reference: https://en.wikipedia.org/wiki/Standard_enthalpy_of_formation
// In doubt: Reference: Binas 6th edition, table 57
// Missing values from http://www.mrbigler.com/misc/energy-of-formation.html
// and http://www.conradnaleway.net/ThermoData.PDF
///... | true |
0e76940d0ce7e5d9611aadb31a022679cd11459d | Rust | liamnickell/rustyboi | /src/mmu.rs | UTF-8 | 5,906 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::result::Result;
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
pub struct MMU {
// various MMU components: WRAM, VRAM, etc.
//0000 - 3FFF From cartridge, usually a fixed bank
//4000 - 7FFF From cartridge, switchable bank
//8000 - 9FFF Vram, Only bank 0... | true |
cb6399c8d73590ef7646bc436f623c65d9aaccea | Rust | maekawatoshiki/eb | /eb_parser/src/expr.rs | UTF-8 | 7,131 | 2.71875 | 3 | [
"MIT"
] | permissive | use super::{function, Context, Error};
use crate::{
ast::expr,
lexer::token::{DelimKind, PunctKind, TokenKind},
};
use anyhow::Result;
pub fn parse(ctx: &mut Context) -> Result<expr::Node> {
parse_binop_eq_ne(ctx)
}
fn parse_binop_eq_ne(ctx: &mut Context) -> Result<expr::Node> {
let mut lhs = parse_bi... | true |
eb829b22ad76fca6cceba54d9da95e6559859a58 | Rust | rylynchen/TRPL-Code | /TRPL_05_01_struct_instance/src/main.rs | UTF-8 | 655 | 3.3125 | 3 | [] | no_license | use std::string::String;
struct User {
email: String,
username: String,
active: bool,
sign_in_count: u64,
}
fn main() {
let mut user = build_user(String::from("rylynchen@gmail.com"), String::from("rylyn"));
println!("email: {}", user.email);
user.email = String::from("test@gmail.com");
... | true |
ebc4f37f2453a5426a6698f317ec360fae8515b0 | Rust | blaenk/anymap | /src/with_clone.rs | UTF-8 | 779 | 3.359375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use std::fmt;
#[doc(hidden)]
pub trait CloneToAny {
/// Clone `self` into a new `Box<Any>` object.
fn clone_to_any(&self) -> Box<Any>;
}
impl<T: Any + Clone> CloneToAny for T {
fn clone_to_any(&self) -> Box<Any> {
Box::new(self.clone())
}
}
#[doc(hidden)]
/// Pretty much just `std::any::Any +... | true |
f57a5f332292935ed42ca56705c2b34949330f2a | Rust | ksakiyama/practice_atcoder | /arc071c/src/main.rs | UTF-8 | 1,414 | 3.109375 | 3 | [] | no_license | use std::collections::HashMap;
use std::cmp;
fn main() {
const INF : i32 = 10000;
let ascii_lower = String::from("abcdefghijklmnopqrstuvwxyz");
let mut vec = vec![];
let n = read();
for _ in 0..n {
let mut map = HashMap::new();
let s = read_line_str();
for c in s.chars() {... | true |
b446c892027776b3f66b0bf14384b7e00139e1f9 | Rust | rksm/adventofcode | /2018/rust/src/main.rs | UTF-8 | 672 | 2.796875 | 3 | [
"MIT"
] | permissive | #![feature(toowned_clone_into)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_imports)]
mod day1;
mod day2;
mod day3;
mod day4;
mod day5;
mod day9;
mod util;
fn input(day: u32) -> String {
let f = format!("data/day{}.txt", day);
std::fs::read_to_string(f).expect("input not there?")
}
fn ma... | true |
d5f30b9ace515dc59224ca15c941dcdda8944d27 | Rust | t-vlad/transaction_parser | /src/main.rs | UTF-8 | 13,246 | 3.1875 | 3 | [] | no_license | use std::{env, io};
use csv;
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
fn help() {
println!("
This program parses one CSV file as input.
Eg: cargo run -- transactions.csv
OR
transactions_parser transactions.csv
The output is text in the CSV format as well
Hist, you... | true |
c1b1b73f65ec16c27eea43e61b131a8d7f90a6bb | Rust | 1u0/puzzles | /advent-of-code-2020/day-13/src/main.rs | UTF-8 | 2,348 | 3.140625 | 3 | [] | no_license | use gcd::Gcd;
use std::io::{self, BufRead};
fn load_puzzle() -> (i32, Vec<Option<i32>>) {
let mut timestamp = 0;
let mut schedule = Vec::new();
for (i, line) in io::stdin().lock().lines().enumerate() {
let line = line.unwrap();
match i {
0 => timestamp = line.parse().unwrap(),
... | true |
e0c89eb885a323e1e40924e1d9c22d74abfae726 | Rust | sabinchitrakar/wilders-rs | /src/lib.rs | UTF-8 | 2,253 | 3.0625 | 3 | [] | no_license | #![feature(external_doc)]
use ta_common::traits::Indicator;
#[doc(include = "../README.md")]
pub struct Wilders {
period: u32,
prev_avg: f64,
sum: f64,
index: u32,
}
impl Wilders {
pub fn new(period: u32) -> Wilders {
Self {
period,
prev_avg: 0.0,
sum: ... | true |
b4f64284842d2f666948a45e53a03ecbad7857a9 | Rust | mcountryman/chip8 | /src/ui/debug.rs | UTF-8 | 3,853 | 2.515625 | 3 | [] | no_license | //! Debug widgets.
use crate::{insn::Insn, vm::Vm};
use tui::{
backend::Backend,
layout::{Alignment, Rect},
style::{Color, Style},
text::{Span, Spans},
widgets::{Block, Borders, Paragraph},
Frame,
};
pub fn keys<B: Backend>(vm: &Vm, area: Rect, ui: &mut Frame<B>) {
let mut spans = Vec::new();
let mut ... | true |
6b587921e827c0492ff84b5683e444009c816078 | Rust | Pana/rs-data-structures | /stack/src/lib.rs | UTF-8 | 181 | 3.421875 | 3 | [] | no_license |
pub trait Stack<T> {
fn push(&mut self, val: T) -> bool;
fn pop(&mut self) -> Option<T>;
fn is_empty(&self) -> bool;
fn len(&self) -> usize;
fn print(&self);
} | true |
397bf878424f43372380b6fabd220728a0b8e334 | Rust | miquels/webdav-server-rs | /pam/src/pamserver.rs | UTF-8 | 5,957 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | // Server part - the code here is fork()ed off and lives in its own
// process. We communicate with it through a unix stream socket.
//
// This is all old-fashioned blocking and thread-based code.
//
use std::io::{self, Read, Write};
use std::os::unix::io::AsRawFd;
use std::os::unix::net::UnixStream as StdUnixStream;
u... | true |
9d58a448b0365d0164d50dc1d27c63c8a13b216b | Rust | traviscole/heliocron | /src/parsers.rs | UTF-8 | 6,373 | 3.21875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::result;
use chrono::{DateTime, Duration, FixedOffset, Local, NaiveTime, TimeZone};
use super::{
enums::Event,
errors::{ConfigErrorKind, HeliocronError},
};
type Result<T> = result::Result<T, HeliocronError>;
pub fn parse_date(
date: &str,
date_fmt: &str,
time_zone: Option<&str>,
) -> Re... | true |
425a33681586972fc40a39e920c178f21c801d5e | Rust | LightAndLight/spiddy | /errors/src/lib.rs | UTF-8 | 4,895 | 3.125 | 3 | [] | no_license | use span::{Offset, SourceFiles, Span};
use std::io;
use std::io::Write;
pub enum Highlight {
Point(Offset),
Span(Span),
}
impl Highlight {
#[inline]
pub fn start(&self) -> Offset {
match self {
Highlight::Point(start) => *start,
Highlight::Span(span) => span.start,
... | true |
fcd22716a97e9ac7fbd4facb820c655a61f82d4e | Rust | thibautRe/rustrogueliketutorial | /chapter-27-cellular-automata/src/map_builders/simple_map.rs | UTF-8 | 3,374 | 2.71875 | 3 | [
"MIT"
] | permissive | use super::{MapBuilder, Map, Rect, apply_room_to_map,
apply_horizontal_tunnel, apply_vertical_tunnel, TileType,
Position, spawner, SHOW_MAPGEN_VISUALIZER};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
pub struct SimpleMapBuilder {
map : Map,
starting_position : Position,
depth: i32,
... | true |
ffcaad5e0969d629b46590a88b3dfe770f7fbda4 | Rust | jbschlosser/resin | /src/error.rs | UTF-8 | 595 | 3.078125 | 3 | [] | no_license | use std::fmt;
#[derive(PartialEq, Eq)]
pub struct RuntimeError {
pub msg: String
}
impl fmt::Debug for RuntimeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Runtime error: {}", &self.msg)
}
}
#[macro_export]
macro_rules! runtime_error{
($($arg:tt)*) => (
ret... | true |
09f69874641ef386eb7c6c40796bfd6d827ece2e | Rust | George-Payne/rust_h_w | /averages/src/main.rs | UTF-8 | 1,973 | 3.59375 | 4 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::env;
enum Average {
Unknown,
Mean,
Median,
Mode,
}
fn main() {
let mut numbers: Vec<f32> = Vec::new();
let mut kind: Average = Average::Unknown;
for argument in env::args() {
match argument.parse::<f32>() {
Ok(i) => numbers.push(... | true |
59273a0f462f377c517c21305b088d18dbf0e76d | Rust | m000/adventofcode | /2022/src/day24b.rs | UTF-8 | 13,083 | 3.21875 | 3 | [
"Unlicense"
] | permissive | #![feature(drain_filter)]
use clap::Parser;
use env_logger::Env;
use log::{debug, info};
use std::cell::Cell;
use std::fmt;
use std::fs::File;
use std::io::{BufRead, BufReader};
/// Advent of Code 2022, Day 24
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Input fi... | true |
70abb8bdf867bbf2556ae253c1e012fae4be6994 | Rust | pyaillet/dive-rs | /src/oci/image/manifest.rs | UTF-8 | 2,355 | 2.578125 | 3 | [] | no_license | use std::collections::HashMap as Map;
use serde::{Deserialize, Serialize};
use crate::oci::Hash;
pub const MANIFEST_MIME: &str = "application/vnd.docker.distribution.manifest.v2+json";
pub const CONFIG_MIME: &str = "application/vnd.docker.container.image.v1+json";
pub const LAYER_MIME: &str = "application/vnd.docker... | true |
8e56078b47f887088e471837c04eec9b5a38dc88 | Rust | vonglasow/rust-of-life | /src/main.rs | UTF-8 | 824 | 2.953125 | 3 | [] | no_license | extern crate ansi_term;
extern crate rand;
mod cell;
mod position;
mod printer;
#[cfg(not(test))]
fn main() {
use cell::Cell;
use position::Position;
use printer::CliPrinter;
use rand::Rng;
let mut rng = rand::thread_rng();
println!("Game of Life");
for y in 0..10 {
for x in 0..1... | true |
e3b46f3bf827f2784ff3e19f304d8ad2731fd853 | Rust | SallySoul/tacit | /implicit-mesh/src/function.rs | UTF-8 | 601 | 2.8125 | 3 | [] | no_license | use crate::interval::Interval;
use std::collections::HashMap;
pub trait Function: Sized {
fn evaluate(&self, x: f32, y: f32, z: f32) -> f32;
fn evaluate_interval(&self, bindings: &HashMap<char, Interval>) -> Vec<Interval>;
}
#[derive(Copy, Clone)]
pub struct ConstFunction {
pub c: f32,
}
impl Function f... | true |
d8190192997207347b0b24ea955970e52a76c103 | Rust | k-bx/ormx | /example-postgres/src/main.rs | UTF-8 | 3,154 | 3 | 3 | [
"MIT"
] | permissive | // #![feature(trace_macros)]
use chrono::{NaiveDateTime, Utc};
use ormx::{Insert, Table, Delete};
use sqlx::PgPool;
// trace_macros!(true);
// To run this example-postgres, first run `/scripts/postgres.sh` to start postgres in a docker container and
// write the database URL to `.env`. Then, source `.env` (`. .env`) ... | true |
83bbdbd73cb3f4f5873c67d78e586c25a7c4d5e2 | Rust | Gobi03/Rust_mylibrary | /Marathon/Direction.rs | UTF-8 | 404 | 3.265625 | 3 | [] | no_license | #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Direction {
Left,
Right,
Up,
Down,
}
impl Direction {
pub fn to_delta(&self) -> Coord {
match *self {
Self::Left => Coord::new((-1, 0)),
Self::Right => Coord::new((1, 0)),
Self::Up => C... | true |
34cd669796db548f34a8d3c855a1025f5164dfe2 | Rust | hilbert-space/hdf5 | /src/lib.rs | UTF-8 | 4,482 | 3.390625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Interface to [HDF5][1].
//!
//! ## Example
//!
//! ```
//! extern crate hdf5;
//! # extern crate temporary;
//!
//! use hdf5::File;
//! # use temporary::Directory;
//!
//! # fn main() {
//! let path = "data.h5";
//! # let directory = Directory::new("hdf5").unwrap();
//! # let path = directory.join(path);
//! let fi... | true |
d758151563766a64f276897886da6d1129b4dfc5 | Rust | zhangjunfang/rust_read_code | /web_basic_01/src/user.rs | UTF-8 | 490 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use actix_web::{Json, Result};
#[derive(Deserialize, Serialize, Debug)]
pub struct Info {
username: String,
email: String,
password: String,
confirm_password: String,
}
pub fn info(info: Json<Info>) -> Result<Json<Info>> {
println!("=========={:?}=========", info);
Ok(Json(Info {
usern... | true |
4580ff9d5f63980497e614eeb2d1e742c82072f2 | Rust | beschaef/rtos | /src/features/shell/mod.rs | UTF-8 | 19,462 | 3.15625 | 3 | [] | no_license | //! This module provides a basic shell / terminal to enable user interaction with the system.
//! It supports a minimal set of commands and is easily enhancable to implement new commands.
//! Currently supported commands are:
//!
//! 1. "help" -> Displays a man page which shows a list of supported commands.
//!... | true |
0fb5f60412972f29351df33911e6c7e20e8fbc96 | Rust | andrelmlins/numero-por-extenso | /src/conversor/mod.rs | UTF-8 | 3,152 | 3.625 | 4 | [
"MIT"
] | permissive | mod constantes;
use crate::tipo::TipoExtenso;
use constantes::*;
pub fn gerar_extenso(inteiro: String, decimal: String, tipo: TipoExtenso) -> String {
let inteiro_extenso = extenso(inteiro);
let decimal_extenso = extenso(decimal);
match tipo {
TipoExtenso::DECIMAL => mascara_decimal(inteiro_exten... | true |
3acd22f8c007ee07ac0aee4d8f8e46042da27635 | Rust | juancastillo0/rick-morty-back | /src/graphql/mod.rs | UTF-8 | 8,287 | 2.609375 | 3 | [] | no_license | use crate::db::{self, establish_connection};
use crate::schema::{character, episode, location};
use diesel::{
dsl::sql,
pg::Pg,
prelude::*,
sql_types::{Bool, Float},
};
use juniper::FieldResult;
use std::sync::RwLock;
pub mod character_model;
use character_model::*;
pub mod episode_model;
use episode_model::*;... | true |
fec6f1f4d1c21fc70a123e321a8831193cdf6c16 | Rust | mirek186/intakectf-2021-public | /Reversing/baby_rusty_key/src/main.rs | UTF-8 | 7,871 | 2.53125 | 3 | [] | no_license | #[macro_use]
extern crate litcrypt;
//trash rust code only obfuscates it further :p
extern crate cursive;
extern crate chrono;
use cursive::align::HAlign;
use cursive::event::{Event};
use cursive::traits::Identifiable;
use cursive::views::{Dialog, EditView, SelectView, TextView};
use cursive::Cursive;
use chrono::prel... | true |
6d62939dd9d637e7430171076dce33db577aeda7 | Rust | davechallis/rust-raytracer | /src/config.rs | UTF-8 | 1,995 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive | use std::path::Path;
use clap::{Arg, App};
pub struct Config {
width: u32,
height: u32,
samples: u32,
output: String,
inline: bool,
}
impl<'a> Config {
pub fn width(&self) -> u32 {
self.width
}
pub fn height(&self) -> u32 {
self.height
}
pub fn samples(&self)... | true |
f649c9b5fb2268d9db83c1b426d2b44dc6708fd1 | Rust | joaompsantos/exercism | /rust/raindrops/src/lib.rs | UTF-8 | 312 | 2.703125 | 3 | [] | no_license | #[allow(unused_parens)]
pub fn raindrops(n: u32) -> String {
let mut result : String = String::new();
if ( n%3 == 0) {result+="Pling"}
if ( n%5 == 0) {result+="Plang"}
if ( n%7 == 0) {result+="Plong"}
if result.is_empty() {
result = format!("{}", n);
}
result
}
| true |
23ccb8686ad7a8a190b2599289c618a54c38ecae | Rust | ebottabi/datafuse | /common/datavalues/src/series/comparison.rs | UTF-8 | 4,163 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020-2021 The Datafuse Authors.
//
// SPDX-License-Identifier: Apache-2.0.
//! Comparison operations on Series.
use common_exception::Result;
use super::Series;
use crate::arrays::ArrayCompare;
use crate::numerical_coercion;
use crate::DFBooleanArray;
use crate::DataType;
macro_rules! impl_compare {
... | true |
99a0be3e4a0a22d3d2fb722d5d2670f121b4bcf8 | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/nom-5.0.0/src/bits/macros.rs | UTF-8 | 8,119 | 3.578125 | 4 | [
"BSD-2-Clause",
"MIT"
] | permissive | //! Bit level parsers and combinators
//!
//! Bit parsing is handled by tweaking the input in most macros.
//! In byte level parsing, the input is generally a `&[u8]` passed from combinator
//! to combinator as the slices are manipulated.
//!
//! Bit parsers take a `(&[u8], usize)` as input. The first part of the tuple... | true |
ffcfdf72ca1993fb3e3c1e346c77ca7085090d7c | Rust | airpIane/offset-dumper | /src/util.rs | UTF-8 | 1,465 | 2.8125 | 3 | [] | no_license | use regex::bytes::Regex;
use iced_x86::Instruction;
use iced_x86::IntelFormatter;
use iced_x86::Formatter;
use std::time::Instant;
/// Enables the user to generate a byte regex out of the normal signature format.
pub fn generate_regex(raw: &str) -> Option<Regex> {
let mut res = raw
.to_string()
.sp... | true |
b8591f6aff785f6af3dfc29348a8cc43b19e6906 | Rust | DamonPalovaara/nerdee_engine | /src/terrain.rs | UTF-8 | 4,720 | 3.15625 | 3 | [] | no_license | use std::sync::{Arc, Mutex};
use std::thread;
use crate::engine_core::*;
use noise::{NoiseFn, Fbm};
// For file output
use std::fs::File;
use std::io::prelude::*;
const CHUNK_BLOCKS: usize = 512;
const CHUNK_RADIUS: isize = (CHUNK_BLOCKS / 2) as isize;
const BLOCK_SIZE: f64 = 0.5;
const CHUNK_SIZE: f64 = CHUN... | true |
a40630593381c32f6a76a6014b3c3174a9c4fc77 | Rust | DForshner/RustExperiments | /bevy_event_loss/src/main.rs | UTF-8 | 3,376 | 3.15625 | 3 | [
"Unlicense"
] | permissive | use bevy::prelude::*;
use bevy_diagnostic::{Diagnostic, DiagnosticId, Diagnostics};
// Purposely creating the pitfall where you can miss events because the
// receiver doesn't handle the emitted events within 2 frames.
//
// From Bevy Cookbook:
// Events don't persist. They are stored until the end of the next frame, ... | true |
7129e3f403fa0a22beb1c75372d03ed4e6327b44 | Rust | pnkfelix/rust | /src/test/ui/traits/suggest-fully-qualified-path-with-appropriate-params.rs | UTF-8 | 507 | 3.234375 | 3 | [
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | struct Thing;
trait Method<T> {
fn method(&self) -> T;
fn mut_method(&mut self) -> T;
}
impl Method<i32> for Thing {
fn method(&self) -> i32 { 0 }
fn mut_method(&mut self) -> i32 { 0 }
}
impl Method<u32> for Thing {
fn method(&self) -> u32 { 0 }
fn mut_method(&mut self) -> u32 { 0 }
}
fn mai... | true |
7cecda0b9603649949d112a8df00559d214485bf | Rust | jFransham/quake-level-loader | /src/macros.rs | UTF-8 | 4,650 | 2.671875 | 3 | [
"Unlicense"
] | permissive | macro_rules! to_3_arr {
($itr:expr) => {{
let mut i = $itr.into_iter();
[
i.next().unwrap(),
i.next().unwrap(),
i.next().unwrap(),
]
}};
}
macro_rules! to_8_arr {
($itr:expr) => {{
let mut i = $itr.into_iter();
[
i.ne... | true |
cfcd78119b3ec7c6371a6bd319b1f79d21e9a661 | Rust | earthengine/namable_closures | /src/stable_fn.rs | UTF-8 | 2,541 | 2.9375 | 3 | [] | no_license | /// Replicates the Fn traits for stable build
pub trait StableFnOnce<Input> {
type Output;
fn stable_call_once(self,args:Input) -> Self::Output;
}
/// Replicates the Fn traits for stable build
pub trait StableFnMut<Input>: StableFnOnce<Input> {
fn stable_call_mut(&mut self,args:Input) -> Self::Output;
}
///... | true |
5011eb85aed92ce1566e84cf58ed0c86b58f362d | Rust | robertgoss/aoc-2020 | /src/passwords.rs | UTF-8 | 2,663 | 3.515625 | 4 | [] | no_license | #[derive(Copy, Clone)]
pub enum RuleSet {
Sled,
Toboggan
}
struct Verification {
letter : char,
max : usize,
min : usize
}
fn parse_range(string : &str) -> Option<(usize, usize)> {
let parts = string.split_once('-').map(
|(min, max)| (min.parse::<usize>(), max.parse::<usize>())
);
... | true |
5c5c725adea5a6ab50515cdac7ebb4171a596f74 | Rust | artran/ray-tracer | /src/shape.rs | UTF-8 | 3,527 | 3.328125 | 3 | [] | no_license | use std::fmt::Debug;
use crate::color::Color;
use crate::light::PointLight;
use crate::material::Material;
use crate::matrix::Matrix;
use crate::ray::Ray;
use crate::vector4::Vector4;
pub trait Shape {
fn material(&self) -> &Material;
fn transformation(&self) -> Matrix<4>;
fn inv_transform(&self) -> &Mat... | true |
b736cfe656d06136f96a72649523ad352d47b4c4 | Rust | servo/green-rs | /librustuv/tests/async.rs | UTF-8 | 807 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use green::{Callback, RemoteCallback};
use rustuv::Async;
// Make sure that we can fire watchers in remote threads and that they
// actually trigger what they say they will.
test!(fn smoke_test() {
struct MyCallback(Option<Sender<int>>);
impl Callback for MyCallback {
fn call(&mut self) {
/... | true |
182245288a6190645e47017267a6d4050f486d88 | Rust | DoumanAsh/clipboard-script | /src/lib.rs | UTF-8 | 808 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | #[inline(always)]
///Returns whether text contains JP.
pub fn is_jp<T: AsRef<str>>(text: T) -> bool {
let text = text.as_ref();
text.chars().any(|elem_char| match elem_char { '\u{3000}'..='\u{303f}'| //punctuation
'\u{3040}'..='\u{309f}'| //hiragana
... | true |
c2e5ff0548e986eef92d4b0d3f8ce87806e73860 | Rust | defuz/sublimate | /src/core/command.rs | UTF-8 | 1,285 | 3.203125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::hash::{Hash, Hasher};
use core::settings::{Settings, SettingsObject, ParseSettings};
use self::ParseCommandError::*;
#[derive(Debug, PartialEq, Clone)]
pub struct Command {
pub name: String,
pub args: SettingsObject
}
impl Eq for Command {}
impl Hash for Command {
fn hash<H: Hasher>(&self, stat... | true |
1accf62634478041b3e5dc797b45b922de4692dd | Rust | jstarry/solana | /sdk/program/src/sysvar/slot_hashes.rs | UTF-8 | 1,248 | 2.625 | 3 | [
"Apache-2.0"
] | permissive | //! named accounts for synthesized data accounts for bank state, etc.
//!
//! this account carries the Bank's most recent bank hashes for some N parents
//!
pub use crate::slot_hashes::SlotHashes;
use crate::{account_info::AccountInfo, program_error::ProgramError, sysvar::Sysvar};
crate::declare_sysvar_id!("SysvarS1ot... | true |
83da822e878f54deae303ea39ee11358b06033b2 | Rust | EFanZh/LeetCode | /src/problem_1138_alphabet_board_path/mod.rs | UTF-8 | 1,001 | 3.234375 | 3 | [] | no_license | pub mod iterative;
pub trait Solution {
fn alphabet_board_path(target: String) -> String;
}
#[cfg(test)]
mod tests {
use super::Solution;
pub fn run<S: Solution>() {
let test_cases = [("leet", 15), ("code", 14)];
let board = ["abcde", "fghij", "klmno", "pqrst", "uvwxy", "z"];
let... | true |
0e9e35afe6973850e6c795b22c4ba17c2a726841 | Rust | syousif94/clubby | /api/src/users/routes.rs | UTF-8 | 2,886 | 2.75 | 3 | [] | no_license | use crate::cities::City;
use crate::users::*;
use serde_json::json;
use warp::{Filter, Rejection, Reply};
async fn sign_up(req: SignUpRequest) -> Result<impl Reply, Rejection> {
req.validate().await?;
let token = encode_sign_up_request(&req)?;
send_login_code(&req.phone).await?;
let res = SignUpRespons... | true |
6587f2c73a65bd07ebbe9b5f726637feece7b407 | Rust | j4qfrost/fork-the-game | /src/lib.rs | UTF-8 | 3,484 | 2.59375 | 3 | [
"MIT"
] | permissive | use log::error;
use neovide_plugin::*;
use skulpin::winit::event::{
ElementState, ModifiersState, MouseButton, MouseScrollDelta, WindowEvent,
};
use skulpin::winit::event_loop::{ControlFlow, EventLoopProxy};
use skulpin::winit::window::Window;
use skulpin::{winit::dpi::LogicalSize, Renderer as SkulpinRenderer, Win... | true |
d8bf3db7e2120f893207fb5637d96c37da2160f7 | Rust | gz/rust-fallible-iterator | /src/test.rs | UTF-8 | 4,551 | 3.375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use core::iter;
use super::{convert, FallibleIterator, Vec};
#[test]
fn all() {
assert!(convert([0, 1, 2, 3].iter().map(Ok::<&u32, ()>)).all(|&i| i < 4).unwrap());
assert!(!convert([0, 1, 2, 4].iter().map(Ok::<&u32, ()>)).all(|&i| i < 4).unwrap());
}
#[test]
fn and_then() {
let it = convert(vec![0, 1, 2,... | true |
d955d0ecadba558b5281e9a316e90f648373db83 | Rust | facebook/hhvm | /hphp/hack/src/hh_codegen/common/context.rs | UTF-8 | 5,168 | 2.59375 | 3 | [
"PHP-3.01",
"Zend-2.0",
"MIT"
] | permissive | // Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the "hack" directory of this source tree.
use std::collections::VecDeque;
use std::path::Path;
use anyhow::anyhow;
use anyhow::Result;
use hash::IndexMap;
use hash::IndexSet;
us... | true |
78c08e01c6dd7b6c81c5ac62738415fa69b9b7a4 | Rust | DeMille/encrusted | /src/rust/instruction.rs | UTF-8 | 13,558 | 2.84375 | 3 | [
"MIT"
] | permissive | use std::fmt;
use std::hash;
enum_from_primitive! {
#[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Opcode {
// Two-operand opcodes (2OP)
OP2_1 = 1, OP2_2 = 2, OP2_3 = 3, OP2_4 = 4, OP2_5 = 5, OP2_6 = 6,
OP2_7 = 7, OP2_8 = 8, ... | true |
dab41b7a538cd3d85da398fc043fe30655865b82 | Rust | lulf/dove | /src/decoding.rs | UTF-8 | 9,639 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2020, Ulf Lilleengen
* License: Apache License 2.0 (see the file LICENSE or http://apache.org/licenses/LICENSE-2.0.html).
*/
//! The decoding module contains AMQP 1.0 type decoders and rust native type decoders.
use byteorder::NetworkEndian;
use byteorder::ReadBytesExt;
use std::io::Read;
use std::v... | true |
8b087598d1c024f52c4cd8cd9b5bbec43650e8ab | Rust | caojen/heystack | /src/master/route.rs | UTF-8 | 2,751 | 2.796875 | 3 | [] | no_license | use actix_web::{ web, get, post, put, delete, Responder, HttpResponse, Error };
use super::AppState;
use futures::StreamExt;
#[put("/sync")]
pub async fn sync_index_file(data: web::Data<AppState>) -> impl Responder {
let index_file = data.index_file.lock().unwrap();
match index_file.store_into_file() {
Err(e) ... | true |
f047849cbbfad9eb95607e482720128757193b4d | Rust | algon-320/regex-vm | /src/regex/matcher.rs | UTF-8 | 3,262 | 2.875 | 3 | [] | no_license | use super::compiler::{Char, Ins, Instruction, Position};
type PC = usize;
type SP = usize;
type Context = (PC, SP, usize);
// substring match
pub fn search(ins: &Ins, text: String) -> Option<Vec<(usize, usize)>> {
let text = text.chars().collect::<Vec<_>>();
for p in 0..text.len() {
let ret = search_i... | true |
67d5965db467b8d1777d0e384bcd6d70e4de6d5b | Rust | wolvespaw/grepbot | /src/grep.rs | UTF-8 | 1,599 | 2.875 | 3 | [
"MIT"
] | permissive | use std::cmp::{Eq, PartialEq};
use std::hash::{Hash, Hasher};
use serenity::model::id::UserId;
use regex::Regex;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde::de::Error;
/// Wrapper around a `Regex, UserId` tuple that implements `PartialEq`, `Eq` and `Hash` manually,
/// using the `Regex... | true |
342085c65b61f67d56d09b9ae6b9113813676d61 | Rust | critiqjo/cmark-hamlet | /src/adapter.rs | UTF-8 | 7,930 | 3.078125 | 3 | [] | no_license | use std::borrow::Cow;
use cmark::Tag as CmTag;
use cmark::Event as CmEvent;
use hamlet::Token as HmToken;
/// _The_ adapter! An iterator that generates `hamlet::Token`s.
pub struct Adapter<'a, I> {
cm_iter: I,
cm_looka: Option<CmEvent<'a>>, // for lookahead
hm_queue: Vec<HmToken<'a>>,
group_text: bool... | true |
3530d285c0acac44b76f4a2decf27be0bd2bf797 | Rust | fbielejec/rust-opencv | /src/mat_mask_operations.rs | UTF-8 | 3,054 | 2.8125 | 3 | [] | no_license | use opencv::{
core::{self, Point, Scalar, Vec3b},
imgproc,
prelude::*,
imgcodecs
};
use crate::{utils};
#[allow(dead_code)]
fn saturate_cast (value: &i32) -> u8 {
(u8::min_value () as i32 +
(u8::max_value () as i32 / i32::max_value () ) * value) as u8
}
fn sharpen (image: &Mat, result: &mut ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.