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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
845317caa7ca70f8b4ce7f26344357ff540d5cfa | Rust | rust-lang/rust | /tests/rustdoc/check-source-code-urls-to-def-std.rs | UTF-8 | 1,123 | 2.640625 | 3 | [
"Apache-2.0",
"LLVM-exception",
"NCSA",
"BSD-2-Clause",
"LicenseRef-scancode-unicode",
"MIT",
"LicenseRef-scancode-other-permissive"
] | permissive | // compile-flags: -Zunstable-options --generate-link-to-definition
#![crate_name = "foo"]
// @has 'src/foo/check-source-code-urls-to-def-std.rs.html'
fn babar() {}
// @has - '//a[@href="{{channel}}/std/primitive.u32.html"]' 'u32'
// @has - '//a[@href="{{channel}}/std/primitive.str.html"]' 'str'
// @has - '//a[@href... | true |
0516474a9c1e93f7ec958194e8292ec71812fd48 | Rust | gemarcano/libtock-rs | /core/platform/src/syscalls.rs | UTF-8 | 933 | 2.578125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | // TODO: Implement `libtock_runtime` and `libtock_unittest`, which are
// referenced in the comment on `Syscalls`.
/// `Syscalls` provides safe abstractions over Tock's system calls. It is
/// implemented for `libtock_runtime::TockSyscalls` and
/// `libtock_unittest::FakeSyscalls` (by way of `RawSyscalls`).
pub trait ... | true |
0e2b2b17496ff2fe0db3c55f0b25e35e0c9fd0be | Rust | karjonas/advent-of-code | /2021/day24/src/lib.rs | UTF-8 | 2,482 | 2.8125 | 3 | [] | no_license | extern crate common;
#[macro_use]
extern crate scan_fmt;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
fn parse_input(input: &String) -> Vec<(i64, i64, i64)> {
let mut result = Vec::new();
let mut x = 0;
let mut y;
let mut z = 0;
let mut read_x = fal... | true |
5003963ac8a296456da24ce26eba2bee0abf4482 | Rust | theotherphil/kaleidoscope | /src/main.rs | UTF-8 | 295 | 3.296875 | 3 | [] | no_license |
pub mod lexer;
pub use crate::lexer::*;
// def plus(x, y)
// x + y
//
// plus (1 2)
//
// extern sin(x);
//
// sin(1)
fn main() {
let program = "
# Comment line
plus(1 2) # another comment
";
let tokens = tokenize(program);
println!("TOKENS");
println!("{:#?}", tokens);
}
| true |
9d7a0d1042fe6920293492bf25c421f5441d0918 | Rust | Suppr/Logitech-Led-Profile-Manager | /src/keyboard/layout.rs | UTF-8 | 37,016 | 2.59375 | 3 | [] | no_license | use std::collections::hash_map::HashMap;
use serde::{Deserialize, Serialize};
pub type KeysDB = HashMap<Key, klogi::model::Keydata>;
pub type KeydataType = (Key, klogi::model::Keydata);
//keyboard bit map representation
#[repr(C)]
#[derive(Clone, Serialize, Deserialize, Copy, Hash, Debug, PartialEq, Eq, PartialOrd, Or... | true |
07b8a976a5d3ee36390b42f950acfbd0b31cd964 | Rust | elijahandrews/ncollide | /src/procedural/to_trimesh/capsule_to_trimesh.rs | UTF-8 | 815 | 2.65625 | 3 | [
"BSD-2-Clause"
] | permissive | use na;
use geom::Capsule;
use procedural::{ToTriMesh, TriMesh};
use procedural;
use math::{Scalar, Point, Vect};
#[cfg(feature = "3d")]
impl ToTriMesh<(u32, u32)> for Capsule {
fn to_trimesh(&self, (ntheta_subdiv, nphi_subdiv): (u32, u32)) -> TriMesh<Scalar, Point, Vect> {
let diameter = self.radius() * n... | true |
9fb8679f2c4771b9650eacd0047e8fbb69df7e31 | Rust | vthib/aoc19-rust | /day6/src/main.rs | UTF-8 | 2,536 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::collections::{HashMap, HashSet};
use std::io;
use std::io::Read;
type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
fn main() -> Result<()> {
let mut input = String::new();
io::stdin().read_to_string(&mut input)?;
// from star to its satellites
let mut deps = HashMap::new()... | true |
8fadeff5986784db83da7e2d31292eda9e21025c | Rust | cdecompilador/console_color-rs | /src/platform/windows.rs | UTF-8 | 5,015 | 2.8125 | 3 | [] | no_license | //! This module includes the bindings generated by `windows` crate,
//! (should be) more standard than winapi, maintained by microsoft
#![cfg(target_family = "windows")]
use bindings::{
Windows::Win32::SystemServices::{
GetConsoleScreenBufferInfo,
SetConsoleTextAttribute,
WriteConsoleA,
... | true |
82999291f850feb87279787b3b25eef61b2295d3 | Rust | MoxxieGIT/sylphiev3 | /sylphie/sylphie_database/src/config/impls.rs | UTF-8 | 654 | 2.640625 | 3 | [] | no_license | use crate::config::ConfigType;
use std::fmt;
use sylphie_core::errors::*;
impl <T: ConfigType> ConfigType for Option<T> {
fn ui_fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Some(v) => T::ui_fmt(v, formatter),
None => formatter.write_str("(default)"),
... | true |
437444e2cdc9875b2c3b563fe861ed0cb77034b1 | Rust | faineance/rustorm | /examples/delete_category.rs | UTF-8 | 500 | 2.640625 | 3 | [
"MIT"
] | permissive | extern crate rustorm;
use rustorm::platform::postgres::Postgres;
use rustorm::query::Query;
use rustorm::query::{Filter,Equality};
fn main(){
let pg = Postgres::connect_with_url("postgres://postgres:p0stgr3s@localhost/bazaar_v6").unwrap();
match Query::delete()
.from_table("bazaar.category")
... | true |
46c694d284e40de160007ebda991fc78edfbd203 | Rust | peterwilli/Lightwatch | /PinGUIn/libpinguin/src/geospatial_fastindex/tests.rs | UTF-8 | 3,130 | 3.375 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
mod tests {
use crate::common::Rect;
use crate::geospatial_fastindex::GeoSpatialFastIndex;
use crate::println;
#[test]
fn test_add_tile2() {
let mut fastindex = GeoSpatialFastIndex::<i16, i16, u8>::new(10, 10, 10, 10);
fastindex.add(
Rect {
x... | true |
acba7bc3d7a9f8d7744519c8f39cc6105d03899c | Rust | nacleric/mdview | /src/main.rs | UTF-8 | 4,125 | 2.984375 | 3 | [] | no_license | use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use pulldown_cmark::{html, Parser};
use structopt::StructOpt;
use tiny_http::{Request, Response, Server};
use webbrowser;
extern crate ispell;
use ispell::SpellLauncher;
#[derive(Debug, StructOpt)]
enum CliArgs {
#[structopt(name = "serve", about = "Serv... | true |
5e200d9c42e03bce0739b2a72e8377c50f3107e6 | Rust | aiaoyang/processMonitorWithRust | /src/read.rs | UTF-8 | 787 | 2.953125 | 3 | [] | no_license | pub fn read_file_line_column(
file: String,
line: usize,
position: usize,
) -> Result<f64, crate::error::MyError> {
if let Ok(line) = read_file_line(file, line) {
let num = line
.split_whitespace()
.collect::<Vec<&str>>()
.get(position)
.unwrap()
... | true |
3a03eec1b0f0b20f2b317e2436a1c501a62dfa45 | Rust | etaoins/arret | /runtime-syntax/writer.rs | UTF-8 | 11,884 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | use std::io::{Result, Write};
use arret_runtime::boxed;
use arret_runtime::boxed::prelude::*;
use arret_runtime::boxed::refs::Gc;
use arret_runtime::intern::InternedSym;
macro_rules! process_escaped_chars {
($w:ident, $source:ident, $( $pattern:pat => $escape:expr ),*) => {
// Try to write sequential unes... | true |
525316fedd0c8af67a2a59d43a0470799ebfcf60 | Rust | jirutka/git-metafile | /src/git.rs | UTF-8 | 1,679 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::collections::BTreeSet;
use std::ffi::OsStr;
use std::io;
use std::os::unix::ffi::OsStrExt;
use std::path::{Path, PathBuf};
use std::process::Command;
use std::str;
pub fn repo_root() -> io::Result<PathBuf> {
let output = Command::new("git")
.args(["rev-parse", "--show-toplevel"])
.output()... | true |
b19f2bc1e61f4e79cd541229fb38426f7d170eb2 | Rust | lgarcia93/rust_tcp_server | /src/message/message.rs | UTF-8 | 3,466 | 3.453125 | 3 | [] | no_license | use std::net::{TcpStream};
use std::io::Write;
use std::ops::Deref;
#[derive(Debug)]
pub enum MessageType {
ListFiles,
GetFile,
Unknown,
}
pub struct MessageHeader {
pub message_type: MessageType,
pub content_size: u32,
}
pub struct Message {
pub header: MessageHeader,
pub content: Vec<u... | true |
40fbbeaba1965e3ed0f16ce524f5ee4fac5d0fb0 | Rust | rnleach/metfor | /src/test_utils.rs | UTF-8 | 1,645 | 3.390625 | 3 | [
"MIT"
] | permissive | //! Utilities for running unit tests.
#![macro_use]
use crate::types::*;
use std::ops::Sub;
pub fn approx_equal<L, R>(left: L, right: R, tol: <L as Sub<R>>::Output) -> bool
where
L: Quantity + From<R> + Sub<R>,
R: Quantity,
<L as Sub<R>>::Output: Quantity + PartialOrd,
{
use std::f64;
assert!(tol.u... | true |
416dbad9554bd029815e6348b07d1fce248eb664 | Rust | wieslander/aoc-2019 | /src/bin/22-01.rs | UTF-8 | 1,518 | 3.390625 | 3 | [] | no_license | use regex::Regex;
use aoc::get_input;
enum Shuffle {
NewStack,
Cut(i32),
Deal(i32),
}
impl Shuffle {
pub fn from(line: &str) -> Shuffle {
let new_stack = Regex::new(r"^deal into new stack$").unwrap();
let cut = Regex::new(r"^cut (?P<count>-?[0-9]*)$").unwrap();
let deal = Regex... | true |
aa0598fb416d680ec2dd1fc2d95f94553d78b596 | Rust | mverleg/number2name | /src/encode.rs | UTF-8 | 8,669 | 3.46875 | 3 | [
"BSD-3-Clause"
] | permissive | use crate::{
signed2unsigned_128, signed2unsigned_16, signed2unsigned_32, signed2unsigned_64, Charset,
};
macro_rules! number2name_for_type {
($name: ident, $int:ty) => {
/// Convert a number to a short string representation using the given character set.
pub fn $name(number: impl Into<$int>, c... | true |
47256fd7320253f1eb89d9022cfb57c983ef23b9 | Rust | rune-rs/rune | /crates/rune/src/modules/f64.rs | UTF-8 | 8,776 | 3.09375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! The `std::f64` module.
use core::cmp::Ordering;
use core::num::ParseFloatError;
use crate as rune;
use crate::runtime::{VmErrorKind, VmResult};
use crate::{ContextError, Module};
/// Install the core package into the given functions namespace.
pub fn module() -> Result<Module, ContextError> {
let mut m = Mod... | true |
89481e6472b9737107419ca678d18c54ef79f905 | Rust | aDotInTheVoid/picoCTF-2019-writeup | /categorys/reversing/20-Times-Up-Again/solve/src/main.rs | UTF-8 | 2,804 | 3.015625 | 3 | [] | no_license | use std::io::*;
use std::process::*;
struct Solver<'a> {
pub prob: &'a [u8],
}
impl<'a> Solver<'a> {
fn new(prob: &'a [u8]) -> Self {
Self { prob }
}
fn peek(&self) -> u8 {
*self.prob.get(0).unwrap_or(&0)
}
fn get(&mut self) -> u8 {
let ret = self.peek();
self... | true |
290e8a3a0963f4589848ce46128ff1843c2074b7 | Rust | glium/glium | /examples/shadow_mapping.rs | UTF-8 | 16,835 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | #[macro_use]
extern crate glium;
use cgmath::SquareMatrix;
use std::time::Instant;
use glium::{Surface, Display, VertexBuffer, IndexBuffer, Program, texture::DepthTexture2d};
use glutin::surface::WindowSurface;
use support::{ApplicationContext, State};
mod support;
fn create_box(display: &glium::Display<WindowSurfac... | true |
df9e2af118a9ec7bc2add2f46def5150401d2bfb | Rust | foriequal0/advent-of-code-2019 | /src/bin/03-a.rs | UTF-8 | 3,178 | 3.484375 | 3 | [] | no_license | use std::collections::HashSet;
use std::error::Error;
use std::io;
use std::io::prelude::*;
use std::str::FromStr;
type BoxedError = Box<dyn Error + 'static>;
type Result<T> = std::result::Result<T, BoxedError>;
enum Direction {
R,
L,
D,
U,
}
struct Segment {
direction: Direction,
distance: u... | true |
bf053b301f17f4b2ec022d8a344706fcedd734d1 | Rust | cawfeecoder/travs | /src/authenticator.rs | UTF-8 | 14,398 | 2.84375 | 3 | [] | no_license | use serde_json::json;
use std::fmt::{Formatter, Display};
use once_cell::sync::OnceCell;
use crate::db;
use std::collections::HashMap;
use serde_derive::{Deserialize, Serialize};
use failure_derive::*;
use crate::entity::{Entity, EntityStore, EntityError};
use crate::identifier::{Identifier, IdentifierStore, Identifier... | true |
a48afd539a71a91f2c9b8f439c93d87a968aa572 | Rust | JamesMcGuigan/ecosystem-research | /rust/rust-crash-course/src/vars.rs | UTF-8 | 569 | 3.6875 | 4 | [
"MIT"
] | permissive | // Source: https://stackoverflow.com/questions/21747136/how-do-i-print-the-type-of-a-variable-in-rust?answertab=votes#tab-top
fn type_of<T>(_: &T) -> String {
return format!("{}", std::any::type_name::<T>())
}
pub fn run() {
let name = "James";
let mut age: f64 = 37.0;
age = age + 1.0 / (2 as f64);
... | true |
8e8edbf5ca5ea382861694eb94f280143c7f4ad5 | Rust | rust-lang/stdarch | /crates/core_arch/src/x86/sse3.rs | UTF-8 | 8,920 | 2.640625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Streaming SIMD Extensions 3 (SSE3)
use crate::{
core_arch::{simd::*, simd_llvm::simd_shuffle, x86::*},
mem::transmute,
};
#[cfg(test)]
use stdarch_test::assert_instr;
/// Alternatively add and subtract packed single-precision (32-bit)
/// floating-point elements in `a` to/from packed elements in `b`.
///... | true |
58604f75d9ac049e81ae9336a2bf95906bd72603 | Rust | mtsr/polyfuse | /xtask/src/main.rs | UTF-8 | 2,656 | 2.84375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::{
ffi::OsString,
path::{Path, PathBuf},
};
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
enum Arg {
/// Install Git hooks
InstallHooks,
/// Run a script.
Script {
/// The script name
#[structopt(name = "command", parse(from_os_str))]
command: OsString,
... | true |
ca3897c3f4e892d119268974d31f89522e4689d2 | Rust | pitdicker/small-rngs | /src/sfc.rs | UTF-8 | 5,443 | 2.890625 | 3 | [] | no_license | // Copyright 2017 Paul Dicker.
// See the COPYRIGHT file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. T... | true |
9b39cef8ff8a412e3f9cd0a6ac155b61c00734a2 | Rust | DmitriiKostrov/mazai | /rust/mazai/src/main.rs | UTF-8 | 3,986 | 2.9375 | 3 | [] | no_license | use tide::{Body, Request, Response};
use tide::prelude::*;
use tera::Tera;
use tide_tera::prelude::*;
use serde_json::{Number, Value};
#[derive(Debug, Deserialize, Serialize)]
struct Animal {
name: String,
legs: u16,
}
#[derive(Debug, Deserialize, Serialize)]
struct TripDay {
seats: u16,
guests: u16
}... | true |
b89bc50b74d917ba4e70e2a13ca9e86ae0a5131d | Rust | extraymond/phala-blockchain | /standalone/pruntime/enclave-api/src/crypto.rs | UTF-8 | 1,867 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | use alloc::vec::Vec;
use parity_scale_codec::{Decode, Encode};
use crate::prpc::{Signature, SignatureType};
pub use phala_crypto::{aead, ecdh, CryptoError};
#[derive(Clone, Encode, Decode, Debug)]
pub struct EncryptedData {
pub iv: aead::IV,
pub pubkey: ecdh::EcdhPublicKey,
pub data: Vec<u8>,
}
impl Encr... | true |
2570361a8780b473b188b27ecbcc3a1f6f4e1a2a | Rust | mb64/stack_alloc | /src/bitmapped_stack.rs | UTF-8 | 9,318 | 3.484375 | 3 | [] | no_license | //! A stack allocator with a bitmap as well.
//!
//! This way it can actually de-allocate things.
use alloc::alloc::{self, AllocErr, Layout};
use core::ops;
use core::ptr::NonNull;
/// The size, in chunks, of each bitmapped stack
pub const STACK_SIZE: usize = 64;
/// Rounds the given number up to fit the alignment.
... | true |
e721fd25ffae22bb8c1509726d7555ea73726b64 | Rust | matklad/fall | /fall/tree/src/edit.rs | UTF-8 | 2,711 | 3.015625 | 3 | [
"MIT"
] | permissive | use crate::{TextEdit, TextEditBuilder, Node, File, TextRange, TextEditOp, tu};
use crate::search::find_covering_node;
pub struct FileEdit<'f> {
file: &'f File,
inserted: Vec<(Node<'f>, String)>,
replaced: Vec<(Node<'f>, String)>,
deleted: Vec<Node<'f>>,
}
impl<'f> FileEdit<'f> {
pub fn new(file: &... | true |
7941e832c59dbca8d7af0c5e7add9dea1541c0a5 | Rust | Catorpilor/aoc2018 | /day16a/src/main.rs | UTF-8 | 2,403 | 3.0625 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufReader, BufRead};
use itertools::Itertools;
use self::OpCode::*;
#[macro_use]
extern crate text_io;
type Reg = usize;
#[derive(Copy, Clone, Debug)]
enum OpCode {
AddR,
AddI,
MulR,
MulI,
BanR,
BanI,
BorR,
BorI,
SetR,
SetI,
GtIR,
GtR... | true |
cc7c3fb0f7cca7ac1e8fdb43d11cde8e77f62583 | Rust | numbaa/learn-plt | /freestyle/src/parser.rs | UTF-8 | 13,347 | 3.296875 | 3 | [] | no_license | use super::tokenizer::*;
use super::ast;
pub struct Parser {
tokenizer: Tokenizer
}
impl Parser {
fn function_call(&mut self, func: Token) -> Result<ast::AstNode, String> {
self.tokenizer.eat(1);
let mut func_node = ast::AstNode::new(ast::NodeType::FuncCall, func);
loop {
... | true |
f2b4d674337f61bebf897d6c6954123ace424a46 | Rust | RoccoDev/mcp-converter | /src/ffi/mod.rs | UTF-8 | 1,558 | 2.53125 | 3 | [] | no_license | use parser;
use std::ffi::{CStr, CString};
use std::str;
use libc::c_char;
/* Utility functions */
fn str_to_ptr(input: &str) -> *const c_char {
let c_str = CString::new(input).unwrap();
let c_ptr = c_str.as_ptr();
std::mem::forget(c_str);
c_ptr
}
fn str_from_ptr<'a>(input: *const c_char) -> &'a str... | true |
c71f5966ce73d11f5696c3691726f539ef013729 | Rust | harpsword/tex-rs | /src/tex_the_program/section_1008_to_1011.rs | UTF-8 | 4,323 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! @ @<Append an insertion to the current page and |goto contribute|@>=
//! begin if page_contents=empty then freeze_page_specs(inserts_only);
//! n:=subtype(p); r:=page_ins_head;
//! while n>=subtype(link(r)) do r:=link(r);
//! n:=qo(n);
//! if subtype(r)<>qi(n) then
//! @<Create a page insertion node with |subtype... | true |
a693d0e3666cf9daa07fdb5f6c5531bfbf165647 | Rust | curiousTauseef/tako | /src/symbol_table_builder.rs | UTF-8 | 6,266 | 2.8125 | 3 | [
"MIT"
] | permissive | use super::ast::*;
use super::database::Compiler;
use super::errors::TError;
use super::tree::{to_hash_root, HashTree};
// Walks the AST interpreting it.
#[derive(Default)]
pub struct SymbolTableBuilder {}
// TODO: Return nodes.
type Res = Result<Node, TError>;
#[derive(Debug, Clone)]
pub struct State {
pub tabl... | true |
9fae24cbafecd9239c14c53601fc058d829421e4 | Rust | gaswelder/che | /src/format_che.rs | UTF-8 | 6,412 | 3.234375 | 3 | [
"MIT"
] | permissive | use crate::nodes::*;
use crate::parser;
pub fn format_expression(expr: &Expression) -> String {
match expr {
Expression::FieldAccess {
op,
target,
field_name,
} => {
return format!("{}{}{}", format_expression(target), op, field_name.name);
}
... | true |
6e1f4aa39a6b8ae951742c708e91ad2d6d42bba1 | Rust | bnjjj/fixme_report | /src/config.rs | UTF-8 | 1,404 | 2.90625 | 3 | [
"MIT"
] | permissive | use crate::error::Error;
use crate::issue_tracker::IssueTracker;
use crate::Result;
use config_rs::Config as ConfigRs;
impl From<String> for IssueTracker {
fn from(issue_tracker: String) -> Self {
match &issue_tracker.to_lowercase()[..] {
"github" => IssueTracker::Github,
"bitbucke... | true |
add6a16c5bd5484939a782abb6188d76dcbbc348 | Rust | y3ll0wlife/rust-programming-book | /variables/src/main.rs | UTF-8 | 170 | 2.9375 | 3 | [
"MIT"
] | permissive | // Print the lyrics to the Christmas carol “The Twelve Days of Christmas,” taking advantage of the repetition in the song.
fn main() {
println!("Hello World")
}
| true |
0b8366c81aa8384276d8ee66014def5bb7f0171c | Rust | mtthw-meyer/misra-rust | /tests/compile-fail/Rule_13_5.rs | UTF-8 | 270 | 3.484375 | 3 | [
"MIT"
] | permissive | /// This function has a side effect.
fn not(x: &mut bool) -> &mut bool {
*x = !*x;
x
}
fn main() {
let mut x: bool = true;
if *not(&mut x) || *not(&mut x) {
//~^ ERROR Non-compliant - right hand operand contains persistent side-effects
}
}
| true |
b5098cbbf9ddfdc986124835006bd3c2329d595e | Rust | AlexShkor/deip-polkadot | /pallets/deip_toolkit/src/storage_ops.rs | UTF-8 | 1,062 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | //! Module contains abstractions over storage operations
//!
//!
use sp_std::collections::vec_deque::VecDeque;
/// Storage operation
pub trait StorageOp {
fn exec(self);
}
/// Fifo-queue for storage operations
pub struct StorageOpsQueue<T>(VecDeque<T>);
impl<T> StorageOpsQueue<T> {
/// Add storage operation... | true |
26208c2d607ab7c59633b4b82f8718a42e65ddc8 | Rust | hrlmartins/advent-of-code-2019 | /day_10/p1/src/main.rs | UTF-8 | 3,019 | 3.375 | 3 | [] | no_license | extern crate num_rational;
use std::io::{self, BufReader, Read, BufRead};
use num_rational::Ratio;
use std::collections::HashSet;
#[derive(Debug, PartialEq, Eq)]
struct Point {
x: i32,
y: i32
}
impl Point {
fn new(x: i32, y: i32) -> Point {
Point {
x,
y
}
}
}
... | true |
3b3a662a0eefc9f4a46a5ae6ebd6575562ac05b0 | Rust | ExPixel/miniaudio-rs | /miniaudio/examples/simple-enumeration.rs | UTF-8 | 1,485 | 2.859375 | 3 | [
"MIT"
] | permissive | use miniaudio::{Context, DeviceId, DeviceType, ShareMode};
pub fn main() {
let context = Context::new(&[], None).expect("failed to create context");
context
.with_devices(|playback_devices, capture_devices| {
println!("Playback Devices:");
for (idx, device) in playback_devices.... | true |
c744fc0b856e89a6104a328c30bfbb96381d544e | Rust | orionz/wasm-skiplist | /neon/native/src/lib.rs | UTF-8 | 7,118 | 3 | 3 | [] | no_license | #[macro_use]
extern crate neon;
extern crate skip_list;
use skip_list::{TreeMap,ListMap};
use neon::prelude::*;
fn hello(mut cx: FunctionContext) -> JsResult<JsString> {
Ok(cx.string("hello node"))
}
pub struct Skip {
data: TreeMap<String,String>
}
declare_types! {
pub class MyClass for Skip {
init(mut... | true |
c29a3808000620a8c6a28511b90e0f8a391dcef8 | Rust | vandomej/Crogue | /src/game/actors/player.rs | UTF-8 | 2,649 | 3.125 | 3 | [
"MIT"
] | permissive | use tcod::input::Key;
use tcod::console::*;
use tcod::colors;
use std::io;
use game::map::tile::Tile;
use game::actors::health::Health;
use game::actors::game_object::GameObject;
#[derive(Debug, Clone)]
pub struct Player {
pub x: i32,
pub y: i32,
head: i32,
arms: Vec<i32>,
torso: i32,
legs: Ve... | true |
8650da35c50b54269c60030bec2d2c21858d260d | Rust | cooljohnny3/numerical-methods | /src/lib.rs | UTF-8 | 12,633 | 3.359375 | 3 | [] | no_license | use std::{f64::{INFINITY}};
pub fn add(x: &Vec<isize>, y: &Vec<isize>) -> Vec<isize> {
let mut result: Vec<isize>;
let length: usize = usize::min(x.len(), y.len());
if x.len() > y.len() {
result = x.clone();
} else {
result = y.clone();
}
for i in 0..length {
let temp ... | true |
e0f5332f463a423ed50748441c0dc1247e8831e3 | Rust | BenoitZugmeyer/RustyAdventOfCode | /2015/src/bin/day16.rs | UTF-8 | 3,378 | 3.203125 | 3 | [] | no_license | #[macro_use]
extern crate lazy_static;
extern crate regex;
use regex::Regex;
use std::borrow::Borrow;
use std::collections::HashMap;
use std::io;
use std::io::BufRead;
#[derive(Debug)]
struct Things {
name: String,
data: HashMap<String, u8>,
}
impl Things {
fn new(name: &str) -> Self {
Things {
... | true |
483dfb64facd570bf5e0e0c1eaa99feb9e26de72 | Rust | tiagosr/cachoeira | /cachoeira_core/src/console.rs | UTF-8 | 1,455 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::sync::mpsc;
use std::result;
use std::cell::RefCell;
use std::ops::Deref;
use std::borrow::Borrow;
pub type ConsoleVarResult = Result<Option<String>, String>;
pub trait ConsoleVar {
fn set(&mut self, String) -> ConsoleVarResult;
fn get(&self) -> String;
}
#[derive(Deb... | true |
4c57a719885d2ddd839f71668ba325230dbed7ad | Rust | logtopus/logtopus | /src/cfg.rs | UTF-8 | 3,701 | 3.03125 | 3 | [
"Apache-2.0"
] | permissive | use config;
use config::ConfigError;
use std::path::Path;
pub fn read_config<S: AsRef<str>>(
maybe_filename: &Option<S>,
) -> Result<config::Config, config::ConfigError> {
let mut settings = config::Config::new();
let defaults = include_bytes!("default_config.yml");
settings.merge(config::File::from_s... | true |
f54d1bce14efc53d08f321dad3a8a5c4708bd7b4 | Rust | japaric/embedded2020 | /host/cmsis-dap/src/hid.rs | UTF-8 | 2,847 | 3.296875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! USB-HID operations
use std::time::Instant;
use log::trace;
pub(crate) const REPORT_ID: u8 = 0x00;
impl crate::Dap {
/// Pushes the data into the HID buffer
pub(crate) fn hid_push(&mut self, data: impl AsLeBytes) {
data.as_le_bytes(|bytes| {
let n = bytes.len();
let cursor... | true |
65268825db551df453dc3c3db9d3ef8d8585be6b | Rust | steveklabnik/rust-git-fs | /src/root.rs | UTF-8 | 2,184 | 2.625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright (C) 2014 Josh Stone
//
// 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... | true |
8500a787bfcea551762f96ef76959087b8733d6e | Rust | crawlis/keeper | /src/nats.rs | UTF-8 | 527 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | pub struct NatsSubscriber {
conn: nats::Connection,
sub: nats::Subscription,
}
impl NatsSubscriber {
pub fn new(uri: &str, subject: &str) -> std::io::Result<NatsSubscriber> {
let conn = nats::connect(uri)?;
let sub = format!("{}.*", subject);
let sub = conn.queue_subscribe(&sub, "ke... | true |
11b9fb78d53d092dcbb778b8dc53268a55b7728e | Rust | zzeroo/programmieren-in-rust-notes | /aufgaben/sheet06/sol3/swagger.rs | UTF-8 | 573 | 3.3125 | 3 | [] | no_license | use std::fmt;
use std::env;
struct Swagger<T>(pub T);
impl<T: fmt::Display> fmt::Display for Swagger<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "yolo {} swag", self.0)
}
}
trait SwaggerExt: Sized {
fn with_swag(self) -> Swagger<Self>;
}
impl<T> SwaggerExt for T {
f... | true |
30c51b2048d99a295e2e5ab4ad0afb501a764d5d | Rust | likr/atcoder | /typical90/src/bin/009.rs | UTF-8 | 1,524 | 2.765625 | 3 | [] | no_license | use ordered_float::OrderedFloat;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;
#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]... | true |
58f06125b8a970c38b2efdb540b213b0c9945183 | Rust | winksaville/fuchsia | /third_party/rust_crates/vendor/tokio-executor/src/typed.rs | UTF-8 | 5,321 | 3.765625 | 4 | [
"MIT",
"BSD-3-Clause"
] | permissive | use SpawnError;
/// A value that spawns futures of a specific type.
///
/// The trait is generic over `T`: the type of future that can be spawened. This
/// is useful for implementing an executor that is only able to spawn a specific
/// type of future.
///
/// The [`spawn`] function is used to submit the future to th... | true |
bf9603e89fac84f5c958f407b1388773b38dfd92 | Rust | SimonCarlson/exercism | /rust/clock/src/lib.rs | UTF-8 | 2,987 | 3.65625 | 4 | [] | no_license | use std::cmp;
use std::fmt;
pub struct Clock {
hours: i32,
minutes: i32,
}
impl Clock {
pub fn new(hours: i32, minutes: i32) -> Self {
let mut deducted_hours = 0;
let mut wrapped_hours;
let mut wrapped_minutes;
let mut extra_hours = 0;
if minutes < 0 {
... | true |
fd6a366c514325a8155945fcc0c9d2949fda9cae | Rust | rchaser53/rust-monkey-ir | /src/parser/expressions.rs | UTF-8 | 6,307 | 3.484375 | 3 | [] | no_license | use std::fmt;
use parser::infix::*;
use parser::prefix::*;
use parser::statements::*;
#[derive(PartialEq, Clone, Debug)]
pub struct Identifier(pub String);
#[derive(PartialEq, Clone, Debug)]
pub enum Expression {
Identifier(Identifier, Location),
IntegerLiteral(u64, Location),
StringLiteral(String, Locat... | true |
f07646603bd1661d9a614ebedada36aee7476143 | Rust | darwins-challenge/genoculars | /src/dirlist.rs | UTF-8 | 2,502 | 2.96875 | 3 | [
"MIT"
] | permissive | use glob;
use std::path::{Path,PathBuf};
use std::error::Error;
use std::fs::File;
use std::ffi::OsStr;
use std::io::Read;
use iron::middleware::Handler;
use iron::prelude::*;
use iron::status;
use rustc_serialize::json;
pub struct DirectoryLister {
pub directory: String
}
fn name_from_path(pb: PathBuf) -> Op... | true |
21a14470cf2bf8d8e4eb579fdf6017dd4e42a179 | Rust | Mutestock/mini-project-loner-edition | /grpc/src/client.rs | UTF-8 | 1,915 | 2.53125 | 3 | [] | no_license | // For manual testing in this project
#[macro_use]
extern crate lazy_static;
mod entities;
mod utils;
use entities::student::student_client::StudentClient;
use entities::student::{CreateStudentRequest, ReadStudentRequest};
use tonic::transport::Channel;
use utils::config::{is_production_mode, CONFIG};
#[tokio::main... | true |
d10659c6c8dc32f029d3cd1d8495ffc1d6b64138 | Rust | dorayakikun/alfred_jira_workflow | /src/item.rs | UTF-8 | 908 | 3.34375 | 3 | [
"MIT"
] | permissive | #[derive(Debug, Serialize, Deserialize)]
pub struct Item {
pub title: String,
pub arg: String,
}
#[derive(Debug)]
pub struct ItemBuilder<TitleType, ArgType> {
pub title: TitleType,
pub arg: ArgType,
}
impl ItemBuilder<(), ()> {
pub fn new() -> Self {
ItemBuilder { title: (), arg: () }
... | true |
eeeb93cedcde08d53dded9cc785f0b09bf582927 | Rust | raymondnumbergenerator/spire_rogue | /src/components/creature.rs | UTF-8 | 4,042 | 2.515625 | 3 | [] | no_license | use specs::prelude::*;
use specs::saveload::{Marker, ConvertSaveload};
use specs::error::NoError;
use specs_derive::{Component, ConvertSaveload};
use serde::{Serialize, Deserialize};
use super::super::{monsters};
use rltk::RandomNumberGenerator;
#[derive(Component, Debug, Serialize, Deserialize, Clone)]
p... | true |
eda2a3c2073c1b7cbdda4c51795fc68e6c380814 | Rust | Schwenger/RustTak | /src/player/command_line_human/cli_parser.rs | UTF-8 | 5,646 | 3.46875 | 3 | [
"MIT"
] | permissive | use crate::actions::Action;
use crate::board::Position;
use crate::board::piece::PieceKind;
use crate::board::Direction;
use regex::Regex;
pub(crate) struct CLIParser {}
pub(crate) type Result<T> = std::result::Result<T, CLIParserError<T>>;
impl CLIParser {
pub(crate) fn action(s: &str) -> Result<Action> {
... | true |
5cd483cbf2897ef66b5aaed9042c7dff842086c2 | Rust | RobertWHurst/Delta | /src/worker.rs | UTF-8 | 2,144 | 2.8125 | 3 | [] | no_license | use std::thread::{spawn, JoinHandle};
use std::sync::{Arc, Mutex, RwLock};
use scene::Scene;
use controller::ControllerApi;
pub struct Worker {
end_worker_thread: Arc<Mutex<bool>>,
join_handle: Option<JoinHandle<()>>,
}
impl Worker {
pub fn new(worker_index: usize, scene_mx: Arc<RwLock<Option<Scene>>>) ->... | true |
74b2036e5e0ea2294d74e5bc47ae55831d24d406 | Rust | Dstate/clex | /src/token.rs | UTF-8 | 2,036 | 3.515625 | 4 | [] | no_license | use std::fmt;
use std::ops::Range;
pub use ConstKind::*;
pub use ErrorKind::*;
pub use TokenKind::*;
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
pub enum TokenKind {
/* tokens */
Keyword,
Ident,
Const(ConstKind),
StrLit,
Punct,
/* compiler internal tokens */
Comment,
... | true |
764dcd52232fa9b8497289ee00c2801a469d7964 | Rust | JakubGrobelny/University | /2019-2020/zima/Rust/lista1/square_area_to_circle.rs | UTF-8 | 700 | 3.765625 | 4 | [] | no_license | fn square_area_to_circle(area: f64) -> f64 {
let radius: f64 = area.sqrt() / 2.0;
radius * radius * std::f64::consts::PI
}
fn assert_close(a:f64, b:f64, epsilon:f64) {
assert!( (a-b).abs() < epsilon, format!("Expected: {}, got: {}",b,a) );
}
#[test]
fn test0() {
assert_close(square_area_to_circle(0.0... | true |
625f6f1ec4f083fbef19cc7e30846cb0a1e46bd6 | Rust | ManishVerma16/Rust_Learning | /rust_basics/src/impl_keyword.rs | UTF-8 | 710 | 4.1875 | 4 | [] | no_license | // impl keyword is used to add method to a structs to make it more useful
struct Rectangle {
width: u32,
length: u32
}
impl Rectangle {
fn print_description(&self){ //adding description method
println!("Rectangle: {} x {}", self.width, self.length);
}
fn area(&self){ // adding area metho... | true |
68836e22086cd06dc4f9fba24e1645955a008169 | Rust | nabor/azurita | /src/azurita/ast/ast.rs | UTF-8 | 2,606 | 3.21875 | 3 | [
"MIT"
] | permissive | use azurita::Token;
use azurita::Expresion;
use azurita::expresions::{AzInteger, AzOperator};
pub fn generate(tokens: Vec<Token>) -> Result<(), &'static str>{
let debug = false;
let mut stack = Vec::<Expresion>::new();
for token in tokens {
match token {
Token::Number(number) => {
... | true |
3f1527f9ed9f3448222ca64134a240916c63ab71 | Rust | oysterpack/oysterpack-smart-near | /near/oysterpack-smart-staking-pool/src/domain/unstaked_balances.rs | UTF-8 | 12,134 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::components::staking_pool::State;
use oysterpack_smart_near::asserts::ERR_INSUFFICIENT_FUNDS;
use oysterpack_smart_near::domain::{EpochHeight, YoctoNear};
use oysterpack_smart_near::near_sdk::{
borsh::{self, BorshDeserialize, BorshSerialize},
env,
};
use std::cmp::Ordering;
use std::collections::BTree... | true |
5cfc17d9951375e96094376d1d732ce97183b793 | Rust | uwe-app/bracket | /tests/lines.rs | UTF-8 | 2,934 | 3.09375 | 3 | [] | no_license | use bracket::{
parser::ast::{CallTarget, Lines, Node},
Registry, Result,
};
const NAME: &str = "lines.rs";
#[test]
fn lines_text() -> Result<()> {
let registry = Registry::new();
let value = r"This is some text
that spans multiple lines
so we can check the line range.";
let template = registry.par... | true |
a4892213502fc5a24fbe6fbfeea78c23d2377725 | Rust | Thaddeus19/rust-programming | /snippets/src/fmt_arguments.rs | UTF-8 | 519 | 3.171875 | 3 | [] | no_license | #![allow(unused_macros)]
#[allow(dead_code)]
fn format_message(entry: std::fmt::Arguments) -> String {
use std::fmt::Write;
let mut message = String::new();
message.write_fmt(entry);
message
}
macro_rules! log {
($format:tt, $($arg:expr), *) => {
format_message(format_args!($format, $($ar... | true |
fcfdf3792431041a6014fd2f53381d81c662a2b7 | Rust | everynote/dropbox-api-content-hasher | /rust/src/run_tests.rs | UTF-8 | 2,410 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | //! A command-line tool that runs the `DropboxContentHasher` tests.
extern crate digest;
extern crate rand;
extern crate dropbox_content_hasher;
extern crate sha2;
use digest::Digest;
use std::io::Write as io_Write;
use rand::Rng;
use dropbox_content_hasher::{DropboxContentHasher, BLOCK_SIZE};
fn main() {
let mu... | true |
12e56e66c697b5e459dad562a3b0fb81b25ed870 | Rust | hzkazmi/Batch6_34_Quarter1 | /may_17_2020_imran/chap5/src/main.rs | UTF-8 | 1,522 | 3.390625 | 3 | [] | no_license | #[derive(Debug)]
struct Food {
resturant: String, //field
food_item:String,
size:u8,
price:u16,
availablilty:bool
} //blue print
fn main() {
let pizza = Food {
resturant: String::from("Pizza Hut"),
food_item:String::from("Chicken Fajita"),
availablilty:true,
price:1500,
... | true |
5a86ffc73f0eaddfeefe204f665d8da53db65c23 | Rust | Schenk75/Learn-Rust | /exercism/etl/src/lib.rs | UTF-8 | 364 | 2.84375 | 3 | [] | no_license | use std::collections::BTreeMap;
pub fn transform(h: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> {
let mut map: BTreeMap<char, i32> = BTreeMap::new();
for (point, char_list) in h.iter() {
for ch in char_list {
let count = map.entry(ch.to_ascii_lowercase()).or_insert(0);
*co... | true |
bd9d205c23048cc078189118ef8aed32009c39b5 | Rust | mnts26/aws-sdk-rust | /sdk/ssmcontacts/src/client.rs | UTF-8 | 88,911 | 2.53125 | 3 | [
"Apache-2.0"
] | permissive | // Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
#[derive(Debug)]
pub(crate) struct Handle<
C = smithy_client::erase::DynConnector,
M = aws_hyper::AwsMiddleware,
R = smithy_client::retry::Standard,
> {
client: smithy_client::Client<C, M, R>,
conf: crate::Config,
}
//... | true |
4cdf51d47e762fb92c2b5ef7f0fc73dc0af807ea | Rust | hegza/serpent-rs | /src/transpile/rust.rs | UTF-8 | 605 | 2.6875 | 3 | [
"MIT"
] | permissive | use rustc_ap_rustc_ast::ast::{Item, ItemKind, Stmt, StmtKind};
/// An item, a statement, a newline or a comment of Rust.
#[derive(Clone, Debug)]
pub enum NodeKind {
/// An anonymous Rust AST item matching with rustc_ast::ItemKind.
Item(ItemKind),
/// A Rust AST item with attributes, ident, etc. matching wi... | true |
4116dc16a74536b558df6f83c8505d3ca5973e5b | Rust | multifacet/0sim-experiments | /src/bin/memcached_and_capture_thp.rs | UTF-8 | 6,060 | 2.609375 | 3 | [] | no_license | //! Sits in a loop doing `put` operations on the given memcached instance. The keys are unique, but
//! the values are large, all-zero values.
//!
//! We do N insertions, followed by N/3 deletions, followed by N/2 more insertions.
//!
//! In the meantime, every N seconds, it executes syscall 335 to get THP compaction s... | true |
333678a476a4f451f9e5678e5d228cc2469d0748 | Rust | wieslander/aoc-2019 | /src/bin/07-02.rs | UTF-8 | 1,000 | 2.78125 | 3 | [] | no_license | use itertools::Itertools;
use std::cmp;
use aoc::get_input;
use aoc::intcode::Program;
fn main() {
let initial_memory = get_input()
.split(',')
.map(|x| x.parse().expect("NaN"))
.collect();
let mut max_output = 0;
let mut amps = vec![];
for _ in 0..5 {
let amp = Progr... | true |
c31b5c8522fd55129ad3704e7871a7526dc3ae24 | Rust | liguangsheng/leetcode-rust | /src/a0643_maximum_average_subarray_i.rs | UTF-8 | 932 | 3.359375 | 3 | [
"MIT"
] | permissive | /*
* [0643] maximum-average-subarray-i
*/
pub struct Solution {}
// solution impl starts here
impl Solution {
pub fn find_max_average(nums: Vec<i32>, k: i32) -> f64 {
let mut max_sum;
let mut sum = 0;
for i in 0..=k - 1 {
sum += nums[i as usize];
}
max_sum = ... | true |
f6d76eda012d671e2f72ac0aa41b9510ef65ab9c | Rust | Inspirateur/DungeonChess | /src/pgn.rs | UTF-8 | 908 | 3.203125 | 3 | [
"MIT"
] | permissive | use crate::piece::{Action, Piece};
use crate::pos::Pos;
fn piece2pgn(piece: Piece) -> &'static str {
match piece {
Piece::Pawn {
orientation: _,
status: _,
} => "p",
Piece::Knight => "N",
Piece::Bishop => "B",
Piece::Rook => "R",
Piece::Queen ... | true |
aa77f422f615c90169d345aee2faa66fc6671fff | Rust | deadalusai/raytracer | /raytracer-impl/src/texture.rs | UTF-8 | 3,138 | 3.109375 | 3 | [] | no_license | use std::sync::Arc;
use super::implementation::{ Texture, HitRecord };
use super::types::{ V2, V3 };
// Constant colors
#[derive(Clone)]
pub struct ColorTexture(pub V3);
impl Texture for ColorTexture {
fn value(&self, _hit_record: &HitRecord) -> V3 {
self.0
}
}
// Checker texture
#[derive(Clone)]
... | true |
4a3e0845beb24167fd5fe7ccc8974ee1b6a74a2e | Rust | antonromanov1/dragon-book-compiler | /src/ir.rs | UTF-8 | 19,397 | 2.875 | 3 | [] | no_license | use std::cell::RefCell;
use std::rc::Rc;
use crate::lexer::*;
macro_rules! unreachable {
() => {
panic!("Unreachable code");
};
}
fn error(s: &str, line: u32) -> ! {
println!("near line {}: {}", line, s);
std::process::exit(0);
}
pub fn emit_label(i: u32) {
print!("L{}:", i);
}
fn emit(... | true |
5e2e8151f993b80a5a341565f288f258c583142b | Rust | fooki/pong-deathmatch | /src/server.rs | UTF-8 | 1,011 | 2.984375 | 3 | [] | no_license | use crate::server_network::ServerNet;
use crate::server_state::{ServerState, WaitingForP1};
use laminar::{ErrorKind};
use std::net::SocketAddr;
pub fn run(my_addr: &str) ->Result<(), ErrorKind> {
let addr: SocketAddr = my_addr.parse().unwrap();
let net = ServerNet::bind(addr)?;
let initial_state = Box::ne... | true |
05f1ba2791030bf51067dc1c64590ceb13a2db72 | Rust | kellerkindt/w5500 | /src/host/mod.rs | UTF-8 | 2,263 | 2.796875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | mod dhcp;
mod manual;
pub use self::dhcp::Dhcp;
pub use self::manual::Manual;
use crate::bus::Bus;
use crate::register;
use crate::MacAddress;
use embedded_nal::Ipv4Addr;
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct HostConfig {
mac: MacAddress,
#[cfg_attr(feature = "defmt... | true |
9fb7b8c3c179d863a3fda9c3d787b28334627895 | Rust | algeriastartupjobs/algeriastartupjobs.com | /api/src/search/service.rs | UTF-8 | 9,648 | 2.5625 | 3 | [
"MIT"
] | permissive | use bk_tree::{metrics, BKTree};
use itertools::Itertools;
use serde::{Deserialize, Serialize};
use sqlx::{Pool, QueryBuilder, Row, Sqlite};
use std::sync::{Arc, Mutex};
use crate::{
_utils::{
error::SearchError,
string::{escape_double_quote, get_searchable_words, get_words},
},
account::model::{AccountNa... | true |
986a472f3ca3a8045c72926b4e00aab47bcbb4b0 | Rust | Kryod/rustacean | /src/commands/versions.rs | UTF-8 | 1,180 | 2.703125 | 3 | [] | no_license | use serenity::{
prelude::Context,
model::channel::Message,
framework::standard::{ CommandResult, macros::command },
};
#[command]
#[aliases("version", "ver")]
fn versions(ctx: &mut Context, msg: &Message) -> CommandResult {
let data = ctx.data.read();
let lang_manager = data.get::<crate::LangManage... | true |
43f563519a373f2b18aee6425970b68a12a7fa38 | Rust | justahero/ok-sudoku | /src/parser.rs | UTF-8 | 1,736 | 2.953125 | 3 | [] | no_license | use peg::parser;
use crate::sudoku::{GridError, Sudoku};
parser! {
grammar sudoku_parser() for str {
rule empty() -> u8
= $(['-' | '.' | '0' ]) { 0 }
rule number() -> u8
= n:$(['0'..='9']) { str::parse::<u8>(n).unwrap() }
rule _ = [' ' | '\n' | '\r' | '\t']*
... | true |
bf703aabaffb29e5b1c2b7de658ef48ecb2498b2 | Rust | Orca-bit/DataStructureAndAlgorithm | /src/union_find/_399_evaluate_division.rs | UTF-8 | 3,025 | 3.328125 | 3 | [] | no_license | use std::collections::HashMap;
struct Solution;
impl Solution {
pub fn calc_equation(
equations: Vec<Vec<String>>,
values: Vec<f64>,
queries: Vec<Vec<String>>,
) -> Vec<f64> {
let n = equations.len();
let mut union_find = UnionFind::new(n * 2);
let mut map = Has... | true |
692f51b552cfa5659c3273eef2b8525903aed930 | Rust | shioyama18/apue | /example/ch04_files_and_directories/e06_cp.rs | UTF-8 | 1,152 | 2.625 | 3 | [
"MIT"
] | permissive | use anyhow::Result;
use apue::c_void;
use apue::constants::FILE_MODE;
use apue::result::NumericResult;
use libc::{creat, lseek, open, read, write, O_RDONLY, SEEK_CUR};
use std::ffi::CString;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
#[structopt(parse(try_from_str = CString::new))]
sour... | true |
c32a678a55708b0d79627c744d79635bcb816aa1 | Rust | rodrimati1992/abi_stable_crates | /abi_stable/src/abi_stability/extra_checks.rs | UTF-8 | 28,321 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Contains items for adding checks to individual types.
//!
//! # Implementing and using ExtraChecks
//!
//! To add extra checks to a type follow these steps:
//!
//! - Create some type and implement ExtraChecks for it,
//!
//! - Apply the `#[sabi(extra_checks = const expression that implements ExtraChecks)]`
//! ... | true |
7fd2001e3f2bedd9dd66fefb4e6078c44aa29b47 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/rusqlite/src/backup.rs | UTF-8 | 13,214 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"LicenseRef-scancode-public-domain"
] | permissive | /
/
!
Online
SQLite
backup
API
.
/
/
!
/
/
!
To
create
a
[
Backup
]
you
must
have
two
distinct
[
Connection
]
s
-
one
/
/
!
for
the
source
(
which
can
be
used
while
the
backup
is
running
)
and
one
for
/
/
!
the
destination
(
which
cannot
)
.
A
[
Backup
]
handle
exposes
three
methods
:
/
/
!
[
step
]
(
Backup
:
:
step
)... | true |
b3939be07a256ce1b0474b92bfdd3d5681998402 | Rust | facebook/hermes | /unsupported/juno/crates/juno_support/src/timer.rs | UTF-8 | 2,825 | 2.96875 | 3 | [
"MIT"
] | permissive | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
use std::fmt::Display;
use std::fmt::Formatter;
use std::time::Duration;
use std::time::Instant;
type Mark = (&'static str, Dura... | true |
5333af0a7f730cc983522d3c3c0cf7861db7cab6 | Rust | nvzqz/userutils | /src/bin/id.rs | UTF-8 | 6,512 | 2.75 | 3 | [
"MIT"
] | permissive | extern crate arg_parser;
extern crate extra;
extern crate redox_users;
use std::borrow::Borrow;
use std::hash::Hash;
use std::env;
use std::io::{self, Write, Stderr, StdoutLock};
use std::process::exit;
use extra::io::fail;
use extra::option::OptionalExt;
use arg_parser::{ArgParser, Param};
use redox_users::{get_egid... | true |
fd9696e9c57f3d533f09efc4cdbe3e389c523875 | Rust | CosmicSyntax/minmaxheap | /src/main.rs | UTF-8 | 308 | 2.78125 | 3 | [] | no_license | use minmaxheap::Heap;
fn main() {
let mut heap = Heap::new("max", 10).expect("Something did not work");
heap.add(20);
heap.add(10);
heap.add(5);
heap.add(100);
heap.add(2);
heap.add(40);
heap.add(40);
println!("{}", heap);
heap.invert();
println!("{}", heap);
}
| true |
181b0270d3e1b5997964b83a6df8abc5a7211865 | Rust | dat2/rtags | /src/tag.rs | UTF-8 | 885 | 3.28125 | 3 | [] | no_license | use std::fmt;
#[derive(Debug, PartialEq, Eq)]
pub enum ExCmd {
GCmd(String),
QPattern(String),
LineNo(usize),
}
impl fmt::Display for ExCmd {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
ExCmd::GCmd(p) => write!(f, "/{}/;\"", p),
ExCmd::QPattern(p... | true |
88f1fad0c3c169549a586975b12d90f3a85a2ce1 | Rust | usagi/usagi-rust-reference | /チュートリアルから得られること/.src/array_slice.rs | UTF-8 | 713 | 3.421875 | 3 | [
"MIT"
] | permissive | fn main()
{
let a = [ 1u, 2, 3, 4, 5 ];
// array は C++ でいう std::valarray のように
// slice によってスライス(slice)を生成できる。
// スライスの型は &[T] となる。
let first_index = 1u;
let last_index = 4u;
let s: &[uint] = a.slice( first_index, last_index );
print!( "s: " );
for v in s.iter() { print!( "{} ", v ); }
println!( ... | true |
362ee0844474fa40ac7e63aaf54d22561d9c7e86 | Rust | hannobraun/cargo-task | /.cargo-task/setup.ct.rs | UTF-8 | 2,503 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | /*
# always run this setup task before any other tasks
@ct-bootstrap@ true @@
# error if cargo-task client binary is not new enough
@ct-min-version@ 0.0.7 @@
@ct-help@ Rebuild tasks if cargo_task_util.rs is updated. @@
@ct-cargo-deps@
num_cpus = "1"
@@
*/
use std::path::Path;
use cargo_task_util::*;
fn mtime<P: A... | true |
b6356f9c1fb4d224fc849e35c3921567f6b92c18 | Rust | dmvict/wTools | /rust/impl/meta/mod_interface/meta/use_tree.rs | UTF-8 | 1,514 | 2.828125 | 3 | [
"MIT"
] | permissive | /// Internal namespace.
pub( crate ) mod private
{
use proc_macro_tools::prelude::*;
#[ derive( Debug, PartialEq, Eq, Clone ) ]
pub struct UseTree
{
pub leading_colon : Option< syn::token::Colon2 >,
pub tree : syn::UseTree,
}
impl UseTree
{
/// Is adding prefix to the tree path required?
... | true |
2d1d2c7b834714b0c3e56e2e6767ab81c5a99f0a | Rust | LiveSplit/livesplit-core | /src/settings/image/shrinking.rs | UTF-8 | 4,090 | 2.875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use alloc::borrow::Cow;
use bytemuck_derive::{Pod, Zeroable};
use image::{
codecs::{bmp, farbfeld, hdr, ico, jpeg, pnm, tga, tiff, webp},
guess_format, load_from_memory_with_format, ImageDecoder, ImageEncoder, ImageFormat,
};
use std::io::Cursor;
use crate::util::byte_parsing::{big_endian::U32, strip_pod};
fn... | true |
4b5a04e616920696744a0a7f5891d4442e51267f | Rust | maxtnuk/gluesql | /test-suite/src/validate/unique.rs | UTF-8 | 2,590 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use {
crate::*,
gluesql_core::{executor::ValidateError, prelude::Value},
};
test_case!(unique, async move {
run!(
r#"
CREATE TABLE TestA (
id INTEGER UNIQUE,
num INT
)"#
);
run!(
r#"
CREATE TABLE TestB (
id INTEGER UNIQUE,
num INT UNIQUE
)"#
);
run!(
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.