I'm noticing a pattern. The last one may or may not be fuelled by me losing 50/50 to a Qiqi const :( reddit.com/gallery/rmuw9z
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Rayan2312
πŸ“…︎ Dec 23 2021
🚨︎ report
Style directives and new @const tag released in Svelte 3.46

Some new Svelte features were just released:

- style directives, e.g. style:color are a nice syntactic sugar for setting dynamic inline styles (REPL, docs)
- the @​const tag lets you define constants in your template (REPL, docs)

I'm excited to start using these! Check out the linked PRs and RFCs in the changelog for more info and background.

πŸ‘︎ 100
πŸ’¬︎
πŸ‘€︎ u/grich12
πŸ“…︎ Jan 12 2022
🚨︎ report
Should Const. Ben Todd be punished for a kick that hospitalized an Aboriginal teen, leaving him with part of his skull removed?
πŸ‘︎ 1k
πŸ’¬︎
πŸ‘€︎ u/Notbrunettee
πŸ“…︎ Nov 06 2021
🚨︎ report
A year has passed and we're finally stabilizing the next feature related to const generics: feature(const_generics_defaults) github.com/rust-lang/rust…
πŸ‘︎ 470
πŸ’¬︎
πŸ‘€︎ u/birkenfeld
πŸ“…︎ Dec 11 2021
🚨︎ report
var bed = 'double' const status = 'single'
πŸ‘︎ 122
πŸ’¬︎
πŸ“…︎ Jan 10 2022
🚨︎ report
What’s the rationale behind naming const generics?

It’s just confusing. I mean, β€œconst” doesn’t distinguish them from regular generics: Rust is statically typed, so types are also const-evaluated. Why isn’t it β€œvalue generics” or something?

Compare to β€œnon-type template parameters” in C++.

πŸ‘︎ 17
πŸ’¬︎
πŸ“…︎ Dec 11 2021
🚨︎ report
Convert []const u8 to []u8

I have a program where I have included a file with embedFile. I create some tokens with std.mem.tokenize() and start to iterate over them:

while (it.next()) |line| {
    var foo: []u8 = line;
}

This part fails, as line is a []const u8. I have watched a video from Loris Cro (https://www.youtube.com/watch?v=VgjRyaRTH6E) where he states that You should not use []u8 when You do not want to modify the slice, but I do want to modify it (want to call std.sort.sort() later on). How can I convert these types? I just can not figure it out.

Edit: Meanwhile I have found this: https://www.reddit.com/r/Zig/comments/jwdm50/comment/gcpn447/?utm_source=share&utm_medium=web2x&context=3

So I understand that converting does not work, but Coule I create a copy of the immutable string to my mutable variable?

πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/voroskoia
πŸ“…︎ Jan 16 2022
🚨︎ report
There is NO reason that I (a heavy armor wearing tank with almost 300 const.) should get stunned, pushed and knocked back as much as a light armor wearing mage

Just something that bothers me running tank. I get tossed around everywhere and constantly stunned or blown over (blocking or not).

πŸ‘︎ 972
πŸ’¬︎
πŸ‘€︎ u/Jefabell
πŸ“…︎ Oct 24 2021
🚨︎ report
Thread safety vs. const methods

So, I keep reading that const methods are thread-safe by default.

Can someone elaborate if this is the case, because I don't really see how this can be the case, unless there is an "in the absence of writes" implied (however with no writes, everything is thread-safe).

πŸ‘︎ 41
πŸ’¬︎
πŸ‘€︎ u/Let_Me_Be
πŸ“…︎ Dec 20 2021
🚨︎ report
*const *const u8

Sometimes I find these kinds of types in function signatures:

fn myMfunction(..., a: *const *const u8, ...) { ...}

My question is: what is the meaning of these "double const"? What is the interest to have a pointer towards a pointer? Does it serve any purpose, especially in the context of FFI?

πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/JibGir
πŸ“…︎ Jan 14 2022
🚨︎ report
Seen at a local gas station. Assuming this was prior to Const. Carry (as it is not a 30.05) , is this still a valid legally binding sign?
πŸ‘︎ 20
πŸ’¬︎
πŸ‘€︎ u/rBassToMouth69
πŸ“…︎ Jan 04 2022
🚨︎ report
Is is okay to const_cast an intializer_list just so we can call std::move on the elements?

Also is this the best way to implement Array?

#if __cplusplus>=201703L
#   define CONSTEXPR17 constexpr
#else
#   define CONSTEXPR17
#endif

     size_t m_len;
     E* m_ptr;
// ...

template <typename E>
Array<E>::Array(const std::initializer_list<E>& list) noexcept :
    m_len(list.size()),
    m_ptr(m_len == 0 ? nullptr 
        : reinterpret_cast<E*>(std::malloc(sizeof(E) * m_len)))
{
    if (m_ptr) {
        if CONSTEXPR17 (std::is_class<E>::value)
        {
            E* it = const_cast<E*>(list.begin()); // <<<<--------
            if(it) {
                if CONSTEXPR17 (std::is_move_constructible<E>::value)
                    for(size_t i=0; i<m_len; ++i)
                        new (m_ptr + i) E(std::move(it[i])); // move
                else
                    for(size_t i=0; i<m_len; ++i)
                        new (m_ptr + i) E(it[i]); // copy
            }
        }
        else
        {
            const E* it = list.begin();
            if(it)
                for(size_t i=0; i<m_len; ++i)
                    m_ptr[i] = it[i];
        }
    } 
    else m_len = 0;
}

Array code (no Tracer): https://godbolt.org/z/W8fcb1xo4

Array code + Tracer + tests: https://godbolt.org/z/PWf6Monjh

gist

sample code:

template <typename E>
class Array 
{
public:
    CONSTEXPR11 static const bool Is_Elem_Class = IFCXX11ELSE(std::is_class<E>::value, true);
    CONSTEXPR11 static const bool Is_Elem_Default_Constructible = IFCXX11ELSE(std::is_default_constructible<E>::value, true);
    CONSTEXPR11 static const bool Is_Elem_Destructible = IFCXX11ELSE(std::is_destructible<E>::value, true);
    CONSTEXPR11 static const bool Is_Elem_Copy_Constructible = IFCXX11ELSE(std::is_copy_constructible<E>::value, true);
    CONSTEXPR11 static const bool Is_Elem_Move_Constructible = IFCXX11ELSE(std::is_move_constructible<E>::value, false);
    CONSTEXPR11 static const bool Is_Elem_Copy_Assignable = IFCXX11ELSE(std::is_copy_assignable<E>::value, true);
    CONSTEXPR11 static const bool Is_Elem_Move_Assignable = IFCXX11ELSE(std::is_move_as
... keep reading on reddit ➑

πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/TheDefalt8
πŸ“…︎ Dec 21 2021
🚨︎ report
owl hair caught in 69420k (I talked to them I did talk to them later tho they said their const was full so we couldn’t be friends) reddit.com/gallery/r5id0j
πŸ‘︎ 139
πŸ’¬︎
πŸ‘€︎ u/chiplikeschaos
πŸ“…︎ Nov 30 2021
🚨︎ report
const post = new Post()
πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/typescripterus
πŸ“…︎ Nov 03 2021
🚨︎ report
Purpose of readonly props? (export const)

I'm totally new to svelte.Can someone give me a usecase for readonly properties?

// HelloWorld.svelte
<script>
	// these are readonly
	export const myProp = 'readonly';
</script>

<div>{myProp}</div> // Will always show 'readonly'

Assigning a property during component declaration as follows has no effect:

<HelloWorld myProp="some value"/>

The value "some value" gets ignored. Had I used let instead, this would work.So when does declaring property with export const become useful?

EDIT: Updated the example according to u/venir_dev's comment to make the example more reasonable.

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/zenoli55
πŸ“…︎ Jan 12 2022
🚨︎ report
Can someone describe in English words the type of [*:null]const ?[*:0]const u8 and also show some example values of that type? Thanks.

I have a rather extensive experience in both C and C++ and I will be glad for getting some help in what kind of values the type described in the title can hold and getting some example values of that type.

Specifically I am trying to call the Linux ls command from a Zig program using the function std.os.execvpeZ described here:

https://github.com/ziglang/zig/blob/a5c7742ba6fc793608b8bb7ba058e33eccd9cfec/lib/std/os.zig#L1642

Using both null arguments and other string arguments.

Note: I already know that [*:0]const u8 is equivalent to a C null terminated string.

Thanks.

πŸ‘︎ 23
πŸ’¬︎
πŸ‘€︎ u/SoftEngin33r
πŸ“…︎ Jan 15 2022
🚨︎ report
Const[A]nt of motion | by Grigory Tsvetkov
πŸ‘︎ 1k
πŸ’¬︎
πŸ‘€︎ u/xponentialdesign
πŸ“…︎ Dec 05 2021
🚨︎ report
why const reference?

Why const reference over a normal int variable decleration in this parameter list?

int max(const int& num1, const int& num2)
{
  int result;
  if (num1 > num2)
    result = num1;
  else
    result = num2;
  return result;
}
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Deadpark_
πŸ“…︎ Jan 08 2022
🚨︎ report
It's Time to Get Hyped About Const Generics in Rust nora.codes/post/its-time-…
πŸ‘︎ 348
πŸ’¬︎
πŸ‘€︎ u/NoraCodes
πŸ“…︎ Nov 06 2021
🚨︎ report
How to share a const library between node and rust

Hi! I'm looking for some best practices here.

I have a pretty big const library in ES node, which is shared between all components of my application. About 7 or 8. The const library has between 50-100 consts and is updated regularly.

Its basically a long list of this:

const SHAPETYPE = {
CIRCLE: 1,
    RECTANGLE: 2,
}
export { SHAPETYPE }

In code, all we use is SHAPETYPE.CIRCLE etc, but under the hood all that is passed around and stored in databases is the int value.

I need to access this library in rust. What would be a good way to do this without having to redefine the whole library?

One solution that I thought is to write a parser program that converts the library to rust enums, which would then be available in the code. Would this be the way to go?

Thanks!

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/garma87
πŸ“…︎ Jan 07 2022
🚨︎ report
Can some meta-programming magic help generate an array of all consts in file

Lets say I have colors.zig file with something like this:

const RGB8 = @import("color.zig");

pub const red = RGB8.init(255, 0, 0);
pub const green = RGB8.init(0, 255, 0);
pub const blue = RGB8.init(0, 0, 255);
pub const yellow = RGB8.init(255, 255, 0);
// ...

// Can I somehow generate an array of all defined colors:
pub const all = [_]RGB8 { GET_ALL_DEFINED_COLORS_FROM_ABOVE_SOMEHOW };

// Also can I get a list of color names in the same order:
pub const names = [_][_]u8 { GET_ALL_DEFINED_COLOR_NAMES_FROM_ABOVE_SOMEHOW };
πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/igors84
πŸ“…︎ Jan 14 2022
🚨︎ report
Ottawa police officer resigns after mocking, filming people with mental illness - Const. Jesse Hewitt’s resignation is effective today, per family court decision, police sources cbc.ca/news/canada/ottawa…
πŸ‘︎ 319
πŸ’¬︎
πŸ‘€︎ u/sirharryflashman
πŸ“…︎ Oct 15 2021
🚨︎ report
We use let because it is only three letters, you can use const if you want πŸ™‚ remix.run/docs/en/v1/tuto…
πŸ‘︎ 94
πŸ’¬︎
πŸ“…︎ Nov 25 2021
🚨︎ report
Equivalent of val/const/final?

I'm brand new to elixir, just started a course. Very early in it. I could be patient and wait to be taught more stuff, but where's the fun in that? Lol

I love the immutable design of elixir data structures. However it seems like an issue where you can reassign a variable. Other languages have constructs like Val/const/final that prevent this. Is there something like this in elixir?

Thanks.

πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/Droid2Win
πŸ“…︎ Dec 01 2021
🚨︎ report
Difference between var, let and const.
πŸ‘︎ 407
πŸ’¬︎
πŸ‘€︎ u/codedblood
πŸ“…︎ Oct 22 2021
🚨︎ report
Class member: const vs static

I recently had a discussion with one of my co-workers where the intent was to have one aspect of a class that was shared across all objects. By definition, this is a static member variable.

However, a good point was raised in this discussion. If you have a const member (let's say a value, i.e. not pointer or reference), wouldn't it make sense for the compiler to make this static? It seems wasteful for each object to hold something like this.

Is there reasoning why const members aren't treated as static class members?

πŸ‘︎ 17
πŸ’¬︎
πŸ‘€︎ u/jokem59
πŸ“…︎ Dec 07 2021
🚨︎ report
Xiao build help please! I had kept him in the basement until I could get a good weapon for him (been saving stardust for Kaeya consts.) and finally went for the Blackcliff. Artifact luck still hurting in some places (crit rate, sands, etc) but am I on the right track? reddit.com/gallery/ru1i9a
πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/Dahlia_Dusk
πŸ“…︎ Jan 02 2022
🚨︎ report
Killer of Const. Todd Baylis still claims self-defence - but parole board grants escorted pass torontosun.com/news/local…
πŸ‘︎ 30
πŸ’¬︎
πŸ‘€︎ u/woodenboatguy
πŸ“…︎ Nov 06 2021
🚨︎ report
Please help me debug: "keyword 'const' is reserved"
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Boomdingo
πŸ“…︎ Jan 11 2022
🚨︎ report
Prosecution fights to keep publication ban in trial of man accused of killing Const. Jeffrey Northrup cbc.ca/news/canada/toront…
πŸ‘︎ 12
πŸ’¬︎
πŸ‘€︎ u/beef-supreme
πŸ“…︎ Dec 02 2021
🚨︎ report
Const worth it for low-spender?

I'm a relatively low-spender/f2p buying only daily chests, seasonal bundles for the most part. I'm just finishing KVK3 and have Alex, YSG, and CM expertised; Sala 5/5/5/2 and Richard 5/5/1/1. He just became available through Daily Chests and my options are to either purchase Sala and over time expertise him, or purchase Const for the foreseeable future.

I dont plan on using many, if any, heads to get him 5/5/1/1 since SOC commanders will become available. But some say he isnt worth it at all

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/Jezzzv_
πŸ“…︎ Nov 25 2021
🚨︎ report
Getting tired of const AFK killers, decide to do a little experiment. v.redd.it/di9hpstql0181
πŸ‘︎ 59
πŸ’¬︎
πŸ‘€︎ u/rayletter1997
πŸ“…︎ Nov 21 2021
🚨︎ report
Gov. Wolf (unsurprisingly) vetoed PA Const Carry yesterday, but what's even more surprising is 5 Dems voted for it. Out of curiosity, Does anyone think we're starting to see a shifting of the tides or just a freak incident?

Just as a summary (from local news source):

  • 9 Republican legislators voted against
  • 5 Democrats voted for

I'm not sure what exactly the breakdown was (which D's voted Yay), as the PA site doesn't seem to have it by Party. I am curious what counties they represent though. Does anyone else think that it's odd? Or just a fluke?

Senate: https://www.legis.state.pa.us/CFDOCS/Legis/RC/Public/rc_view_action2.cfm?sess_yr=2021&sess_ind=0&rc_body=S&rc_nbr=361

House: https://www.legis.state.pa.us/CFDOCS/Legis/RC/Public/rc_view_action2.cfm?sess_yr=2021&sess_ind=0&rc_body=H&rc_nbr=624

πŸ‘︎ 16
πŸ’¬︎
πŸ‘€︎ u/oddabel
πŸ“…︎ Dec 03 2021
🚨︎ report
Accessing a function from const x = includedFileWithFunctions in another class like x.function()

Please help me sort this mess :)

I'm trying to make this work, since I'm a NodeN00b I'd really appreicate a heads up.

My co-worked has created a monsterfile filled with functions, loaded via

index.js

const x = require(file);

I have another helper function file i call like this:

const helper = require('../helper');

const helperFunc = new helper(VARS, x);

helper.js

 class Helper {
    constructor(VARS, x) {
        this._VARS = VARS;
        this._x = x;
    }
    static get VARS() {
        return this._VARS;
    }
    static get x() {
        return this._x;
    }
    needed() {
        const newTopic = x.topicFunctionInX(
            VARS.param,
            name
        );
    }
}

Thing is, I need the functions from x, to also be available in my helper file.

Everything that is related to x in my sample is a mystery to me. Anybody care to point me in the right direction?

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/kimk2
πŸ“…︎ Nov 26 2021
🚨︎ report
4 years ago today; Police motorcade escorts fallen Abbotsford Police officer Const. John Davidson from Vancouver hospital to Abbotsford. v.redd.it/5zybw0igkny71
πŸ‘︎ 79
πŸ’¬︎
πŸ‘€︎ u/CanucksKickAzz
πŸ“…︎ Nov 09 2021
🚨︎ report
Better diagnostic when you mess up const generic impl blocks

Today I was implementing my new const generic structure HeightMap:

impl HeightMap<const HEIGHT: usize, const WIDTH: usize>

But of course that's wrong, you can't do that. Rust's compiler (1.56.1) said:

error: expected one of `>`, a const expression, lifetime, or type, found keyword `const`

... which is true but unhelpful, particularly because "Huh, const isn't a const expression?" doesn't promote healthy thinking about what's wrong here.

In fact what I should write is:

impl<const HEIGHT: usize, const WIDTH: usize> HeightMap<HEIGHT, WIDTH>

It would be nice if the Rust compiler suggested I try that, or at least something closer to that, in this sort of case rather than waiting until I realize for myself.

I don't know how to go about making such a change, if it's easy maybe I should learn how.

πŸ‘︎ 19
πŸ’¬︎
πŸ‘€︎ u/tialaramex
πŸ“…︎ Dec 10 2021
🚨︎ report
Corner of 5th and Const.

I lived in Playa for a few months a while ago and use to go out in the area of 5th and Constituyentes because it seemed well populated and safe. I've been back this week and have seen a violent ruckus at a bar named Bloody Mary twice in one week, both involving the owner. Never a cop around. Is this normal for that area now? If it were once I wouldn't think twice but it's been twice in one week at the same bar. Is that area desinigrating? Is it normal for that bar?

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/DivineSwine_
πŸ“…︎ Dec 04 2021
🚨︎ report
Const objects

I've been using Dart for a few months now and I'm really bothered by not being able to prevent objects from being modified (like C++ const) when passed as function parameters.

Let's take this simple example:

class A {
   int i = 0;
}

void foo(final A a) {
   a.i = 2;
}

void main() {
   final a = A();
   foo(a);
   assert(a.i == 2);
}

I'd like to ensure that foo keeps parameter 'a' unchanged, ideally detected at compile time. Am I missing a keyword or a solution? Or is it not supposed in Dart?

πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/arnaudbr
πŸ“…︎ Dec 04 2021
🚨︎ report
how do I "fail" in const fn?

say there's a const fn that takes an i32 as parameter then return the input parameter squared, but depending on certain condition I want to just fail to compile

const fn foo(num: i32) -> i32 {
    if some_condition {
        fail_to_compile
    } else {
        num * num
    }
}

in c++ if you do anything that's invalid in constant evaluated context (like throwing an exception), the compiler will scream at you but only if the control flow reaches said invalid operation, for example:

// this code will compile just fine
// because the control flow won't reach 
// the "throw" line
consteval int foo(int num) {
    if (false) {
        throw 0xDEADBEEF;
    } else {
        return num * num;
    }
}

I'm looking for the same behavior in rust, is it possible?

πŸ‘︎ 72
πŸ’¬︎
πŸ‘€︎ u/shkspr_
πŸ“…︎ Oct 20 2021
🚨︎ report
What did the var say to his old const friend?

You haven't changed a bit.

πŸ‘︎ 47
πŸ’¬︎
πŸ‘€︎ u/Krazune
πŸ“…︎ Jan 02 2022
🚨︎ report
Is passing ints by const reference deprecated?

Are there any drawbacks to it?

What should I keep in mind except for the size of an object before using const references?

πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/EtaDaPiza
πŸ“…︎ Dec 09 2021
🚨︎ report
var, let or const ?

So when should I use each type of variable? Can someone explain in a sentence ? I feel confused and choose them randomly.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/tonystarkco
πŸ“…︎ Jan 17 2022
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.